“Depth texture itself is not generated using shader replacement anymore; it is rendered with ShadowCaster shader passes. This means that as long as your objects can cast proper shadows, then they will also appear in camera’s depth texture properly (was very hard to do before, if you wanted custom vertex animation or funky alpha testing). It also means that Camera-DepthTexture.shader is not used for anything now. And also, all built-in shadow shaders used no backface culling; that was changed to match culling mode of regular rendering.”
Does this mean vertex shader animated objects need to cast shadows in order to get an up-to-date CameraDepthTexture or am I misinterpreting something?
Here’s an example of what I do:
Some weed is vertex animated, intersecting a _CameraDepthTexture shader for debug purposes. Sadly the depth value doesn’t get updated.
Could anyone give me a hint on that?
Thanks in advance
I posted a question along similar lines as I feel it needs a little more clarification —
Regards what’s mentioned in the documentation, instead of using the depth replacement shader to render objects into the depth texture previously, you need to add an additional ShadowCaster subshader to the shader your object is using. You can grab a basic ShadowCaster pass from the built in VertexLit shader code. Then you’ll need to add the same vertex animation from your shader into the ShadowCaster’s vertex program.
A few notes:
I’ve noticed that I needed to add the ShadowCaster pass inside an extra subshader instead of just adding the pass to the existing shaders subshader.
I’ve also noticed that in some instances (mainly for forward rendered objects on a deferred setup) I need to add the passes to the _CameraDepthNormal replacement shader, which still gets used.