summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2012-02-08 15:51:32 +0000
committerQt by Nokia <qt-info@nokia.com>2012-02-09 00:42:27 +0100
commit50a80cd08330886e380f1ea5801acaca8c31fd00 (patch)
treed95d88a1c90017f0f5578c3cea9a49ef76c7f6c6
parent5c0629b5711b1f349dd7f4add7a61d75bdf5b222 (diff)
Fixed 'magnify' shader in qmlvideofx example
Previous shader caused untransformed pixels (those outside of the lens) radius to be offset slightly from their original positions. Change-Id: I4df847fdc40073a55da8777981c3fdd373937658 Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
-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 c4c25d9e..076db179 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);
}