Graphics Reference
In-Depth Information
Figure 16.15. The path of light through a water droplet.
Table 16.1 shows these approximate angles for different wavelengths of
light that correspond to the main colors we see in a rainbow. The angle Θ rep-
resents the main rainbow, and ΘΘ represents the secondary rainbow.
Color
λ
η
Θ
cosΘ
ΘΘ cosΘΘ
Red
≈ 650 nm
1.510
42°
0.743
50.0°
0.643
Green ≈ 500 nm
1.519
41°
0.755
51.5°
0.623
Blue
≈ 400 nm
1.528
40°
0.766
53.0°
0.602
Table 16.1. The approximate angles for a rainbow.
The actual computation of color for a rainbow in a scene could be done
using angle computations in the fragment shader, as we did for the spotlight
simulation in Chapter 8. This would involve creating a one-dimensional tex-
ture whose colors span the rainbow and using that texture with the angle val-
ues as texture coordinates. However, we have other resources, so it is probably
simpler to use the approach of [4], with the Lee diagram for light scatering in
the rainbow region, computed by MiePlot and shown in Figure 16.16.
We have created a texture map from this Lee diagram and have used it as
a look-up table to return the color of the rainbow for various angles in a dis-
play. This is done by sampling a vertical line in the Lee diagram at a fixed value
of the droplet radius. In Figure 16.17, we see the effect of this fragment shader
computation for a plain gray quad (left), for a natural scene with the rainbow
added (middle), and for the natural scene with an actual rainbow (right). In
the first two cases, the color returned from the texture map is simply added to
the color of the pixel to get the displayed color, though of course some of the
 
Search WWH ::




Custom Search