Add support for vanilla enviromental fog

This commit is contained in:
mcrcortex
2025-06-23 00:51:54 +10:00
parent cf60d31b75
commit 7fa07ae5ea
12 changed files with 70 additions and 18 deletions

View File

@@ -19,6 +19,9 @@
"voxy.config.general.renderDistance": "Render distance",
"voxy.config.general.renderDistance.tooltip": "Render distance of voxy in chunks",
"voxy.config.general.environmental_fog": "Enable environmental fog",
"voxy.config.general.environmental_fog.tooltip": "Enables or disables voxy rendering environmental fog",
"voxy.config.general.vanilla_fog": "Enable vanilla fog",
"voxy.config.general.vanilla_fog.tooltip": "Enables or disables vanilla fog effect",

View File

@@ -4,6 +4,10 @@ layout(binding = 0) uniform sampler2D colourTex;
layout(binding = 1) uniform sampler2D depthTex;
layout(location = 2) uniform mat4 invProjMat;
layout(location = 3) uniform mat4 projMat;
#ifdef USE_ENV_FOG
layout(location = 4) uniform vec3 endParams;
layout(location = 5) uniform vec3 fogColour;
#endif
out vec4 colour;
in vec2 UV;
@@ -28,7 +32,16 @@ void main() {
discard;
}
depth = projDepth(rev3d(vec3(UV.xy, depth)));
vec3 point = rev3d(vec3(UV.xy, depth));
#ifdef USE_ENV_FOG
{
float fogLerp = max(fma(min(length(point.xyz), endParams.x),endParams.y,endParams.z),0);//512 is 32*16 which is the render distance in blocks
colour.rgb = mix(colour.rgb, fogColour, fogLerp);
}
#endif
depth = projDepth(point);
depth = min(1.0f-(2.0f/((1<<24)-1)), depth);
depth = depth * 0.5f + 0.5f;
depth = gl_DepthRange.diff * depth + gl_DepthRange.near;