pmndrs / postprocessing

A post processing library for three.js.
zlib License
2.37k stars 213 forks source link

Renderer's autoClear never set back to true, causing unexpected behavior in custom Shadow Map. #621

Closed MikeFernandez-Pro closed 7 months ago

MikeFernandez-Pro commented 7 months ago

While implementing the shadow mapping example by Mofu on threejs: Mofu Shadow Mapping

I attempted to integrate the Effect Composer from pmnds/postprocessing and noticed that after its implementation, the casted shadows were no longer cleared on each frame.

Upon comparing it with the Three.js postprocessing implementation, I noticed that in this Effect Composer implementation the autoClear value of the renderer was set to false without ever setting it back to true (its default value).

I believe this is intentional, but if not, I was able to resolve the issue by resetting the autoClear value of the renderer to true immediately after creating my Effect Composer.

https://github.com/pmndrs/postprocessing/blob/0653ce4e10a46cc51b045acc29e5637856f281a8/src/core/EffectComposer.js#L231

vanruesc commented 7 months ago

the autoClear value of the renderer was set to false without ever setting it back to true

That's the intended behaviour. Auto clear should be off for all postprocessing passes to avoid unnecessary clear calls.

If you need to clear specific render targets for custom shadow mapping, consider using renderer.clear() explicitly after setting the render target.

vanruesc commented 7 months ago

Closing as resolved.

MikeFernandez-Pro commented 7 months ago

Thank you very much for your explanation Vanruesc, it worked perfectly using renderer.clear()