Add shader defines for prepass to support alpha test and dithered opacity#8606
Open
slimbuck wants to merge 1 commit intoplaycanvas:mainfrom
Open
Add shader defines for prepass to support alpha test and dithered opacity#8606slimbuck wants to merge 1 commit intoplaycanvas:mainfrom
slimbuck wants to merge 1 commit intoplaycanvas:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect opacity handling in the prepass by giving the prepass its own shader-define preparation path (instead of sharing the “do nothing” pick-pass path). This ensures the prepass compiles the same alpha-test / opacity-dither branches that the material expects.
Changes:
- Added a dedicated
preparePrepassPass()inLitShaderto set prepass-specific defines. - Split the
SHADER_PICK || SHADER_PREPASSbranch soSHADER_PREPASSruns its own preparation. - Imported
ditherNamesto supportSTD_OPACITY_DITHERdefine selection for the prepass.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
The prepass shader pass was sharing the same empty code path as the pick pass, which meant it had no shader defines set. This caused materials with alpha testing or opacity dithering to render incorrectly during the prepass because the relevant shader code was never compiled in.
This PR separates the prepass from the pick pass and adds a dedicated
preparePrepassPass()method toLitShaderthat sets:LIT_ALPHA_TEST— enables alpha-test discard in the prepassLIT_BLEND_TYPE— sets the blend type so the shader can handle transparency correctlySTD_OPACITY_DITHER— enables opacity dithering (matching the shadow pass behavior viaopacityShadowDither)Technical Details
ditherNamesimport fromconstants.jsSHADER_PICK/SHADER_PREPASScombined branch ingenerateFragmentShader()so each pass gets its own preparationpreparePrepassPass()follows the same pattern asprepareShadowPass()