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>
This commit is contained in:
committed by
Qt by Nokia
parent
5c0629b571
commit
50a80cd083
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user