I noticed that HDRP, ShaderGraph and VFXGraph all support/generate ZClip render state attribute in their shader files.
The advantage of ZClip during shadowcaster pass seems to be to clip by fragment, rather than using traditional Shadow Pancaking which deforms vertices and can produce bad shadow with large triangles. (Shadow Pancaking: Unity - Manual: Shadow troubleshooting)
Shadow Pancaking is currently used in builtin RP and URP for all light types.
In HDRP, there is no shadow pancaking, and ZClip Off is only used for directional shadows. Other light types can show shadow clipping.
Why is ZClip not disabled on other light types in HDRP?
Is there any plan to add ZClip to URP, to be consistent with the rest of SRP?
Is there any performance implication to using ZClip instead of pancaking?
I suppose ZClip is not supported on every platform, hence why pancaking is used in URP?
Yes, it is a known issue and that is on the roadmap for shadow improvements.
Can you provide any more details about the issues you are facing? This will help us prioritize this request
I don’t think there isn’t so much of a performance implication, but a precision implication. The problem with shadow pancaking is that it distorts geometry and having zclip disabled, severely hurts precision.
You are correct. Part of that work is to introduce API to query whether it is supported, and the query is supported on all platforms.
Well apart from the inherent problem of pancaking, not really.
I have a very different shadow implementation in URP (all bias handled in pixel shader during shading, no fancy bias and no pancaking in shadowcaster vertex shader) and I didn’t implement ZClip initially, leading to artifacts in directional shadowmap generation.
Oh I hadn’t thought of that but that makes sense. Good to know.
Hi,did you konw why URP remove the positionCS.w in ShadowCasterPass.hlsl?
It usually be positionCS.w * UNITY_NEAR_CLIP_VALUE ,I found this Commit which actually removed the positionCS.w,but I can’t figure out,look forward to your reply,thank you