DepthCompositing
DepthCompositing copied to clipboard
Depth compositing broken in Unity 5.5
This project was unfortunately broken by Unity 5.5, and depth compositing is no longer working as intended. The background simply draws over the top of realtime objects.
It was last functioning without issue in Unity 5.4.
ChristmasGT on the Shader Forge forums found the cause, and shared this one-line fix.
Cause: Shaders: Z-buffer float inverted
Fix: Depth_Write.shader
Find Line 54: clipSpace.z = 0.5*(clipSpace.z+1.0);
Change it to: clipSpace.z = 0.5*(1.0-clipSpace.z);
I've tested, and this fix works for Unity 5.5 and Unity 5.6.
Thanks for the solution. Here is one that is more robust:
#if defined(UNITY_REVERSED_Z)
clipSpace.z = 0.5 * (1.0 - clipSpace.z);
#else
clipSpace.z = 0.5 * (clipSpace.z + 1.0);
#endif
Is this step equal to Linear01Step?