diff --git a/shader/sky/fog.frag b/shader/sky/fog.frag index cc2677883..a45392e85 100644 --- a/shader/sky/fog.frag +++ b/shader/sky/fog.frag @@ -51,6 +51,10 @@ layout(binding = 4) uniform utexture3D pageTbl; layout(binding = 5) uniform texture2D pageData; #endif +const float dFogMin = 0; +//const float dFogMax = 1; +const float dFogMax = 0.9999; + #if defined(GL_COMPUTE_SHADER) uvec2 invocationID = gl_GlobalInvocationID.xy; #endif @@ -175,10 +179,8 @@ vec4 fog(vec2 uv, float z) { const int steps = 32; const float noise = interleavedGradientNoise()/steps; - const float dMin = 0; - const float dMax = 0.9999; - const vec3 pos0 = project(scene.viewProjectLwcInv, vec3(inPos,dMin)); - const vec3 pos1 = project(scene.viewProjectLwcInv, vec3(inPos,dMax)); + const vec3 pos0 = project(scene.viewProjectLwcInv, vec3(inPos,dFogMin)); + const vec3 pos1 = project(scene.viewProjectLwcInv, vec3(inPos,dFogMax)); const vec3 posz = project(scene.viewProjectLwcInv, vec3(inPos,z)); #if defined(VIRTUAL_SHADOW) || defined(VIRTUAL_SHADOW_MARK) @@ -262,11 +264,9 @@ const vec3 debugColors[MAX_DEBUG_COLORS] = { }; vec4 fog(vec2 uv, float z) { - float dMin = 0; - float dMax = 0.9999; - float dZ = linearDepth( z, scene.clipInfo); - float d0 = linearDepth(dMin, scene.clipInfo); - float d1 = linearDepth(dMax, scene.clipInfo); + float dZ = linearDepth( z, scene.clipInfo); + float d0 = linearDepth(dFogMin, scene.clipInfo); + float d1 = linearDepth(dFogMax, scene.clipInfo); float d = (dZ-d0)/(d1-d0); // return vec4(debugColors[min(int(d*textureSize(fogLut,0).z), textureSize(fogLut,0).z-1)%MAX_DEBUG_COLORS], 0); return textureLod(fogLut, vec3(uv,d), 0); diff --git a/shader/virtual_shadow/vsm_common.glsl b/shader/virtual_shadow/vsm_common.glsl index 2ec1216ec..f5bfb8245 100644 --- a/shader/virtual_shadow/vsm_common.glsl +++ b/shader/virtual_shadow/vsm_common.glsl @@ -64,15 +64,19 @@ bool vsmPageClip(ivec2 fragCoord, const uint page) { } int vsmCalcMipIndex(in vec2 shPos) { +#if 1 + float d = max(abs(shPos.x), abs(shPos.y)); + uint id = uint(d); + return findMSB(id)+1; +#else float x = ceil(log2(max(abs(shPos.x), 1))); float y = ceil(log2(max(abs(shPos.y), 1))); return int(max(x,y)); +#endif } int vsmCalcMipIndex(in vec2 shPos, int minMip) { - float x = ceil(log2(max(abs(shPos.x), 1))); - float y = ceil(log2(max(abs(shPos.y), 1))); - return max(minMip, int(max(x,y))); + return max(vsmCalcMipIndex(shPos), minMip); } uint pageIdHash7(ivec3 src) {