Skip to content

Commit 29b2d58

Browse files
mvaligurskyMartin Valigursky
andcommitted
Fix chromatic fringing shader undefined behavior with negative values (#8438)
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
1 parent 7aba7cb commit 29b2d58

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/scene/shader-lib/glsl/chunks/render-pass/frag/compose/compose-fringing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default /* glsl */`
55
vec3 applyFringing(vec3 color, vec2 uv) {
66
// offset depends on the direction from the center
77
vec2 centerDistance = uv - 0.5;
8-
vec2 offset = fringingIntensity * pow(centerDistance, vec2(2.0, 2.0));
8+
vec2 offset = fringingIntensity * centerDistance * centerDistance;
99
1010
color.r = texture2D(sceneTexture, uv - offset).r;
1111
color.b = texture2D(sceneTexture, uv + offset).b;

src/scene/shader-lib/wgsl/chunks/render-pass/frag/compose/compose-fringing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default /* wgsl */`
55
fn applyFringing(color: vec3f, uv: vec2f) -> vec3f {
66
// offset depends on the direction from the center
77
let centerDistance = uv - 0.5;
8-
let offset = uniform.fringingIntensity * pow(centerDistance, vec2f(2.0));
8+
let offset = uniform.fringingIntensity * centerDistance * centerDistance;
99
1010
var colorOut = color;
1111
colorOut.r = textureSample(sceneTexture, sceneTextureSampler, uv - offset).r;

0 commit comments

Comments
 (0)