Fix fisheye distortion calculations and update mask parameter in fragment shader

This commit is contained in:
Quinten Mennen 2025-06-11 18:00:40 +02:00
parent 55f5b32b93
commit e3e7bbefdc

View File

@ -45,7 +45,7 @@ vec2 fisheyeDistort(vec2 coord, float strength) {
float distance = length(centered);
// Reduce strength near edges
float adjustedStrength = strength * (1.0 - smoothstep(0.7, 0.9, distance));
float adjustedStrength = (1 - strength) * (1.0 - smoothstep(0.7, 0.9, distance));
float distorted = distance * (1.0 + adjustedStrength * distance * distance);
@ -69,7 +69,7 @@ float calculateMask(vec2 coord, float fisheyeStrength, float maskThreshold, floa
return 1.0;
}
float distorted = distance * (1.0 + fisheyeStrength * distance * distance);
float distorted = distance * (1.0 + (1 - fisheyeStrength) * distance * distance);
vec2 distortedCoord = centered * (distorted / distance);
distortedCoord = distortedCoord * 0.5 + 0.5;
float maxDistortion = max(
@ -150,7 +150,7 @@ void main()
noiseColor *= vec4(vig) * vec4(1.0, inv_hit, inv_hit, 1.0);
}
float mask = calculateMask(gl_FragCoord.xy / u_resolution, 1, 0.08f, 0.02f);
float mask = calculateMask(gl_FragCoord.xy / u_resolution, u_battery, 0.08f, 0.02f);
FragColor = vec4(noiseColor.rgb * mask, noiseColor.a);
// FragColor = noiseColor;
} else {