From 336ca81adf8b22aab6aa4ee6c1d66fbff436ca8d Mon Sep 17 00:00:00 2001 From: Lea Date: Tue, 11 Jul 2023 16:17:25 +0200 Subject: [PATCH] messing around with the beacon shader --- .../shaders/core/rendertype_beacon_beam.fsh | 39 +++++++++++++++++++ .../shaders/core/rendertype_beacon_beam.json | 26 +++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 pack/assets/minecraft/shaders/core/rendertype_beacon_beam.fsh create mode 100644 pack/assets/minecraft/shaders/core/rendertype_beacon_beam.json diff --git a/pack/assets/minecraft/shaders/core/rendertype_beacon_beam.fsh b/pack/assets/minecraft/shaders/core/rendertype_beacon_beam.fsh new file mode 100644 index 0000000..ab794d6 --- /dev/null +++ b/pack/assets/minecraft/shaders/core/rendertype_beacon_beam.fsh @@ -0,0 +1,39 @@ +#version 150 + +#moj_import + +uniform sampler2D Sampler0; + +uniform mat4 ProjMat; +uniform vec4 ColorModulator; +uniform float FogStart; +uniform float FogEnd; +uniform vec4 FogColor; +uniform vec4 Pink; + +in vec4 vertexColor; +in vec2 texCoord0; + +out vec4 fragColor; + +void main() { + vec4 color = texture(Sampler0, texCoord0); + color *= vertexColor * ColorModulator; + float fragmentDistance = -ProjMat[3].z / ((gl_FragCoord.z) * -2.0 + 1.0 - ProjMat[2].z); + + float nuts = 0.0; + + /* this is an excuse for me to play around with shaders but i guess it also looks kinda cool */ + + if (fragmentDistance > 10) { + nuts = 1.0; + } else { + nuts = fragmentDistance / 10; + } + + nuts /= 3; + nuts += 0.25; + + color.rgb = mix(color.rgb, Pink.rgb, nuts); + fragColor = linear_fog(color, fragmentDistance, FogStart, FogEnd, FogColor); +} diff --git a/pack/assets/minecraft/shaders/core/rendertype_beacon_beam.json b/pack/assets/minecraft/shaders/core/rendertype_beacon_beam.json new file mode 100644 index 0000000..6e8155b --- /dev/null +++ b/pack/assets/minecraft/shaders/core/rendertype_beacon_beam.json @@ -0,0 +1,26 @@ +{ + "blend": { + "func": "add", + "srcrgb": "srcalpha", + "dstrgb": "1-srcalpha" + }, + "vertex": "rendertype_beacon_beam", + "fragment": "rendertype_beacon_beam", + "attributes": [ + "Position", + "Color", + "UV0" + ], + "samplers": [ + { "name": "Sampler0" } + ], + "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": "Pink", "type": "float", "count": 4, "values": [ 0.957, 0.722, 0.859, 1 ] } + ] +}