Part 2 - Transparent Surface Ray-TracingNow we have our wavemap, we want to have some fun with it. We take a beam of light and let it pass through the surface vertically. Because water has a higher density than air, the beam refracts towards the surface normal, and we can calculate where the beam hits whatever is under there (an image, for example). First we have to find out what the angle between the incoming light and the surface normal is (figure c).
In figure c, the red line represents the surface normal. The vertical line running through the wavemap represents the incoming light, and the arrow connected to the vertical line is the refracted beam. As you can see, the angle between the refracted beam and the surface normal is smaller than the angle between the incoming beam and the surface normal.
Determining The Angle Of The Incoming Light
Calculating the angle between the surface normal and the incoming light is very simple in our case. If we draw an imaginary triangle as shown here in red, all we need to do is determine alpha. We get the tangent of alpha when we divide y (height difference) by x (1). In other words, the height difference is the tangent of alpha, and alpha is ArcTan( height difference ). To convince you of the fact that this is actually the angle between the surface normal and the incoming light, I rotated the red triangle 90 degrees counter-clockwise. As you can see, the hypothenusa runs parallel to the surface normal. Next, we calculate the refraction. If you remember your highschool physics, you know that:
so that the angle of the refracted beam can be calculated like this:
where the refraction index is that of water: 2.0. Third, we need to calculate where the refracted beam hits the image, or its relative position to the place where the incoming light beam originally entered:
Transparent Surface Ray-Tracing Example Popup: Source Listing 2 The following program demonstrates these effects: DXEffect.exe Source code Roy Willemse can be contacted at r.willemse@dynamind.nl
|