Open victorronnow opened 3 months ago
I'm trying to render 2 planes using stencils. Somehow the green plane is not masking the red plane properly when rendering with the EffectComposer and is causing to tearing around the mask, see the attached gifs:
Here's a stackblitz link: https://stackblitz.com/edit/vitejs-vite-6fxjcx
In the demo I'm using 2 planes:
A green plane
const geometry = new THREE.PlaneGeometry(1, 1, 1); const material = new THREE.MeshBasicMaterial({ color: 0x00ff00, }); material.depthWrite = false; material.stencilWrite = true; material.stencilRef = 1; material.stencilFunc = THREE.AlwaysStencilFunc; material.stencilZPass = THREE.ReplaceStencilOp; const mask = new THREE.Mesh(geometry, material);
A red plane getting masked by the green plane using THREE.EqualStencilFunc
THREE.EqualStencilFunc
const planeGeometry = new THREE.PlaneGeometry(1, 1, 1); const planeMaterial = new THREE.MeshBasicMaterial({ color: 'red', }); planeMaterial.stencilWrite = true; planeMaterial.stencilRef = 1; planeMaterial.stencilFunc = THREE.EqualStencilFunc; const plane = new THREE.Mesh(planeGeometry, planeMaterial);
Hi, I haven't used stencil ops with postprocessing before, but there's MaskPass and ClearMaskPass which might help.
I'm trying to render 2 planes using stencils. Somehow the green plane is not masking the red plane properly when rendering with the EffectComposer and is causing to tearing around the mask, see the attached gifs:
To reproduce
Here's a stackblitz link: https://stackblitz.com/edit/vitejs-vite-6fxjcx
In the demo I'm using 2 planes:
A green plane
A red plane getting masked by the green plane using
THREE.EqualStencilFunc
Library versions used
Desktop