feat(rendering): add fog-distance darkness to chunk shaders

This commit is contained in:
2026-06-01 15:46:33 +02:00
parent 2e36d40386
commit aa1aa6fec6
2 changed files with 13 additions and 3 deletions

View File

@@ -1,13 +1,20 @@
#version 330 core
in vec2 vUv;
in float vShade;
in float vWorldY;
out vec4 FragColor;
uniform sampler2D atlas;
uniform float u_caveDarkStartY;
uniform float u_caveDarkEndY;
uniform float u_caveMinBrightness;
void main()
{
vec4 texel = texture(atlas, vUv);
FragColor = vec4(texel.rgb * vShade, 1.0);
float t = clamp((u_caveDarkStartY - vWorldY) /
(u_caveDarkStartY - u_caveDarkEndY), 0.0, 1.0);
float brightness = mix(1.0, u_caveMinBrightness, t);
FragColor = vec4(texel.rgb * vShade * brightness, 1.0);
}

View File

@@ -5,6 +5,7 @@ layout(location = 2) in float aShade;
out vec2 vUv;
out float vShade;
out float vWorldY;
uniform mat4 model;
uniform mat4 view;
@@ -14,6 +15,8 @@ void main()
{
vUv = aUv;
vShade = aShade;
// Vector-on-left convention; matrices are uploaded with transpose=true.
gl_Position = vec4(aPos, 1.0) * model * view * projection;
// World-space position uses row-vector convention (matches gl_Position below).
vec4 worldPos = vec4(aPos, 1.0) * model;
vWorldY = worldPos.y;
gl_Position = worldPos * view * projection;
}