Use native depth clip control instead of manual DEPTH_CLAMP_ORTHO where possible #16078
Labels
A-Rendering
Drawing game state to the screen
C-Feature
A new feature, making something new possible
C-Performance
A change motivated by improving speed, memory usage or compile times
D-Shaders
This code uses GPU shader languages
D-Straightforward
Simple bug fixes and API improvements, docs, test and examples
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
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 thez
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
The text was updated successfully, but these errors were encountered: