diff options
author | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-11-08 17:44:27 +1100 |
---|---|---|
committer | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-11-08 17:44:27 +1100 |
commit | 07403ec86c53f67b94d988b4c01a0afc2fdb2810 (patch) | |
tree | fba4b3c37b02c42267e03a07453d3941c98fd66d /src/main/resources/assets/notenoughupdates/shaders | |
parent | fc4143dd3c892b11ae5f427fcecc22044ff98460 (diff) | |
parent | ec0660e41145d3d9ed479b3e697afddf8ddc8c4c (diff) | |
download | NotEnoughUpdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.tar.gz NotEnoughUpdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.tar.bz2 NotEnoughUpdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.zip |
uh yeah its pretty necessary guys
Diffstat (limited to 'src/main/resources/assets/notenoughupdates/shaders')
20 files changed, 509 insertions, 6 deletions
diff --git a/src/main/resources/assets/notenoughupdates/shaders/cape.frag b/src/main/resources/assets/notenoughupdates/shaders/cape.frag index cbe00c70..bfc089bb 100644 --- a/src/main/resources/assets/notenoughupdates/shaders/cape.frag +++ b/src/main/resources/assets/notenoughupdates/shaders/cape.frag @@ -8,9 +8,9 @@ void main() { vec4 texture = texture2D(textureIn, gl_TexCoord[0].st); gl_FragColor = texture * passColour; - vec3 fakeSunNormal = normalize(vec3(0.2f,1f,-0.2f)); + vec3 fakeSunNormal = normalize(vec3(0.2f,1.0f,-0.2f)); vec3 normNormal = normalize(passNormal); float shading = max(0.6f, dot(fakeSunNormal, normNormal)); - gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a);//gl_FragColor.rgb*shading + gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a); }
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/shaders/fade_cape.frag b/src/main/resources/assets/notenoughupdates/shaders/fade_cape.frag index 76738c31..33d6b341 100644 --- a/src/main/resources/assets/notenoughupdates/shaders/fade_cape.frag +++ b/src/main/resources/assets/notenoughupdates/shaders/fade_cape.frag @@ -16,16 +16,16 @@ vec3 hsv2rgb(vec3 c) { void main() { vec4 texture = texture2D(textureIn, gl_TexCoord[0].st); - float hue = mod(millis/10000f+gl_TexCoord[0].t, 1f); + float hue = mod(millis/10000.0f+gl_TexCoord[0].t, 1.0f); float sat = 0.5f; float val = 0.5f; vec3 fade = hsv2rgb(vec3(hue, sat, val)); - gl_FragColor = vec4(texture.rgb*texture.a + fade*(1-texture.a), 1f) * passColour; + gl_FragColor = vec4(texture.rgb*texture.a + fade*(1.0f-texture.a), 1.0f) * passColour; - vec3 fakeSunNormal = normalize(vec3(0.2f,1f,-0.2f)); + vec3 fakeSunNormal = normalize(vec3(0.2f,1.0f,-0.2f)); vec3 normNormal = normalize(passNormal); float shading = max(0.6f, dot(fakeSunNormal, normNormal)); gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a); -}
\ No newline at end of file +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/lava_cape.frag b/src/main/resources/assets/notenoughupdates/shaders/lava_cape.frag new file mode 100644 index 00000000..9fb35990 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/lava_cape.frag @@ -0,0 +1,32 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; +uniform sampler2D textureIn; + +uniform int millis; + +void main() { + vec4 texture = texture2D(textureIn, gl_TexCoord[0].st); + + float t = gl_TexCoord[0].t; + t = clamp(t, 10.0f/1024.0f, 410.0f/1024.0f); + + float index = mod(millis/30.0f-t*1024.0f, 1024.0f); + float xIndex = mod(index, 1024.0f); + float yIndex = mod(gl_TexCoord[0].s*1024.0f+millis/500.0f, 421.0f)+421.0f; + vec3 lava = texture2D(textureIn, vec2(xIndex/1024.0f, yIndex/1024.0f)).xyz; + + float factor = (lava.r / 0.65f)*(lava.r / 0.65f); + lava.r += sin(mod(millis/2000.0f, 6.28f))*factor*0.15f+sin(mod(millis/500.0f, 6.28f))*factor*0.15f; + lava.g += sin(mod(millis/2000.0f, 6.28f))*factor*0.15f; + lava.b += sin(mod(millis/2000.0f, 6.28f))*factor*0.15f; + + gl_FragColor = vec4(texture.rgb*texture.a + lava*(1.0f-texture.a), 1.0f) * passColour; + + vec3 fakeSunNormal = normalize(vec3(0.2f,1.0f,-0.2f)); + vec3 normNormal = normalize(passNormal); + float shading = max(0.6f, dot(fakeSunNormal, normNormal)); + + gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a); +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/lava_cape.vert b/src/main/resources/assets/notenoughupdates/shaders/lava_cape.vert new file mode 100644 index 00000000..2b5c48f8 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/lava_cape.vert @@ -0,0 +1,12 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; + +void main() { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + + passColour = gl_Color; + passNormal = normalize(gl_Normal); +}
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/shaders/lightning_cape.frag b/src/main/resources/assets/notenoughupdates/shaders/lightning_cape.frag new file mode 100644 index 00000000..c4472679 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/lightning_cape.frag @@ -0,0 +1,13 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; +uniform sampler2D textureIn; + +uniform int millis; + +void main() { + vec4 texture = texture2D(textureIn, gl_TexCoord[0].st); + + gl_FragColor = vec4(texture.rgb*shading, gl_FragColor.a); +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/lightning_cape.vert b/src/main/resources/assets/notenoughupdates/shaders/lightning_cape.vert new file mode 100644 index 00000000..2b5c48f8 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/lightning_cape.vert @@ -0,0 +1,12 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; + +void main() { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + + passColour = gl_Color; + passNormal = normalize(gl_Normal); +}
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/shaders/make_gold.frag b/src/main/resources/assets/notenoughupdates/shaders/make_gold.frag new file mode 100644 index 00000000..e771f2c2 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/make_gold.frag @@ -0,0 +1,38 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passPosition; +uniform sampler2D textureIn; + +uniform float amount; + +//Algorithm by sam hocevar +vec3 rgb2hsv(vec3 c) { + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 1.0e-10; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); +} + +//Algorithm by hughsk +vec3 hsv2rgb(vec3 c) { + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); +} + +void main() { + vec4 texture = texture2D(textureIn, gl_TexCoord[0].st); + + vec3 hsv = rgb2hsv(texture.rgb); + + float hue = mod(hsv.x + amount + passPosition.x*4.0f, 1.0f); + float sat = hsv.y*0.7f; + float val = hsv.z; + vec3 fade = hsv2rgb(vec3(hue, sat, val)); + + gl_FragColor = vec4(fade.rgb, texture.a); +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/make_gold.vert b/src/main/resources/assets/notenoughupdates/shaders/make_gold.vert new file mode 100644 index 00000000..40a9d08a --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/make_gold.vert @@ -0,0 +1,13 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passPosition; + +void main() { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + + passPosition = gl_Position.xyz; + + passColour = gl_Color; +}
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/shaders/mcworld_cape.frag b/src/main/resources/assets/notenoughupdates/shaders/mcworld_cape.frag new file mode 100644 index 00000000..1dc5e1c8 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/mcworld_cape.frag @@ -0,0 +1,129 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; +uniform sampler2D textureIn; + +uniform int millis; + +//Algorithm by hughsk +vec3 hsv2rgb(vec3 c) { + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); +} + +vec3 rgb2hsv(vec3 c) { + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 1.0e-10; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); +} + +void main() { + vec4 texture = texture2D(textureIn, gl_TexCoord[0].st); + + float t = gl_TexCoord[0].t; + t = clamp(t, 10.0f/1024.0f, 410.0f/1024.0f); + + float start = 56.0f - 44.0f*t/(420.0f/1024.0f); + float width = 182.0f + 90.0f*t/(420.0f/1024.0f); + float scaleFactor = 1.0f/(width/1024.0f)*112.0f; + + float index = mod(millis/20.0f+t*scaleFactor, 2820.0f); + float yIndex = floor(index/1024.0f)*112.0f-(gl_TexCoord[0].s-start/1024.0f)*scaleFactor+532.0f; + float xIndex = mod(index, 1024.0f); + vec3 world = texture2D(textureIn, vec2(xIndex/1024.0f, yIndex/1024.0f)).xyz; + + float hue = 0.0f; + float saturation = 1.0f; + float value = 1.0f; + if(index < 208) { //sky + float blurFactor = clamp((index-158)/100.0f, 0.0f, 0.5f); + + hue = 200.0f; + saturation = 1.0f - blurFactor; + value = 0.9f - 0.6f*blurFactor; + } else if(index < 800) { //underground + if(index < 400) { + float blurFactor = clamp((258-index)/100.0f, 0.0f, 0.5f); + + hue = 200.0f; + saturation = 0.0f + blurFactor; + value = 0.3f + 0.6f*blurFactor; + } else { + float blurFactor = clamp((index-750)/100.0f, 0.0f, 0.5f); + + hue = 350.0f; + saturation = 0.0f + 0.5f*blurFactor; + value = 0.3f - 0.1f*blurFactor; + } + } else if(index < 1762) { //nether + if(index < 1200) { + float blurFactor = clamp((850-index)/100.0f, 0.0f, 0.5f); + + hue = 350.0f; + saturation = 0.5f - 0.5f*blurFactor; + value = 0.2f + 0.1f*blurFactor; + } else { + float blurFactor = clamp((index-1712)/100.0f, 0.0f, 0.5f); + + hue = 350.0f; + saturation = 0.5f - 0.5f*blurFactor; + value = 0.2f + 0.1f*blurFactor; + } + } else if(index < 2200) { //underground + if(index < 1900) { + float blurFactor = clamp((1812-index)/100.0f, 0.0f, 0.5f); + + hue = 350.0f; + saturation = 0.0f + 0.5f*blurFactor; + value = 0.3f - 0.1f*blurFactor; + } else { + float blurFactor = clamp((index-2150)/100.0f, 0.0f, 0.5f); + + hue = 0.0f; + saturation = 0.0f; + value = 0.3f - 0.3f*blurFactor; + } + } else if(index < 2600) { //end + if(index < 2400) { + float blurFactor = clamp((2250-index)/100.0f, 0.0f, 0.5f); + + hue = 0.0f; + saturation = 0.0f; + value = 0.0f + 0.3f*blurFactor; + } else { + float blurFactor = clamp((index-2550)/100.0f, 0.0f, 0.5f); + + hue = 200.0f; + saturation = 0.0f + blurFactor; + value = 0.0f + 0.9f*blurFactor; + } + } else { //sky + float blurFactor = clamp((2650-index)/100.0f, 0.0f, 0.5f); + + hue = 200.0f; + saturation = 1.0f - blurFactor; + value = 0.9f - 0.9f*blurFactor; + } + hue = mod(hue, 360.0f); + saturation = max(0.0f, min(1.0f, saturation)); + value = max(0.0f, min(1.0f, value)); + + vec3 hsv = rgb2hsv(texture.rgb); + hsv.x = hue/360.0f; + hsv.y *= saturation; + hsv.z *= value; + + gl_FragColor = vec4(hsv2rgb(hsv)*texture.a + world*(1.0f-texture.a), 1.0f) * passColour; + + vec3 fakeSunNormal = normalize(vec3(0.2f,1.0f,-0.2f)); + vec3 normNormal = normalize(passNormal); + float shading = max(0.6f, dot(fakeSunNormal, normNormal)); + + gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a); +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/mcworld_cape.vert b/src/main/resources/assets/notenoughupdates/shaders/mcworld_cape.vert new file mode 100644 index 00000000..2b5c48f8 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/mcworld_cape.vert @@ -0,0 +1,12 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; + +void main() { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + + passColour = gl_Color; + passNormal = normalize(gl_Normal); +}
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/blur.json b/src/main/resources/assets/notenoughupdates/shaders/program/blur.json new file mode 100644 index 00000000..9da3c2e8 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/program/blur.json @@ -0,0 +1,21 @@ +{ + "blend": { + "func": "add", + "srcrgb": "srcalpha", + "dstrgb": "1-srcalpha" + }, + "vertex": "sobel", + "fragment": "blur2", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "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": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] }, + { "name": "AlphaMult", "type": "float", "count": 1, "values": [ 1.0 ] } + ] +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh b/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh new file mode 100644 index 00000000..ca64470a --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh @@ -0,0 +1,34 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +uniform vec2 BlurDir; +uniform float Radius; +uniform float AlphaMult; + +void main() { + vec4 blurred = vec4(0.0); + float totalStrength = 0.0; + float totalAlpha = 0.0; + float totalSamples = 0.0; + for(float r = -Radius; r <= Radius; r += 1.0) { + vec4 sample = texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir); + + // Accumulate average alpha + totalAlpha = totalAlpha + sample.a; + totalSamples = totalSamples + 1.0; + + // Accumulate smoothed blur + //float strength = (2.0 - abs(r / Radius))*sample.a; + float strength = sample.a; + totalStrength = totalStrength + strength; + blurred = blurred + sample; + } + float alpha = totalAlpha/totalSamples*AlphaMult; + gl_FragColor = vec4(blurred.rgb / totalStrength, alpha); +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.fsh b/src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.fsh new file mode 100644 index 00000000..c7bcfb0f --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.fsh @@ -0,0 +1,32 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +uniform float radiusSq = 0.5f; + +uniform vec2 InSize; +uniform vec2 OutSize; + +varying vec2 texCoord; + +void main() { + if(radiusSq < 0.5 && (texCoord.s-0.5)*(texCoord.s-0.5)+(texCoord.t-0.5)*(texCoord.t-0.5) > radiusSq) { + discard; + } + + /*float totalAlpha = 0.0f; + vec3 accum = vec3(0.0); + + for(int x = -1; x<3; x++) { + for(int y = -1; y<3; y++) { + vec4 pixel = texture2D(DiffuseSampler, texCoord+vec2(x, y)/InSize); + + accum += pixel.rgb * pixel.a; + totalAlpha += pixel.a; + } + } + gl_FragColor.a = totalAlpha/4*4; + gl_FragColor.rgb = accum/4*4;*/ + + gl_FragColor = texture2D(DiffuseSampler, texCoord); +}
\ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.json b/src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.json new file mode 100644 index 00000000..bb41ffd5 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.json @@ -0,0 +1,19 @@ +{ + "blend": { + "func": "add", + "srcrgb": "srcalpha", + "dstrgb": "1-srcalpha" + }, + "vertex": "dungeonmap", + "fragment": "dungeonmap", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "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": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "radiusSq", "type": "float", "count": 1, "values": [ 1.0 ] } + ] +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.vsh b/src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.vsh new file mode 100644 index 00000000..01a16db5 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/program/dungeonmap.vsh @@ -0,0 +1,16 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 OutSize; + +varying vec2 texCoord; + +void main(){ + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + texCoord = Position.xy / OutSize; + texCoord.y = 1.0 - texCoord.y; +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.fsh b/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.fsh new file mode 100644 index 00000000..324602fd --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.fsh @@ -0,0 +1,11 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; + +void main(){ + vec4 diffuseColor = texture2D(DiffuseSampler, texCoord); + + gl_FragColor = vec4(diffuseColor.a); +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.json b/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.json new file mode 100644 index 00000000..653764fb --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/program/setrgbtoalpha.json @@ -0,0 +1,17 @@ +{ + "blend": { + "func": "add", + "srcrgb": "srcalpha", + "dstrgb": "1-srcalpha" + }, + "vertex": "blit", + "fragment": "setrgbtoalpha", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "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": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/sobel.vsh b/src/main/resources/assets/notenoughupdates/shaders/program/sobel.vsh new file mode 100644 index 00000000..21b17369 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/program/sobel.vsh @@ -0,0 +1,20 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 InSize; +uniform vec2 OutSize; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + oneTexel = 1.0 / InSize; + + texCoord = Position.xy / OutSize; + texCoord.y = 1.0 - texCoord.y; +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/space_cape.frag b/src/main/resources/assets/notenoughupdates/shaders/space_cape.frag new file mode 100644 index 00000000..e3e5d56e --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/space_cape.frag @@ -0,0 +1,60 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; +uniform sampler2D textureIn; + +uniform int millis; +uniform int eventMillis; +uniform float eventRand; //0-1 + +void main() { + vec4 texture = texture2D(textureIn, gl_TexCoord[0].st); + + vec2 texCoord = gl_TexCoord[0].st + vec2(mod(millis/100.0f,1024.0f)/1024.0f, 421.0f/1024.0f); + + vec4 extra = vec4(0,0,0,0); + if(eventRand < 0.4f) { + vec2 extraPos = vec2(45.0f+eventRand/0.4f*250.0f, eventMillis/300.0f*550.0f)/1024.0f; + vec2 extraTexCoord = vec2(48.0f/1024.0f-(gl_TexCoord[0].t-extraPos.y), gl_TexCoord[0].s-extraPos.x+894.0f/1024.0f); + if(extraTexCoord.x > 0.0f && extraTexCoord.x < 200.0f/1024.0f) { + if(extraTexCoord.y > 843.0f/1024.0f && extraTexCoord.y < 943.0f/1024.0f) { + extra = texture2D(textureIn, extraTexCoord); + } + } + } else if(eventRand < 0.45f) { + vec2 extraPos = vec2(-30.0f+eventMillis/2000.0f*370.0f, 50.0f+(eventRand-0.4f)/0.05f*300.0f)/1024.0f; + vec2 extraTexCoord = vec2(gl_TexCoord[0].s-extraPos.x+248.0f/1024.0f, gl_TexCoord[0].t-extraPos.y+894.0f/1024.0f); + if(extraTexCoord.x > 200.0f/1024.0f && extraTexCoord.x < 300.0f/1024.0f) { + if(extraTexCoord.y > 843.0f/1024.0f && extraTexCoord.y < 943.0f/1024.0f) { + extra = texture2D(textureIn, extraTexCoord); + } + } + } else if(eventRand < 0.47f) { + vec2 extraPos = vec2(-30.0f+eventMillis/2000.0f*370.0f, 50.0f+(eventRand-0.45f)/0.02f*300.0f)/1024.0f; + vec2 extraTexCoord = vec2(gl_TexCoord[0].s-extraPos.x+348.0f/1024.0f, gl_TexCoord[0].t-extraPos.y+894.0f/1024.0f); + if(extraTexCoord.x > 300.0f/1024.0f && extraTexCoord.x < 400.0f/1024.0f) { + if(extraTexCoord.y > 843.0f/1024.0f && extraTexCoord.y < 943.0f/1024.0f) { + extra = texture2D(textureIn, extraTexCoord); + } + } + } else if(eventRand < 0.48f) { + vec2 extraPos = vec2(-30.0f+eventMillis/2000.0f*370.0f, 50.0f+(eventRand-0.47f)/0.01f*300.0f)/1024.0f; + vec2 extraTexCoord = vec2(gl_TexCoord[0].s-extraPos.x+448.0f/1024.0f, gl_TexCoord[0].t-extraPos.y+894.0f/1024.0f); + if(extraTexCoord.x > 400.0f/1024.0f && extraTexCoord.x < 500.0f/1024.0f) { + if(extraTexCoord.y > 843.0f/1024.0f && extraTexCoord.y < 943.0f/1024.0f) { + extra = texture2D(textureIn, extraTexCoord); + } + } + } + + vec3 space = texture2D(textureIn, texCoord).rgb; + + gl_FragColor = vec4(texture.rgb*texture.a + extra.rgb*extra.a*(1.0f-texture.a) + space*(1.0f-texture.a)*(1.0f-extra.a), 1.0f) * passColour; + + vec3 fakeSunNormal = normalize(vec3(0.2f,1.0f,-0.2f)); + vec3 normNormal = normalize(passNormal); + float shading = max(0.6f, dot(fakeSunNormal, normNormal)); + + gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a); +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/space_cape.vert b/src/main/resources/assets/notenoughupdates/shaders/space_cape.vert new file mode 100644 index 00000000..2b5c48f8 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/space_cape.vert @@ -0,0 +1,12 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; + +void main() { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + + passColour = gl_Color; + passNormal = normalize(gl_Normal); +}
\ No newline at end of file |