Reusing the depth buffer from the scene rendering

When working on this:

I noticed that when calling scene.enableDepthRenderer() to get a depth texture for the scene, a specific (first) pass was done to create this texture (all the objects in the scene are reprocessed / drawn to generate the depth texture).

It makes sense it is a specific pass made first, as some material could use this texture in their shaders.

However, when needing this texture only in post process phases (like in the link above) when the scene has been fully rendered, we could use the depth buffer of the main scene itself instead of generating one: is it possible?

I understand we would have less control over the generated depth texture, notably we would always have non linear values in the depth texture, but we would avoid an additional scene render (not very costly because the shaders are simple, but still).

1 Like

unfortunately no. This is a big issue with webgl but we cannot reuse the main depth buffer

1 Like

Too bad!