Skip to content

Commit

Permalink
Improve ShadowMesh.js and Prevent Shadow Overlap (#24180)
Browse files Browse the repository at this point in the history
A simple use of the stencil buffer can prevent ugly artifacts caused by the planar projected shadow of the geometry overlapping with itself.
  • Loading branch information
N8python committed Jun 3, 2022
1 parent cba85c5 commit ca5f97c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/jsm/objects/ShadowMesh.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
Matrix4,
Mesh,
MeshBasicMaterial
MeshBasicMaterial,
EqualStencilFunc,
IncrementStencilOp
} from 'three';

/**
Expand All @@ -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

} );

Expand Down

0 comments on commit ca5f97c

Please sign in to comment.