summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/video/qmlvideofx/shaders/magnify.fsh13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/video/qmlvideofx/shaders/magnify.fsh b/examples/video/qmlvideofx/shaders/magnify.fsh
index c4c25d9e0..076db1799 100644
--- a/examples/video/qmlvideofx/shaders/magnify.fsh
+++ b/examples/video/qmlvideofx/shaders/magnify.fsh
@@ -53,13 +53,16 @@ uniform float posY;
void main()
{
- float h = diffractionIndex * 0.5 * radius;
- vec2 targetSize = vec2(targetWidth, targetHeight);
+ vec2 tc = qt_TexCoord0;
vec2 center = vec2(posX, posY);
vec2 xy = gl_FragCoord.xy - center.xy;
float r = sqrt(xy.x * xy.x + xy.y * xy.y);
- vec2 new_xy = r < radius ? xy * (radius - h) / sqrt(radius * radius - r * r) : xy;
- vec2 tc = (new_xy + center) / targetSize;
- tc.y = 1.0 - tc.y;
+ if (r < radius) {
+ float h = diffractionIndex * 0.5 * radius;
+ vec2 new_xy = r < radius ? xy * (radius - h) / sqrt(radius * radius - r * r) : xy;
+ vec2 targetSize = vec2(targetWidth, targetHeight);
+ tc = (new_xy + center) / targetSize;
+ tc.y = 1.0 - tc.y;
+ }
gl_FragColor = qt_Opacity * texture2D(source, tc);
}