-
-
Notifications
You must be signed in to change notification settings - Fork 977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds "Write Depth" option to blend and additive material features #2634
base: master
Are you sure you want to change the base?
Adds "Write Depth" option to blend and additive material features #2634
Conversation
(cherry picked from commit 6bbfb45ca6798354bee4521ecc116d98c021cc4c)
Marginal overhead aside, wouldn't this make more difficult to have custom materials that depend on the depth value? Like, for example, soft particles, or depth-color water, or stencil-based outlines, or effects of that kind? Or are those things better suited for custom render features? Forgive me if I'm not seeing the full picture. |
I don't think it's allowed to bind the depth as input while also having it bound as the active render target. |
The functionality of "Bind Depth As Resource During Transparent Rendering" remains the same, with a copy of the depth buffer generated regardless of the boolean's state. What I have removed is the following: Before my PR, when this boolean was enabled, the depth buffer was copied into a read-only texture and bound like that to the pipeline. It now simply stays bound.
The copy is done here:
@johang88 do you think there could be a case where |
Yes, on my GPU it will never return a copy as |
To clarify (please correct me if I'm wrong, as I've not tried to touch that part of the renderer yet):
Is it somethink like that? WRT to the My original concern persists, however. Transparent shaders with depth writes can, in any case, read only the opaque depth information, isn't it? Sorry if I'm talking nonsense. I've yet to study your changes and this part of |
It's correct that transparent shaders can only every read from the depth written in the opaque pass. With this change a copy must always be made as the depth buffer is always bound as a read/write render target, if a copy is not made then it the depth buffer will not be able to be bound as texture for reading in the transparent stage shaders. Note that the actual behaviour of this might be driver dependant as I am unsure if it's undefined behaviour or not. But I did check it myself in renderdoc and at least on my system the texture does not get bound properly without forcing a copy to be made. I also noticed that |
@johang88 thanks for your thoughts and investigation on the texture behavior. @Ethereal77 I'll review the code with the new information and will try to clarify the before/after behavior when I'm done. Really helpful, thanks! |
PR Details
This PR introduces a new "Write Depth" option to the blend and additive material features.
Additionally, I disabled the read-only depth buffer bind when "Bind Depth As Resource During Transparent Rendering" is enabled. This change is necessary to allow materials in the transparent rendering stage to write to the depth buffer. While this might introduce a marginal performance overhead, I expect that the shader recognizes when depth writing is disabled on the material and optimizes accordingly, keeping the same performance as before. Feedback is welcome if anyone has further insights or corrections regarding this assumption.
Related Issue
User request in vvvv to enable more design possibilities.
Types of changes
Checklist
Screenshot
The following screenshot demonstrates the "Write Depth" feature in action. A transparent sphere interacts with the teapot's geometry, showing the new depth behavior:
Here as it was before, which is also the default: