I don’t want to render a depth pass for performance reason, but I need a depth texture to render some effects. Is there a way to generate a depth texture from the depth buffer filled in ForwardOpaque pass?
bgolus
January 12, 2017, 5:44pm
2
Aras’s response to that same question (from me) a few months ago:
thoughts.md
"Any thoughts on pulling a depth texture directly from a forward camera after opaque passes rather than using the pre pass?" (https://twitter.com/bgolus/status/747967191278989312)
Yeah, so there's several things that might complicate this:
1. Screenspace ("deferred") shadows. These need depth texture, but you want to receive shadows while rendering opaque objects.
So a depth pre-pass is the only option there. What we could do: remove (or make optional) the screenspace shadows; just directly
sample & blend shadow cascades inside the shader. Increases register pressure, but has quite some benefits too (MSAA "just works",
can do receiver plane bias, just works on transparencies etc.)
1. Various "not quite standard" cases, like splitscreen cameras or other types of cameras that don't render to the whole render target.
Probably not a common case though; if you have shadows & need depth, you likely also have postprocessing etc. So you're not rendering
This file has been truncated. show original
And this is the Scriptable Render Loop he mentions (requires 5.6 beta):
https://github.com/Unity-Technologies/ScriptableRenderLoop
Thank you for replying. I just looked at Roadmap , Scriptable Render Loop is under Research, so I can’t use it for my project.
bgolus
January 13, 2017, 1:31am
4
Yep, and 5.6 is still in (very early) Beta too. So, sadly, there’s no way to do what you want in the current version of Unity.