Fix HALFRES compositer darkening background behind transparent geometry#50
Open
coobeeyon wants to merge 1 commit intoN8python:masterfrom
Open
Fix HALFRES compositer darkening background behind transparent geometry#50coobeeyon wants to merge 1 commit intoN8python:masterfrom
coobeeyon wants to merge 1 commit intoN8python:masterfrom
Conversation
The HALFRES code path in the EffectCompositer hardcodes vec4(0.0, 0.0, 0.0, 1.0) for far-plane pixels (depth == 1.0). The R channel (0.0) is interpreted as full ambient occlusion, which darkens the entire background when transparent objects with depthWrite disabled leave far-plane depth values in the depth buffer. Replace the hardcoded constant with texture2D(tDiffuse, vUv), which bilinearly samples the AO buffer. For background pixels the AO pass already writes 1.0 (no occlusion), so the result is correct while also providing smooth edge transitions at geometry boundaries — avoiding the visible halo that a hard constant produces.
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.
Problem
When
halfResis enabled, the EffectCompositer's HALFRES code path hardcodesvec4(0.0, 0.0, 0.0, 1.0)for far-plane pixels (depth == 1.0). The R channel value of0.0is interpreted as full ambient occlusion, which darkens the entire background when transparent objects withdepthWritedisabled leave far-plane depth values in the depth buffer.Fix
Replace the hardcoded constant with
texture2D(tDiffuse, vUv), which bilinearly samples the AO buffer. For background pixels the AO pass already writes1.0(no occlusion) via the early return in the EffectShader, so the sampled value is correct. This also provides smooth edge transitions at geometry boundaries — the hardcoded constant created a visible halo where the binarydepth == 1.0check met the upsampled AO values.Reproduction
halfRes: truedepthWrite: falsehalfRes: false, the background renders correctlyChange
One-line change in
src/EffectCompositer.js: