EffectLayers don't use stencil buffer

It is sometimes desirable to use a stencil buffer with an EffectLayer, but this isn’t currently supported.

For example: Babylon.js Playground
In this demo, the post-process glow isn’t masked properly by the stencil settings since the underlying texture doesn’t have stenciling enabled.

This can be fixed by allowing EffectLayers to enable stenciling. Here is what that might look like:

I can create a PR for this if desired.

I do not think this would be compatible with highlightlayer as it relies on stencil internally ?

That may be true, I didn’t actually test nor have a use case for highlight layer, I just did the same changes as glow layer. I can remove that from my branch.

Yup I am glad to merge the PR as long as it stays as an option for glow layer only.

1 Like

:+1:

1 Like