Graphics Reference
In-Depth Information
Figure 16.2. Hue spectral changes.
we can simply add the two dot products together.
float sum = dot(ToLight, TransfTangent) + dot(ToEye,
TransfTangent);
float delta = D * abs( sum );
From this, Δ is computed and the wavelength equation is inverted to give
us the required integer multipliers as a function of wavelength:
(
)
d
cos
ΦΦ
λ
cos
i
r
m
=
.
When the minimum and maximum wavelengths are substituted into this
equation, we have the maximum and minimum integer multipliers, mmax and
mmin respectively, for visible light. The fragment shader loops through these inte-
ger multipliers and computes a color for each one using the Rainbow( ) function
that we used in the transfer function discussion in Chapter 15.
That function is a reasonably good approximation of the visible
portion of the electromagnetic spectrum, and it gives us a color
distribution that looks like Figure 16.2.
It may be the case that for some points on the surface,
mmin mmax . In those cases, we compute the colors for each
wavelength and average the results. When we put all of this
together, we get a final effect that looks like Figure 16.3.
This kind of diffraction effect is found in many places in
nature, such as bird feathers and buterly wings. Our ability to
model the effect does not make it any less wonderful in nature!
Figure 16.3. CD diffraction
shader.
Search WWH ::




Custom Search