dipityPix app

Thursday, October 9, 2008

Double-sided dielectrics for ray tracing


No, neither I nor this blog is dead yet.

Sometimes ray tracing models will take a thin dielectric (like a car windshield) and represent it with one surface. If we assume this dielectric surface is locally planer, then the direction of the ray will not be changed by the double refraction, but it will be offset. This is shown in the image above. Our challenge is to calculate the vector o in the figure. The new origin of the ray will just be hit_point+o.

The thickness t is provided by the model, possibly with a texture. First let's find a unit vector parallel to o by subtracting off the portion of v in the direction of n:

a = -normalize(v - dot(v,n)n)

Now we need to find the distance that is the length of o, which is q-w. We can see that

q = t tan(Theta).

Similarly,

w = t tan(Theta')

Snell's law tells us that

sin(Theta) = ref_Idx sin(Theta').

Assuming v is a unit vector we also have

cos(Theta) = -dot(v,n)

That allows us (with a bunch of sqrts) to get all the sines and cosines we need above.

6 comments:

mukurt said...
This comment has been removed by the author.
Brian said...

I just had an idea:
You could approximate the surface interfaces with spheres! With a little precomputation and some extra runtime calculation, your algorithm could be made spatially aware (to a degree, anyway). You could store two sphere radii + an offset for the bottom interface per vertex and interpolate those parameters across a triangle. That way you could, say, have a ray enter near an actual geometric corner and the ray will exit again from the same side.

-Brian

eda said...

情趣,G點,性感丁字褲,情趣,角色扮演服,吊帶襪,丁字褲,情趣用品,無線跳蛋,男女,

按摩棒,電動按摩棒,飛機杯,視訊,自慰套,自慰套,情趣用品,情趣內衣,

情趣按摩棒,自慰套,角色扮演,按摩棒,跳蛋,情趣跳蛋,
.,
潤滑液,SM,內衣,性感內衣,自慰器,充氣娃娃,AV,

Niya said...

Great blog... Thanks.

Enamul Hoq said...

Good post. I am really glad to read this article. This is very informative post. So read and learn something.
clipping path

Enamul Hoq said...
This comment has been removed by the author.