Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pasteur!ucbvax!decwrl!sgi!thant@horus.SGI.COM From: thant@horus.SGI.COM (Thant Tessman) Newsgroups: comp.graphics Subject: Re: Ray tracing refraction Summary: what is refraction Message-ID: <25779@sgi.SGI.COM> Date: 30 Jan 89 18:31:56 GMT References: <65@sdcc10.ucsd.EDU>, <0XryqWy00Uo1875Ud-@andrew.cmu.edu> Sender: daemon@sgi.SGI.COM Distribution: usa Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 66 In article <0XryqWy00Uo1875Ud-@andrew.cmu.edu>, po0o+@andrew.cmu.edu (Paul Andrew Olbrich) writes: > Hi-ho, > > I'm trying to add refraction to a ray tracing program I'm writing in C. Could > someone help me out a bit? Warning: I'm doing this from memory, and I've never written a ray-tracer. \<-theta1->| \ | \ | incoming ray-> \ | <- surface normal \ | \ | \ | \ | \ | \ | \| -------------------------------------------------- <- surface | | \ | \ | \ | \ | \ | \ <- outgoing ray | \ | \ | \ |<-theta2->\ sin(theta1) sin(theta2) ----------- = ---------- n1 n2 (theta1 and theta2 are angles) If n1 is 1 (like for a vacuum) and n2 is bigger than 1 (like glass) then theta2 is smaller than theta1. Note that if it is the other way around, that is, the ray goes from an optically dense material to an optically less dense material, (like a ray coming out of glass), then theta2 is bigger than theta1. (Maybe this is where you are screwing up?) Also, if you are solving for sin(theta2) and you get a number bigger than 1, it means that the ray should be totally internally reflected. This is why when you look up from the bottom of a pool, everything above the water looks like it is in a round window above your head. There are other considerations. The ratio of light reflected to transmitted is dependent on the angle but I can't remember that stuff. Also, reflected and transmitted light is polarized (also dependent on the angle). Pelicans have polarized filters in their eyes to see fish in the water better. Bees have polarized eyes to navigate with sunlight on cloudy days. Some crystals have different indecies of refraction for light polarized in different directions. When you look through them you see two images. And on and on... Thant Tessman (thant@sgi.com) "make money, not war"