Graphics Reference
In-Depth Information
of the pixel whose color you use; look for this in the shader code. The inverse
mapping function for this transformation is given by
Tx xr
+
cos(
β
)
for
for
rr
1
c
max
:
=
x
x
r
>
r
max
Ty yr
+
sin(
β
)
for
for
rr
1
:
=
c
max
y
y
r
>
r
max
with
=
2
2
dxx
r dd
=
+
x
c
x
y
r
r
dyy
= ′ −
β
=
arctan (,)
d d
+
α
(
max
)
y
c
2
yx
r
max
The resulting image effect is shown in Figure 11.17 for the rectangular
grid and for the cherry blossom image.
In the twirl transformation fragment shader below, look for the changes
to and from pixel coordinates, and note the two parameters (angle α and limit-
ing radius r max ) that are set up as uniform variables, so they can be defined as
glman uniform slider variables.
const float PI = 3.14159265;
uniform sampler2D uImageUnit;
uniform float uD, uR;
in vec2 vST;
Figure 11.17. The twirl transformation on the grid (left) and on the cherry blossom image
(right).
Search WWH ::




Custom Search