Browse Source

Merge pull request #17211 from higharc/shadowmap-offbyone-fix

Fix off-by-one error in computing shadow map texture coordinates
Mr.doob 6 years ago
parent
commit
0e0ab563dc
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js

+ 1 - 1
src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js

@@ -41,7 +41,7 @@ export default /* glsl */`
 		const vec2 offset = vec2( 0.0, 1.0 );
 
 		vec2 texelSize = vec2( 1.0 ) / size;
-		vec2 centroidUV = floor( uv * size + 0.5 ) / size;
+		vec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;
 
 		float lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );
 		float lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );