Newsgroups: comp.graphics Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!eye!erich From: erich@eye.com (Eric Haines) Subject: Re: How do YOU compute refraction vectors? Message-ID: <1991May21.211723.22948@eye.com> Reply-To: erich@eye.com () Organization: 3D/Eye Inc., Ithaca, NY References: <9105210459.AA01904@enuxha.eas.asu.edu> Date: Tue, 21 May 91 21:17:23 GMT In article <9105210459.AA01904@enuxha.eas.asu.edu> hollasch@enuxha.eas.asu.edu (Steve Hollasch) writes: > > About a month ago I posted a request for a reference on the particular >refraction equation I used, but no one responded. Could have been >disinterest, but perhaps there are people who haven't heard of it, >either. _ _ > P1 | | > The equation I use is R = (D.N)N + -- | D - (D.N)N |, where P1 is the > P2 |_ _| > >index of refraction of the material containing the ray origin, P2 is >the index of refraction of the intersected object, N is the surface >normal, and D is the ray direction vector TOWARDS the surface. Note that >the resulting vector is NOT a unit vector. > > Does anybody know of a more efficient equation? How do YOU compute >the refraction vector? Sorry, I missed your original posting. Offhand, I don't see how your equation detects total internal reflection, so I am loathe to analyze it further. For example, in Heckbert's method he detects if there is total internal reflection by seeing if the value "C2" is negative - taking the square root of a negative number is interpreted as TIR. However, assume I've missed something and your equation works. Have you compared your method with Heckbert's, in "An Introduction to Ray Tracing" edited by Andrew Glassner? I've found his methods (pages 290-292) to be pretty minimal. He talks about Whitted's original method and gives his own and a variation on it. Whitted's has 2 square roots, 8 divides, 17 mults, and 15 adds. Heckbert's has 1 square root, 1 divide, 13 mults, and 8 adds. His variant formulation has 1 square root, 4 divides, 8 mults, and 8 adds (nice if your machine does divides almost as fast as mults). Note that he's starting with normalized vectors and computing a normalized vector. Eric