fix: ensure opacity dither fully hides at alpha 0 and fully shows at alpha 1#8767
Merged
Merged
Conversation
mvaligursky
approved these changes
May 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the contract of the standard shader’s opacity dithering so the boundary cases behave deterministically across all dither sources (Bayer / blue-noise / IGN): alpha = 0 always fully discards and alpha = 1 never discards.
Changes:
- Add early-out discard when
alpha <= 0.0to prevent stray visible pixels at zero opacity. - Add early-out return when
alpha >= 1.0to prevent any accidental discards at full opacity. - Apply the same boundary behavior to both WGSL (WebGPU) and GLSL (WebGL) opacity dither chunks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/scene/shader-lib/wgsl/chunks/standard/frag/opacity-dither.js | Adds explicit alpha boundary early-outs in WGSL opacityDither to enforce fully hidden/fully opaque behavior. |
| src/scene/shader-lib/glsl/chunks/standard/frag/opacity-dither.js | Mirrors the same alpha boundary early-outs in GLSL opacityDither for consistent behavior across backends. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Thanks! |
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
alpha = 0produces a fully invisible surface andalpha = 1produces a fully opaque surface, regardless of dither mode.[0, 1](Bayer can hit0, blue-noise textures can hit0and1, IGN noise can hit0) causedalpha < noiseto leave stray pixels visible atalpha = 0(and could discard pixels atalpha = 1for blue-noise).opacityDitherso the contract is enforced at the source instead of relying on the noise range.src/scene/shader-lib/glsl/chunks/standard/frag/opacity-dither.js,src/scene/shader-lib/wgsl/chunks/standard/frag/opacity-dither.js).Before:

After:

Test plan
dithered-transparencyexample and confirm a material with opacity intensity0renders fully invisible (no scattered dots) across all three dither modes: BAYER8, BLUENOISE, IGNNOISE.1renders fully opaque with no discarded pixels in all three modes.0 → 1).Fixes #
Checklist