Browse Source

Merge pull request #17179 from higharc/shadowmap-interpolation-bug

Fix shadow artifacts in example by subdividing ground plane
Mr.doob 6 years ago
parent
commit
ecb116f6af
1 changed files with 10 additions and 3 deletions
  1. 10 3
      examples/webgl_shadowmap_pcss.html

+ 10 - 3
examples/webgl_shadowmap_pcss.html

@@ -143,8 +143,15 @@
 				// camera
 
 				camera = new THREE.PerspectiveCamera( 30, window.innerWidth / window.innerHeight, 1, 10000 );
-				camera.position.y = 5;
-				camera.position.z = 15;
+
+				// We use this particular camera position in order to expose a bug that can sometimes happen presumably
+				// due to lack of precision when interpolating values over really large triangles.
+				// It reproduced on at least NVIDIA GTX 1080 and GTX 1050 Ti GPUs when the ground plane was not
+				// subdivided into segments.
+				camera.position.x = 7;
+				camera.position.y = 13;
+				camera.position.z = 7;
+
 				scene.add( camera );
 
 				// lights
@@ -191,7 +198,7 @@
 
 				var groundMaterial = new THREE.MeshPhongMaterial( { color: 0x404040, specular: 0x111111 } );
 
-				var mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 20000, 20000 ), groundMaterial );
+				var mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 20000, 20000, 8, 8 ), groundMaterial );
 				mesh.rotation.x = - Math.PI / 2;
 				mesh.receiveShadow = true;
 				scene.add( mesh );