Only disable depth writing in opaque pipelines #71124
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow up to #70214 and #70884
Fixes: #71249
While working on something else I noticed that there was a regression in master that caused objects with visibility fade alpha to not display unless the visibility was set to 0.0 and the fade was at fully opaque. If any alpha was introduced the object would disappear.
The issue was caused by the depth-prepass optimization added in #70214 which makes it so that objects only draw where their depth matches the depth-prepass depth and it disables writing to the depth during the draw pass. This optimization hugely reduces the cost of drawing opaque geometry. However, it was tricky to apply to the transparent pass. In the end with #70884 we restricted the optimization to just objects that we know will get sent down the opaque pipeline (opaque objects transparent objects with alpha scissor or alpha hash). Even with the restriction we were needlessly applying the optimizations to both the opaque pipeline and the transparent pipeline (if a material passed our checks the object using our material should be sent down the opaque pipeline, not the transparent pipeline, so there is no reason to apply the optimization to the transparent pipeline).
Visibility fade introduces a case where an otherwise opaque object may get sent down the transparent pipeline. In which case, we need the transparent pipeline version to be compiled and ready to be used (i.e. without the optimization). In the end, I realized that we never need to add the optimization to the transparent pipeline as the rendering logic checks for alpha scissor etc. and sends those materials down the opaque pipeline anyway.
before:
after:
CC @Ansraer