Explorar el Código

Improve ShadowMesh.js and Prevent Shadow Overlap (#24180)

A simple use of the stencil buffer can prevent ugly artifacts caused by the planar projected shadow of the geometry overlapping with itself.
n8programs hace 3 años
padre
commit
ca5f97ccf3
Se han modificado 1 ficheros con 8 adiciones y 2 borrados
  1. 8 2
      examples/jsm/objects/ShadowMesh.js

+ 8 - 2
examples/jsm/objects/ShadowMesh.js

@@ -1,7 +1,9 @@
 import {
 	Matrix4,
 	Mesh,
-	MeshBasicMaterial
+	MeshBasicMaterial,
+	EqualStencilFunc,
+	IncrementStencilOp
 } from 'three';
 
 /**
@@ -19,7 +21,11 @@ class ShadowMesh extends Mesh {
 			color: 0x000000,
 			transparent: true,
 			opacity: 0.6,
-			depthWrite: false
+			depthWrite: false,
+			stencilWrite: true,
+            		stencilFunc: EqualStencilFunc,
+            		stencilRef: 0,
+            		stencilZPass: IncrementStencilOp
 
 		} );