Transparency modes review - #333
Merged
Merged
Conversation
+ tweak passes
+ tweak passes
not sure about probes, let's leave blending enabled regardless for now; it avoids repeated state changes, provided we trust the consistency of the alpha and cutoff values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Transparency Modes
This PR revises the transparency modes, introducing three modes:
OPAQUE,HYBRID, andBLEND:The behavior is similar to the previous modes, but the internal logic is now clearer and more efficient.
The
HYBRIDmode first renders an opaque pass for fragments above the alpha cutoff, followed by a blended pass for fragments below the cutoff.It's also worth noting that the hybrid logic naturally works with unlit materials without requiring any additional logic. There isn't much practical benefit to using it for unlit materials though, so it's preferable to render them directly using
BLEND.Blend Modes
Blend modes are now only applied to
BLENDand to the below-cutoff portion ofHYBRID. Previously, there was a special case forADDITIVEwhen transparency wasDISABLED, which resulted in a different blend mode. This was somewhat unclear, so I introduced theADD_ALPHAblend mode and keptADDITIVEas a straightforwardONE, ONEblend.Complete enum with the new
ADD_ALPHA:Shader Usages
For shader
#pragma usage, theprepassmode has been removed, andtransparenthas been renamed toblendfor consistency withR3D_TransparencyMode.Alpha Cutoff
The default material alpha cutoff has also been changed from
0.01fto0.5f. This makes the behavior more natural in most cases and also matches the standard behavior expected for glTF models when no explicit alpha cutoff is defined.Internal Rendering Changes
I also made a few adjustments to the internal rendering-pass logic. These changes helped facilitate the new transparency system and will also serve as preliminary groundwork for the future scene/context architecture and transparent background support.