-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Enable geometry fade/transparency in the Mobile renderer #91672
base: master
Are you sure you want to change the base?
Conversation
To address your open questions, there is no need to port over the shader variants from the Forward+ renderer for this. As they are needed for features which are only present in the Forward+ renderer. That being said, there is no reason for us to double our pipeline count, we already have a pipeline with transparency enabled, so we should be using that instead of creating a new permutation. Adding unnecessary pipelines leads to pipeline compilation stutters and once #90400 is merged, it will double the load time for shaders. So this PR should be adapted to just use the existing transparent pipeline instead of create a new permutation |
@clayjohn Thanks for taking a look. But I think you might have misunderstood some of my points. I didn't want to over-explain the reasoning in the summary, but to provide some more context:
Yes, I believe this PR's implementation only creates new pipelines if there is geometry alpha applied while using an opaque material. The same shader is used in both and isn't recompiled. For this feature to work, the scene shader needs to account for an opaque material/shader and a non-opaque So this isn't "doubling" the pipeline count except in the notion of
I agree. I was probably a bit too oblique -- I was referring more to code structure than function. The original Forward+-only implementation of this geometry alpha feature in c571e4a also added the notion of selecting a pipeline based on material and instance flags. I tried to follow in spirit for Mobile. But that pipeline mapping logic was originally bundled with a significant refactoring ( I can tell that the Forward+ + Mobile renderers/scene shaders came from a common source and are still mostly similar. But this PR doesn't keep that similarity when it could. Specifically, for Mobile, I added Though I can see how one could move closer with appropriate simplifications. But it seems it would add unnecessary risk in this PR from a rando like me. So my question is -- did I make an appropriately simple choice? Or is it too simple? Do other contributors have opinions about the way I implemented this? Or know of similar efforts doing it the "hard" way? Or am I overthinking this? :)
Thanks for reminding me about this one. From looking at the changes made in common classes it and this PR, it seems it will introduce That said, while I believe with this PR there's still only one shader build per material, but I'm unsure how to confirm the number of shader compilations from the GUI (is there a monitor/profiler or debug verbose flag I can look out for)? |
Why close? |
Oops! Sorry about that. |
@eswartz Could you look into rebasing this PR on
#90400 adds performance monitors to track shader compilations over time. |
This is mostly a copy-paste of similar changes in the Forward+ renderer, as hinted in godotengine#76774 (comment) and godotengine#87231 (review), along with a tweak to the shader and pipeline model. The shader pipeline tweak involves distinguishing geometry instance-enabled transparency from material-enabled transparency. A material cannot support transparency on a per-instance level; a separate pipeline must be used when rendering. Originally in c571e4a this was a non-trivial refactoring in Forward+ (which in the past few years has evolved a few more times to account for the multitude of combinations allowed there). I opted to follow a similar sentiment to `SceneShaderForwardClustered::PipelineColorPassFlags` in a simpler `SceneShaderForwardMobile::PipelinePasses` enum, which only accounts for don't-care or opaque pipelines vs. color transparency-enabled ones. This multiplies the number of `PipelineCacheRD`s by two, but otherwise accomplishes the goals without adding unnecessary changes or shooting myself or others in the foot (I hope). BTW I also reorganized and removed some redundant checks in `RenderForwardClustered::_geometry_instance_add_surface_with_material` (since I was comparing this side-by-side with the `RenderForwardMobile` version, which seems better-organized). There is no functional change since `has_alpha` is the only variable used and includes all the checks anyway.
7574756
to
7479368
Compare
Resolves (partially) #76774 (for Mobile).
This is mostly a copy-paste of similar changes in the Forward+ renderer, as hinted in #76774 (comment) and #87231 (review), along with a tweak to the shader and pipeline model.
The shader pipeline tweak involves distinguishing geometry instance-enabled transparency from material-enabled transparency. A material cannot support transparency on a per-instance level; a separate pipeline must be used when rendering. Originally in c571e4a this was solved along with a non-trivial refactoring to the shader and pipeline model in Forward+, which in the past few years has evolved a few more times to account for the multitude of combinations allowed there.
I opted to follow a simpler but similar sentiment to
SceneShaderForwardClustered::PipelineColorPassFlags
in a simplerSceneShaderForwardMobile::PipelinePasses
enum, which only accounts for don't-care or opaque pipelines vs. color transparency-enabled ones. This multiplies the number ofPipelineCacheRD
s by two, but otherwise accomplishes the goals without adding unnecessary changes or shooting myself or others in the foot (I hope).BTW I also reorganized and removed some redundant checks in
RenderForwardClustered::_geometry_instance_add_surface_with_material
(since I was comparing this side-by-side with theRenderForwardMobile
version, which seems better-organized). All the checks result in the same behavior anyway.Test project:
fade-test.zip
Compatibility still shows warnings as expected:
Open issues:
If there are strong opinions, I can try to adapt some of the Forward+ ideas in favor of code similarly, though I would need pointers to know how to test all the combinations. (Is there some grand unified shader pipeline test project somewhere?)
I don't have equipment to test the impact on multiview, though I don't think it should be affected, since color, shadows, depth, and lightmap seem to work as expected. cc @BastiaanOlij
Note there is a missing shadow in all the screenshots, unrelated to my changes. I filed Visibility Range "Fade Self" option hides shadows unexpectedly in Depth Pre-Pass #91671 for that.