浏览代码

Fix shadow artifacts in example by subdividing ground plane

Without the subdivision some artifacts were visible in the test with certain camera angles. The artifacts reproduced on NVIDIA GeForce GTX 10xx series GPUs, presumably due to lack of varying interpolation precision.
Olli Etuaho 6 年之前
父节点
当前提交
24637fde38
共有 1 个文件被更改,包括 10 次插入3 次删除
  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 );