Added static shader for later testing figuring out.

This commit is contained in:
Waterpicker 2021-06-09 03:33:58 -05:00
parent 35cc2270ea
commit 17df485200
5 changed files with 90 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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<Shader>) ModShaders::setDimensionalPortal));
list2.add(Pair.of(new Shader(manager, "static", VertexFormats.POSITION), (Consumer<Shader>) ModShaders::setStaticShader));
}
}

View file

@ -0,0 +1,31 @@
#version 150
#moj_import <matrix.glsl>
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);
}

View file

@ -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 ] }
]
}

View file

@ -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);
}