Graphics Reference
In-Depth Information
Figure 11.28. The result of the darken (left) and lighten (right) operations on our sample
images.
Image Transitions
In addition to combining two images into one, we should think about ways to
move from one image to another over time. One example of this is the set of
slide transitions in Powerpoint, but the control we have with fragment shaders
lets us go well beyond the options available there.
The basic principle is that we start with each pixel from one image, which
we will call the Before image, and we manipulate each pixel in a way that in-
ishes with a second image, which we will call the After image. We can replace
Before pixels with After pixels in any way we like, and we will try to create
some interesting effects in doing so. In all our examples in this section, we start
with the two images of Figure 11.25, the Washington cherry blossoms and the
Hong village.
Horizontal Replace
The first transition we will consider moves the Before image off the display to
the right while simultaneously moving the After image onto the display from
the left. However, as we go through the transition, both images are displayed
in their entirety; each is simply compressed into the part of the display that
is available to it. An example of the transi-tion partly completed is shown in
Figure 11.29.
The .glib file and vertex shader source are essentially identical to the
image blending examples above, so we will focus on the fragment shader
source, shown below.
Search WWH ::




Custom Search