Graphics Reference
In-Depth Information
times. This effect can vary across a surface, changing the colors we see at dif-
ferent points. There are many ways this can happen, but we will look at two:
diffraction gratings, such as the grooves on a CD or DVD, and oil slicks.
Diffraction Gratings
A diffraction grating is a surface containing a set of parallel lines that are very
close together, as illustrated in Figure 16.1. One common example of this is the
surface of a CD or DVD, in which case the “parallel lines” are concentric rings.
On a CD, the distance d between adjacent tracks is 1600 nm, while on a DVD,
d is 740 nm.
In this figure, we see that light arrives at a surface containing a diffrac-
tion grating with distance d between the grooves. The light arrives with an
incident angle Φ i with respect to the plane of the surface. It bounces in all
directions, and some of it reflects toward the eye with a reflective angle Φ r .
Because the distance d between the grooves is very small with respect to
the light and viewing distances, we will treat multiple rays as if they were
parallel.
On the way to the surface, the light along path B travels d  *  cos(Φ i ) farther
than the light along path A , while on the way from the surface to the eye, the
light along path A travels d  *  cos(Φ r ) farther than along path B . The absolute
difference between the lengths of the paths is
(
)
=∗ −
d
cos
Φ
cos
Φ
.
i
r
If the difference ∆ is a multiple of the light's wavelength λ, m λ, then the
waves of the two paths are in phase and that wavelength is reinforced. So the
wavelengths λ * that we see in this type of situation are all defined by
(
)
d
cos
ΦΦ
cos
i
r
λ =
.
m
We know the values of Φ i  , Φ r  , and d . We just need to see what, if
any, integer values of m would give us wavelengths in the visible spectrum.
The following code shows the vertex shader. The eye coordinate position
is retained, as well as the transformed tangent vector. Because the grooves
are circular, the tangent vector to the grooves at a point ( x , y ) on the cir-
cle is (- y , x ). This is computed by the vertex shader to use in the fragment
shader.
out vec3 vECposition;
out vec3 vTransfTangent;
Search WWH ::




Custom Search