POV-Ray : Newsgroups : povray.advanced-users : How does POV-Ray handle IORs between two interfacing surfaces? : Re: How does POV-Ray handle IORs between two interfacing surfaces? Server Time
29 Jul 2024 02:20:26 EDT (-0400)
  Re: How does POV-Ray handle IORs between two interfacing surfaces?  
From: Christopher James Huff
Date: 2 Apr 2003 23:15:22
Message: <cjameshuff-5F81E5.23155702042003@netplex.aussie.org>
In article <web.3e8b41bd8073fdf12a3ff2e70@news.povray.org>,
 "Retsam" <nomail@nomail> wrote:

> I've been looking at the code, trying to figure out how POV-Ray handles a
> refracted ray as it passes from one object to another, such as from a glass
> bottle to the water in the bottle.

The explanation is fairly complex, and has been covered in-depth several 
times. Basically, you should overlap the objects slightly, just enough 
to avoid precision errors.


> Assuming that I have a "water" object whose surface "exactly" matches the
> inside surface of the glass, I would expect the ray to transition from the
> IOR of the glass to the IOR of the water.

No. Because of precision errors, the objects will either overlap, have a 
gap between them, or the surface of one will be missed entirely. You 
need to either overlap or separate them, based on the desired results. 
As long as the objects are well-behaved, with no holes in the surface or 
internal surfaces, it will work.


> The ray will first enter the glass from the outside, going from ior 1 to ior
> 1.57, for example.  Then, in the Trace function, depending on whether
> Best_Intersection is the glass ending or the water starting, you will get
> one of two outcomes.  If it's the glass ending, the ray will go from ior
> 1.57 to 1.0.  Then the next Trace intersection will be with the water,
> going from ior 1.0 to ior 1.33.  Definitely wrong, as you will get TIR at
> angles as small as about 40 degrees, instead of the larger 57 degrees or so
> they should start at.

Not wrong, entirely correct. If you hit the glass first, there is an air 
gap between the glass and the water. This doesn't usually happen with 
glass and water in reality, it only happens here because you set things 
up wrong. However, if you get a piece of glass dirty and sufficiently 
water-repellent, with some kind of oil for example, it will keep a film 
of air which has a silvery appearance.


> On the other hand, if the first intersection is with the water, it will go
> from ior 1.57 to 1.33 (the ior at the interface = 1.57/1.33), then as it
> leaves the glass, it will go from ior 1.57 to 1.33 again, sort of.  That
> is, it will refract twice using the same relative iors.

No, the second glass refraction is ignored. POV maintains a list with 
the objects it is currently "inside", which lets it figure out when 
refraction should be done.

At first, the list is empty: |>

Ray hits glass, which is not in list. Refraction takes place 
(air-glass), glass is added to list. list: |glass>

Ray hits water, which is not in list. Refraction takes place 
(glass-water), water is added to list. list: |glass, water>

Ray hits glass again, which is now in list, but not most recent. 
Refraction is ignored because it was already done for this object, glass 
is removed from list. |water>

For simplicity, say the ray now exits directly into air.
Ray hits water again, which is in list and most recent. Refraction is 
done again (water-air), water is removed from list. |>


> Am I reading something wrong here?  I've been looking for code that handles
> the coincident surfaces, but I cannot find it.

Because it doesn't exist. That's why you aren't supposed to use 
coincident surfaces.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.