feat(rendering): add fog-distance darkness to chunk shaders
This commit is contained in:
@@ -1,13 +1,20 @@
|
|||||||
#version 330 core
|
#version 330 core
|
||||||
in vec2 vUv;
|
in vec2 vUv;
|
||||||
in float vShade;
|
in float vShade;
|
||||||
|
in float vWorldY;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
uniform sampler2D atlas;
|
uniform sampler2D atlas;
|
||||||
|
uniform float u_caveDarkStartY;
|
||||||
|
uniform float u_caveDarkEndY;
|
||||||
|
uniform float u_caveMinBrightness;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 texel = texture(atlas, vUv);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ layout(location = 2) in float aShade;
|
|||||||
|
|
||||||
out vec2 vUv;
|
out vec2 vUv;
|
||||||
out float vShade;
|
out float vShade;
|
||||||
|
out float vWorldY;
|
||||||
|
|
||||||
uniform mat4 model;
|
uniform mat4 model;
|
||||||
uniform mat4 view;
|
uniform mat4 view;
|
||||||
@@ -14,6 +15,8 @@ void main()
|
|||||||
{
|
{
|
||||||
vUv = aUv;
|
vUv = aUv;
|
||||||
vShade = aShade;
|
vShade = aShade;
|
||||||
// Vector-on-left convention; matrices are uploaded with transpose=true.
|
// World-space position uses row-vector convention (matches gl_Position below).
|
||||||
gl_Position = vec4(aPos, 1.0) * model * view * projection;
|
vec4 worldPos = vec4(aPos, 1.0) * model;
|
||||||
|
vWorldY = worldPos.y;
|
||||||
|
gl_Position = worldPos * view * projection;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user