diff --git a/src/main/java/org/dimdev/dimdoors/client/ModShaders.java b/src/main/java/org/dimdev/dimdoors/client/ModShaders.java index 4a9bf209..57c9e723 100644 --- a/src/main/java/org/dimdev/dimdoors/client/ModShaders.java +++ b/src/main/java/org/dimdev/dimdoors/client/ModShaders.java @@ -15,4 +15,14 @@ public class ModShaders { public static Shader getDimensionalPortal() { return DIMENSIONAL_PORTAL; } + + private static Shader STATIC = null; + + public static void setStaticShader(Shader dimensionalPortal) { + STATIC = dimensionalPortal; + } + + public static Shader getStaticShader() { + return STATIC; + } } diff --git a/src/main/java/org/dimdev/dimdoors/mixin/client/GameRendererMixin.java b/src/main/java/org/dimdev/dimdoors/mixin/client/GameRendererMixin.java index bf19706a..15ed412f 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/client/GameRendererMixin.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/client/GameRendererMixin.java @@ -33,5 +33,6 @@ public abstract class GameRendererMixin { @Inject(method = "loadShaders", at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 1, target = "java/util/List.add(Ljava/lang/Object;)Z"), locals = LocalCapture.CAPTURE_FAILSOFT) public void onReload(ResourceManager manager, CallbackInfo ci, List list, List list2) throws IOException { list2.add(Pair.of(new Shader(manager, "dimensional_portal", VertexFormats.POSITION), (Consumer) ModShaders::setDimensionalPortal)); + list2.add(Pair.of(new Shader(manager, "static", VertexFormats.POSITION), (Consumer) ModShaders::setStaticShader)); } } diff --git a/src/main/resources/assets/minecraft/shaders/core/static.fsh b/src/main/resources/assets/minecraft/shaders/core/static.fsh new file mode 100644 index 00000000..588d3599 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/core/static.fsh @@ -0,0 +1,31 @@ +#version 150 + +#moj_import + +uniform sampler2D Sampler0; +uniform sampler2D Sampler1; + +uniform float GameTime; +uniform int EndPortalLayers; + +in vec2 UV0; +in vec2 UV2; + +out vec4 fragColor; + +float Noise21 (vec2 p, float ta, float tb) { + return fract(sin(p.x*ta+p.y*tb)*5678.); +} + +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); + + fragColor = vec4(col, 1.0); +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/shaders/core/static.json b/src/main/resources/assets/minecraft/shaders/core/static.json new file mode 100644 index 00000000..1be0d5b9 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/core/static.json @@ -0,0 +1,24 @@ +{ + "blend": { + "func": "add", + "srcrgb": "srcalpha", + "dstrgb": "1-srcalpha" + }, + "vertex": "static", + "fragment": "static", + "attributes": [ + "Position", + "Color", + "UV0", + "UV2", + "Normal" + ], + "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 ] } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/shaders/core/static.vsh b/src/main/resources/assets/minecraft/shaders/core/static.vsh new file mode 100644 index 00000000..0b24c5fe --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/core/static.vsh @@ -0,0 +1,24 @@ +#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); +}