Fix glass shader tint not blending through multiple layers (#10364)#10366
Closed
Infiland wants to merge 1 commit intoFacepunch:masterfrom
Closed
Fix glass shader tint not blending through multiple layers (#10364)#10366Infiland wants to merge 1 commit intoFacepunch:masterfrom
Infiland wants to merge 1 commit intoFacepunch:masterfrom
Conversation
Contributor
|
Pretty clever, makes sense, I need to test it proper |
Contributor
|
This PR has been merged upstream. |
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
Quality glass (refractive mode) writes fully opaque with no blend state, so the front glass pane completely overwrites the back glass pixels. This means only the front glass tint is ever visible when looking through multiple layers.
This PR enables premultiplied alpha blending for quality glass and computes a physically-based alpha from Fresnel reflectance and albedo luminance. Back glass layers now partially show through the front glass, blending their tints together. Clear glass (white albedo) is unaffected (alpha ≈ 1.0). Reflections remain at full strength due to premultiplied alpha.
Motivation & Context
Fixes: #10364
Implementation Details
SrcBlend=ONE, DstBlend=INV_SRC_ALPHA) instead of standard alpha blend — this keeps specular reflections additive at full strength while only the refraction (emission) is pre-scaled by alpha.saturate(avgFresnel + (1 - avgFresnel) * sqrt(albedoLuminance)). At grazing angles Fresnel pushes alpha to 1.0 (glass is reflective/opaque). At normal incidence, darker tints get lower alpha so more of the back glass shows through. Clear glass gets alpha ≈ 1.0 (no visual change).Screenshots / Videos (if applicable)
-/-
Checklist