diff --git a/shaders/dimensions/DH_generic.fsh b/shaders/dimensions/DH_generic.fsh index 1fbca36..4a64ea8 100644 --- a/shaders/dimensions/DH_generic.fsh +++ b/shaders/dimensions/DH_generic.fsh @@ -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); } diff --git a/shaders/dimensions/DH_solid.fsh b/shaders/dimensions/DH_solid.fsh index f3001ed..2fa7a07 100644 --- a/shaders/dimensions/DH_solid.fsh +++ b/shaders/dimensions/DH_solid.fsh @@ -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; } diff --git a/shaders/dimensions/DH_translucent.fsh b/shaders/dimensions/DH_translucent.fsh index 52d4d4f..a5481d8 100644 --- a/shaders/dimensions/DH_translucent.fsh +++ b/shaders/dimensions/DH_translucent.fsh @@ -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 diff --git a/shaders/shaders.properties b/shaders/shaders.properties index ce40a78..68f9bc8 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -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 ####### ###############################