Skip to content

Commit

Permalink
Fixes bug where certain values of barrel distortion would cause alpha…
Browse files Browse the repository at this point in the history
…=0 pixel in center of source. (#36)

Closes #23
  • Loading branch information
FiniteSingularity authored May 26, 2024
1 parent 5660a3e commit 1128643
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion data/shaders/crt-composite.effect
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ float4 mainImage(VertData v_in) : TARGET
// Anti-alias barrel distortion edges
float d = min(min(uv.x, 1. - uv.x), min(uv.y, 1. - uv.y));
float w = length(float2(ddx(d), ddy(d)));
float aa_mask = smoothstep(-0.7, 0.7, (abs(frac(d - 0.25) - 0.5) - 0.25) / w);
// The check for d < 0.49 below likely can be fixed to something
// that doesn't branch.
float aa_mask = d < 0.49 ? smoothstep(-0.7, 0.7, (abs(frac(d - 0.25) - 0.5) - 0.25) / w) : 1.0;

float4 color = image.Sample(textureSampler, uv);
float4 blur_color = blur_image.Sample(textureSampler, uv);
Expand Down

0 comments on commit 1128643

Please sign in to comment.