Does post processing conflict with stencil test?

I’m currently implementing a shadow-like effect with shadow volumes. Code

The code runs well.

But if I add any post-process pass, like a gamma correction shader pass to it, the shadow volume, which depends on stencil test, gets broken.

What should I do to solve this problem?

Post-processing is applied only onto the final, rendered frame (ex. gamma correction pass kinda just iterates and adjusts colors of the pixels.) Passes shouldn’t affect the calculations in the scene.

Is the issue also happening with just an empty Composer and a RenderPass?

It works fine with just a RenderPass.

I think I found out why. :joy: @mjurczyk
The default renderTarget that EffectComposer uses turns off stencil buffer by default. So, you should create a render target which enables stencil buffer and pass it to the EffectComposer.

const renderTarget = new RenderTarget(width, height, {stencilBuffer:true});
const composer = new EffectComposer(renderer, renderTarget);

The reason why the code works with a single RenderPass is that the last pass, in this case, the render pass, is directly rendered to screen rather than the render target.