-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Use native depth clip control instead of manual DEPTH_CLAMP_ORTHO where possible #16078
Description
What problem does this solve or what need does it fill?
The DEPTH_CLAMP_ORTHO stuff we have for directional light shadow mapping uses a fragment shader. Having the fragment shader disables some really important hardware optimizations that exist for depth-only vertex-only passes.
What solution would you like?
For non-alpha masked draws, on supported platforms, use https://docs.rs/wgpu/latest/wgpu/struct.PrimitiveState.html#structfield.unclipped_depth instead of setting the DEPTH_CLAMP_ORTHO shader def.
Additionally when we do use DEPTH_CLAMP_ORTHO, we should not pass the entire clip_position_unclamped: vec4<f32> from the vertex shader to the fragment shader, we only need to pass the z value.
What alternative(s) have you considered?
We could remove DEPTH_CLAMP_ORTHO entirely, and instead expand the shadow view frustum either by some fixed amount, or based on the AABB's of entities in the scene.
Additional context
#8877
https://therealmjp.github.io/posts/shadow-maps/#disabling-z-clipping
Metadata
Metadata
Assignees
Labels
Type
Projects
Status