Closed deenns closed 1 year ago
I'm confused why the additional setMask()
calls are required. They were originally not added in MaskPass
since it should be sufficient to just unlock color and depth buffer. WebGLState.setMaterial()
is called per render item and executes setMask()
for both color and depth buffer:
Meaning as long as the buffers are unlocked and depthWrite
and colorWrite
are set to true
, the WebGL commands gl.colorMask()
and gl.depthMask()
will be called with true
as well.
Wait, I think I understand now. Color and depth buffer can only be cleared if they are writable. setMask()
is potentially called to late which breaks the clear.
Currently there are the following lines of code in the MaskPass class
Both values are set to
false
, but these operations aren't reverted at the end of the pass.As the result, if after the scene is rendered you remove the scene background, it's not removed for transmissive objects. What's more, if there are non-transmissive parts in a transmissive model and it's being rotated, then the non-transmissive parts leave a trail on the background.
Some code
Probable solution
If the following code
is executed before
RenderPass
(e.g. at the end ofMaskPass
), then the problem disappears. For this very issue only the first line is enough.