Added static shader.
This commit is contained in:
parent
5344e36e88
commit
146f6a89bb
4 changed files with 64 additions and 35 deletions
|
@ -68,6 +68,18 @@ public class MyRenderLayer extends RenderLayer {
|
|||
.build(false)
|
||||
);
|
||||
|
||||
public static RenderLayer STATIC = RenderLayerFactory.create(
|
||||
"static",
|
||||
VertexFormats.POSITION_TEXTURE,
|
||||
VertexFormat.DrawMode.QUADS,
|
||||
2097152,
|
||||
true,
|
||||
false,
|
||||
RenderLayer.MultiPhaseParameters.builder()
|
||||
.shader(new Shader(ModShaders::getStaticShader))
|
||||
.build(true));
|
||||
|
||||
|
||||
public static RenderLayer getMonolith(Identifier texture) {
|
||||
RenderLayer.MultiPhaseParameters multiPhaseParameters = RenderLayer.MultiPhaseParameters.builder().texture(new RenderPhase.Texture(texture, false, false)).shader(new Shader(GameRenderer::getRenderTypeEntityTranslucentShader)).transparency(RenderPhase.TRANSLUCENT_TRANSPARENCY).cull(DISABLE_CULLING).lightmap(ENABLE_LIGHTMAP).depthTest(RenderPhase.ALWAYS_DEPTH_TEST).overlay(ENABLE_OVERLAY_COLOR).build(false);
|
||||
return RenderLayerFactory.create("monolith", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, VertexFormat.DrawMode.QUADS, 256, true, true, multiPhaseParameters);
|
||||
|
|
|
@ -1,31 +1,63 @@
|
|||
#version 150
|
||||
/*
|
||||
static.frag
|
||||
by Spatial
|
||||
05 July 2013
|
||||
|
||||
#moj_import <matrix.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
uniform sampler2D Sampler1;
|
||||
Taken from: https://stackoverflow.com/a/17479300
|
||||
*/
|
||||
#version 330 core
|
||||
|
||||
uniform float GameTime;
|
||||
uniform int EndPortalLayers;
|
||||
|
||||
in vec2 UV0;
|
||||
in vec2 UV2;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
float Noise21 (vec2 p, float ta, float tb) {
|
||||
return fract(sin(p.x*ta+p.y*tb)*5678.);
|
||||
// A single iteration of Bob Jenkins' One-At-A-Time hashing algorithm.
|
||||
uint hash( uint x ) {
|
||||
x += ( x << 10u );
|
||||
x ^= ( x >> 6u );
|
||||
x += ( x << 3u );
|
||||
x ^= ( x >> 11u );
|
||||
x += ( x << 15u );
|
||||
return x;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = vec2(UV0) / vec2(1920, 1080);
|
||||
|
||||
float t = GameTime + 123.;
|
||||
float ta = t * .654321;
|
||||
float tb = t * (ta * .123456);
|
||||
|
||||
float c = Noise21(uv, ta, tb);
|
||||
vec3 col = vec3(c);
|
||||
// Compound versions of the hashing algorithm I whipped together.
|
||||
uint hash( uvec2 v ) { return hash( v.x ^ hash(v.y) ); }
|
||||
uint hash( uvec3 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ); }
|
||||
uint hash( uvec4 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ^ hash(v.w) ); }
|
||||
|
||||
fragColor = vec4(col, 1.0);
|
||||
|
||||
|
||||
// Construct a float with half-open range [0:1] using low 23 bits.
|
||||
// All zeroes yields 0.0, all ones yields the next smallest representable value below 1.0.
|
||||
float floatConstruct( uint m ) {
|
||||
const uint ieeeMantissa = 0x007FFFFFu; // binary32 mantissa bitmask
|
||||
const uint ieeeOne = 0x3F800000u; // 1.0 in IEEE binary32
|
||||
|
||||
m &= ieeeMantissa; // Keep only mantissa bits (fractional part)
|
||||
m |= ieeeOne; // Add fractional part to 1.0
|
||||
|
||||
float f = uintBitsToFloat( m ); // Range [1:2]
|
||||
return f - 1.0; // Range [0:1]
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Pseudo-random value in half-open range [0:1].
|
||||
float random( float x ) { return floatConstruct(hash(floatBitsToUint(x))); }
|
||||
float random( vec2 v ) { return floatConstruct(hash(floatBitsToUint(v))); }
|
||||
float random( vec3 v ) { return floatConstruct(hash(floatBitsToUint(v))); }
|
||||
float random( vec4 v ) { return floatConstruct(hash(floatBitsToUint(v))); }
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 inputs = vec3( texCoord0, GameTime ); // Spatial and temporal inputs
|
||||
float rand = random( inputs ); // Random per-pixel value
|
||||
vec3 luma = vec3( rand ); // Expand to RGB
|
||||
|
||||
fragColor = vec4( luma, 1.0 );
|
||||
}
|
|
@ -8,17 +8,11 @@
|
|||
"fragment": "static",
|
||||
"attributes": [
|
||||
"Position",
|
||||
"Color",
|
||||
"UV0",
|
||||
"UV2",
|
||||
"Normal"
|
||||
"UV0"
|
||||
],
|
||||
"uniforms": [
|
||||
{ "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] },
|
||||
{ "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] },
|
||||
{ "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] },
|
||||
{ "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }
|
||||
{ "name": "GameTime", "type": "float", "count": 1, "values": [ 0.0 ] }
|
||||
]
|
||||
}
|
|
@ -1,24 +1,15 @@
|
|||
#version 150
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
in vec2 UV2;
|
||||
in vec3 Normal;
|
||||
|
||||
uniform mat4 ModelViewMat;
|
||||
uniform mat4 ProjMat;
|
||||
|
||||
out vec2 texCoord0;
|
||||
out float vertexDistance;
|
||||
out vec4 vertexColor;
|
||||
out vec4 normal;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
texCoord0 = UV0;
|
||||
vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz);
|
||||
vertexColor = Color;
|
||||
normal = ProjMat * ModelViewMat * vec4(Normal, 0.0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue