-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Always set PREPASS_FRAGMENT when frag shader being used in prepass. #21106
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
base: main
Are you sure you want to change the base?
Conversation
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
1 similar comment
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
The prepass shaders I've been using have notably not been writing to depth in the shader, so I'm not sure this is a bug but rather a complex set of conditions that could use some additional documentation. Specifically: What I seem to be running into is that The shadows pipeline additionally uses the prepasspipeline unmodified, which doesn't set the So you need two branches in a prepass shader, one for potentially writing normal/motion/deferred/unclipped data, if any are defined to be used, and one for shadows. Shadows also differs in that it doesn't have a FragmentOutput on the entrypoint (and FragmentOutput won't even exist as a type). This is additionally complicated through AlphaMode choice.
So PREPASS_FRAGMENT does seem like a poor name, since it doesn't control whether the fragment shader is running, but rather controls whether any of the aforementioned outputs could be enabled. and is additionally being used to "force" the fragment shader to run, according to some comments in the source code. Overall this seems like a bit of a documentation issue more than a bug, but might also benefit from some renaming/refactoring. |
// is enabled, the material uses alpha cutoff values and doesn't rely on the standard | ||
// prepass shader, or we are emulating unclipped depth in the fragment shader. | ||
let fragment_required = !targets.is_empty() | ||
// PERF: This line forces the "prepass fragment shader" to always run in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't that be above the line that pushes the shader def?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the issue and where it was located before, this is relevant to unclipped depth rather than the shader def being pushed generally, which is why I moved it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the location of the perf comment but other than that LGTM
I like this approach better I think.
|
Interestingly, this does change rendering output as seen from pixel eagle. I'm not sure which is correct or what the concrete difference is on the helmet example. We should investigate further. |
yeah, with the knowledge that This PR will enable the meshlet fragment prepass:
and will require a small refactor in bevy_pbr/src/render/pbr_prepass.wgsl, since the branch would be removed: bevy/crates/bevy_pbr/src/render/pbr_prepass.wgsl Lines 23 to 151 in 4b138af
|
Okay, yup, this could be responsible for the change in the helmet output. Will double check. |
Actually structs can't be empty, so I think the branch is required? This is from
|
@ChristopherBiscardi was running into an issue where
PREPASS_FRAGMENT
was not being set when using a prepass fragment shader that only writes to depth. Previously, we were setting thePREPASS_FRAGMENT
shader def when there are targets oremulate_unclipped_depth
is true, but not when using a material with alpha masking. Instead, we should set the shader def unconditionally when using a fragment shader in the prepass.