Graphics Reference
In-Depth Information
vec3 Rrgb = texture( uRandomUnit, st ).rgb;
vec3 Mrgb = texture( uMaskUnit, st ).rgb;
vec3 color;
float T = 1024.*Timer;
if ( Mrgb.r > 0.5 ) // white part of mask
{
st = vec2( st.s + T/1024., st.t );
color = texture( uRandomUnit, st ).rgb;
}
else // black part of mask
{
st = vec2( st.s - T/1024., st.t );
color = texture( uRandomUnit, st ).rgb;
}
fFragColor = vec4( color, 1.);
}
We wish we could show you this technique in action, but the key word
is action : it is the action of motion that shows the content of the mask tex-
ture. Since you are reading this in print, which does a poor job of supporting
animation, we cannot do this; any freeze-frame capture of the output simply
shows the white noise texture. Instead we urge you to download the textures
( random.bmp and mask.bmp ) shown in Figure 16.31, see the effect, and then see
what more you can do, as suggested in an exercise.
Figure 16.31. The white noise texture (left) and a possible mask texture (right).
Search WWH ::




Custom Search