Graphics Reference
In-Depth Information
shapes, and see how the effects change. Other shapes you may use are
cylinders, boxes, cones, tori, and teapots.
2. Experiment with color: change the color of the simple figures in these
examples to other colors. You may do this with the GLIB file, or you may
add color as a uniform variable set through the glman parameter interface
described in the next chapter.
3. Compute with color: you can use color as data and base your computa-
tions on it. For example, in a fragment shader you can include a state-
ment like
if (color.b > 0.5) color.r = 1.0;
This can be a very useful technique for debugging shaders, since you can-
not instrument your shader code with print statements or other familiar
techniques.
4. Compare pixel blending with pixel discarding: instead of discarding pix-
els as in the example of Figure 3.5, change the alpha value of the color of
each pixel that would have been discarded to zero and see what happens.
Don't be satisfied to observe the results from a single viewpoint; rotate
the sphere (or other object) to view it from all angles, and note when an
alpha of zero has, and when it does not have, the same effect as a discard.
5. Figure 3.5 showed a very regular patern of discards because of the logic
in the fragment shader. Change that logic and see what kind of paterns
you can make on the sphere. For example, apply a trigonometric function
to some combination of coordinates, and see if you can discard sinusoidal
ribbons around the sphere.
6. Get the GLIB file for the tessellation shader example in Figure 3.6, and
experiment with this example by changing the vertices in the patch and
by changing both the inner and outer tessellation levels. (Use any conve-
nient fragment shader to finish creating the image.)
7. Add the geometric shrink shader to the previous exercise so you can see the
individual triangles in the patch you produce, as was done in Figure 3.6.
Search WWH ::




Custom Search