Game Development Community

Proper handling of refracted rays

by Benjamin Wilson · in Technical Issues · 10/20/2002 (6:54 pm) · 2 replies

Hi,

In a ray-tracing setting, I was wondering how to handle refracted rays that are subject to "total reflection". I want to trace them and add in their color contribution, but I'm a little unsure of how to find the ray's direction.

Thanks,
Ben

#1
10/20/2002 (9:08 pm)
Reflect about the normal of the surface, in a word.

Does that help? I think that doing a quick websearch on those keywords would help.
#2
10/21/2002 (11:48 am)
na * sin A = nb * sin B

Where na is the index of refraction for material a, and A is the angle at which the light ray strikes. Likewise for B. If you set it up like this, it is easier:

B = sin-1( (na/nb) * sin A )

Here's some real world examples of n:

Vacuume n = 1
Air @ STP n = 1.00029
Water @ 20 C n = 1.33
Typical glass n = 1.52
Diamond n = 2.42

It is important to note that theta (A or B) is the angle of the lightray and a vector perpendicular to the surface. I will now attempt ASCII art...


\ |
\x|
\|
_______y_\_______
|\ w
|z\
| \
| \

Light strikes the waters surface at a y degrees angle. This makes our theta-A (labled x in picture) 90-y. The resultant angle, theta-B (labled z) is w degrees from the waters surface, so it is 90 - w.

Lets say that y = 50, and we are trying to find z. (Remember x = theta-A, z = theta-B) Theta-A = 90 - y = 40. The light ray is traveling through the air and entering water, this makes na = 1.00029, and nb = 1.33. Here is the equation for theta-B.

B = sin-1( (1.00029/1.33) * sin(40) )
B = sin-1( 0.7521 * sin(40) )
B = sin-1( 0.64279 )
B = 40.0002 degrees

Now for total internal reflection the critical angle can be found by using the above formula modified.

na * sin A = nb * sin 90

Why 90? Because that is when no light will be reflected and you will have total internal reflection.

Hope that helped, if not at least it got me to dust off the physics book and relive the pain of Physics 2.