Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!spool.mu.edu!agate!ucbvax!ENUXHA.EAS.ASU.EDU!hollasch From: hollasch@ENUXHA.EAS.ASU.EDU (Steve Hollasch) Newsgroups: comp.graphics Subject: How do YOU compute refraction vectors? Summary: Here's my method; do you know of a better one? Message-ID: <9105210459.AA01904@enuxha.eas.asu.edu> Date: 21 May 91 04:59:18 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: hollasch@enuxha.eas.asu.edu (Steve Hollasch) Organization: Arizona State University Lines: 70 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? For those of you who are interested, the derivation of the above equation follows. ////////////////// WARNING -- DERIVATION AHEAD ///////////////////// N: Normal vector N /|\ b: "horizontal" component | of vector D. | b |/........o a: Negative "vertical" a /:\ _/ component of vector D. : _/ : _/ P1 :A_/ D ____________:/___________ /: P2 / : /A': / : / : / : R: Refraction vector R |/.....\:/ -a \ kb | | \|/ -N || b || || D - (D.N)N || sin(A) = ------- = ---------------- || a || || - (D.N)N || || kb || k || D - (D.N)N || sin(A') = -------- = ------------------ || -a || || (D.N)N || By Snell's law, P1 sin(A) = P2 sin(A'), so (P1/P2) sin(A) = sin(A'). Using this equality and combining the above two equations, we get k || D - (D.N)N || P1 || D - (D.N)N || ------------------ = -- ---------------- || (D.N)N || P2 || - (D.N)N || Since || (D.N)N || = || - (D.N)N ||, this equation simplifies to k = (P1/P2). So, solving for the refraction vector R, we arrive at the following equation: _ _ P1 | | R = -a + kb = (D.N)N + -- | D - (D.N)N | P2 |_ _| ______________________________________________________________________________ Steve Hollasch / Arizona State University (Tempe, Arizona) hollasch@enuxha.eas.asu.edu / uunet!mimsy!oddjob!noao!asuvax!enuxha!hollasch