make overdraw prevention radius shrink as you move quicker (thanks for the idea, James). fix water depthcheck when overdraw prevention was disabled

This commit is contained in:
Xonk
2026-04-18 20:10:19 -04:00
parent 60e106f3e6
commit a4b8809de4
4 changed files with 29 additions and 7 deletions
+8 -5
View File
@@ -12,6 +12,7 @@ uniform sampler2D depthtex1;
uniform mat4 gbufferModelViewInverse;
uniform float far;
uniform int frameCounter;
uniform vec3 OVERDRAW_PREVENTION_SCALE;
vec3 toLinear(vec3 sRGB){
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
@@ -40,12 +41,14 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
#else
float maxOverdrawDistance = OVERDRAW_MAX_DISTANCE;
#endif
float velocity = clamp(1.0 - length(OVERDRAW_PREVENTION_SCALE),1e-6,1.0);
if(length(playerPos) < clamp(far-16*4, 16, maxOverdrawDistance)*velocity || texture(depthtex1, gl_FragCoord.xy*texelSize).x < 1.0){ discard; return;}
#else
if(texture(depthtex1, gl_FragCoord.xy*texelSize).x < 1.0){ discard; return;}
#endif
if(length(playerPos) < clamp(far-16*4, 16, maxOverdrawDistance) || texture(depthtex1, gl_FragCoord.xy*texelSize).x < 1.0){ discard; return;}
#endif
vec3 Albedo = toLinear(gcolor.rgb) ;
vec3 Albedo = toLinear(gcolor.rgb);
gl_FragData[0] = vec4(Albedo * Emissive_Brightness * 0.1, gcolor.a);
}
+5 -1
View File
@@ -18,6 +18,8 @@ uniform float nightVision;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
uniform vec3 OVERDRAW_PREVENTION_SCALE;
vec3 viewToWorld(vec3 viewPosition) {
vec4 pos;
pos.xyz = viewPosition;
@@ -166,7 +168,9 @@ void main() {
float maxOverdrawDistance = OVERDRAW_MAX_DISTANCE;
#endif
if(clamp(1.0-length(localPos.xyz)/clamp(far - 32.0,32.0,maxOverdrawDistance),0.0,1.0) > 0.0 ){
float velocity = clamp(1.0 - length(OVERDRAW_PREVENTION_SCALE),1e-6,1.0);
if(clamp(1.0-length(localPos.xyz)/(clamp(far - 32.0,32.0,maxOverdrawDistance)*velocity),0.0,1.0) > 0.0 ){
discard;
return;
}
+8 -1
View File
@@ -72,6 +72,7 @@ flat varying vec4 lightCol;
flat varying vec3 WsunVec;
flat varying vec3 WsunVec2;
uniform vec3 OVERDRAW_PREVENTION_SCALE;
// uniform mat4 dhPreviousProjection;
@@ -433,12 +434,18 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
// gl_FragData[0].rgb = normals*0.1;
#ifdef DH_OVERDRAW_PREVENTION
float distancefade = min(max(1.0 - length(playerPos)/clamp(far-16*4, 16, maxOverdrawDistance),0.0)*5,1.0);
float velocity = clamp(1.0 - length(OVERDRAW_PREVENTION_SCALE),1e-6,1.0);
float distancefade = min(max(1.0 - length(playerPos)/(clamp(far-16*4, 16, maxOverdrawDistance)*velocity),0.0)*5,1.0);
if(texture(depthtex0, gl_FragCoord.xy*texelSize).x < 1.0 || distancefade > 0.0){
gl_FragData[0].a = 0.0;
material = 0.0;
}
#else
if(texture(depthtex0, gl_FragCoord.xy*texelSize).x < 1.0){
gl_FragData[0].a = 0.0;
material = 0.0;
}
#endif
#if DEBUG_VIEW == debug_DH_WATER_BLENDING
+8
View File
@@ -766,6 +766,14 @@ uniform.float.shadowMaxProj = 150.0/abs(sunPosY)
uniform.int.LOD_RENDERDISTANCE = vxRenderDistance * 16
#endif
#ifdef DISTANT_HORIZONS
# retract the radius of overdraw prevention as you move quicker to hide the hole.
variable.float.smoothVelocity_X = smooth(abs(previousCameraPosition.x-cameraPosition.x),0.5,5.0)
variable.float.smoothVelocity_Y = smooth(abs(previousCameraPosition.y-cameraPosition.y),0.5,5.0)
variable.float.smoothVelocity_Z = smooth(abs(previousCameraPosition.z-cameraPosition.z),0.5,5.0)
uniform.vec3.OVERDRAW_PREVENTION_SCALE = vec3(smoothVelocity_X,smoothVelocity_Y,smoothVelocity_Z)
#endif
###############################
####### FLOODFILL STUFF #######
###############################