Skip to content

Fix chromatic fringing shader undefined behavior with negative values#8438

Merged
mvaligursky merged 1 commit intomainfrom
mv-fringing-fix
Feb 4, 2026
Merged

Fix chromatic fringing shader undefined behavior with negative values#8438
mvaligursky merged 1 commit intomainfrom
mv-fringing-fix

Conversation

@mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Feb 4, 2026

Summary

  • Fixed undefined behavior in the fringing (chromatic aberration) post-effect shader caused by using pow() with negative base values
  • Replaced pow(centerDistance, vec2(2.0)) with centerDistance * centerDistance in both GLSL and WGSL shaders

Details

In GLSL/WGSL, pow(x, y) is undefined for negative x values. When UV coordinates are less than 0.5 (left/bottom portions of the screen), centerDistance = uv - 0.5 becomes negative, causing undefined results that varied by GPU driver and rendering path. This manifested as screenshot corruption where only the top-right quadrant rendered correctly in some browsers.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes undefined behavior in the chromatic fringing (chromatic aberration) post-effect shaders that could cause rendering corruption on certain GPU drivers and rendering paths.

Changes:

  • Replaced pow(centerDistance, vec2(2.0)) with centerDistance * centerDistance in both GLSL and WGSL fringing shaders
  • Eliminated undefined behavior caused by using pow() with negative base values when UV coordinates are in the left/bottom portions of the screen

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/render-pass/frag/compose/compose-fringing.js Fixed undefined behavior in WGSL fringing shader by replacing pow() with direct multiplication
src/scene/shader-lib/glsl/chunks/render-pass/frag/compose/compose-fringing.js Fixed undefined behavior in GLSL fringing shader by replacing pow() with direct multiplication

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mvaligursky mvaligursky merged commit e6855f8 into main Feb 4, 2026
14 checks passed
@mvaligursky mvaligursky deleted the mv-fringing-fix branch February 4, 2026 09:44
mvaligursky added a commit that referenced this pull request Feb 4, 2026
…#8438)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants