Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: TiltShiftFilter coordinates are calculated incorrectly #483

Merged
merged 6 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/tilt-shift/tilt-shift.frag
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ uniform vec2 uStart;
uniform vec2 uEnd;
uniform vec2 uDelta;
uniform vec2 uDimensions;
uniform highp vec4 uInputSize;

float random(vec3 scale, float seed)
{
Expand All @@ -15,6 +16,7 @@ float random(vec3 scale, float seed)

void main(void)
{
vec2 adjustedStart = uStart * uDimensions / uInputSize.xy;
vec4 color = vec4(0.0);
float total = 0.0;

Expand All @@ -23,7 +25,7 @@ void main(void)

float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
vec2 normal = normalize(vec2(uStart.y - uEnd.y, uEnd.x - uStart.x));
float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * uDimensions - uStart, normal)) / gradientBlur) * blur;
float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * uDimensions - adjustedStart, normal)) / gradientBlur) * blur;

for (float t = -30.0; t <= 30.0; t++)
{
Expand Down