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:55 EDT (-0400)
  Re: How does POV-Ray handle IORs between two interfacing surfaces?  
From: Retsam
Date: 5 Apr 2003 00:15:03
Message: <web.3e8e663aeee3489b34dff4bb0@news.povray.org>
Christopher James Huff wrote:

>
>> 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. |>

I know that's probably what's intended, but I'm just looking at the code.
To wit:

  if (Ray->Index == -1)
      ....
  }
  else
  {
    /* The ray is currently inside an object. */
    if ((nr = Interior_In_Ray_Container(&NRay, Interior)) >= 0)
    {
      /* The ray is leaving the current object. */
      Ray_Exit(&NRay, nr);
            if (NRay.Index == -1)
      {
        /* The ray is leaving into the atmosphere. */
           .......
      }
      else
      {
        /* The ray is leaving into another object. */
        ior = Interior->IOR / NRay.Interiors[NRay.Index]->IOR;
             ....

It looks to me like this happens.  The ray enters the glass, ior 1:1.57.  We
all agree so far.  Next, if I have the water go slightly inside the glass,
then there will be a water hit, and refraction at ior 1.57:1.33.  Again, we
all agree so far.

Now, the Trace function is called again.  There's a hit, this time as the
ray exits the glass (still in the water).

Looking at the code above, this is what I see.  Ray->Index != -1, so we go
to the else.

The Interior_In_Ray_Container function is passed the current ray, and the
Interior we're checking.  Correct me if I'm wrong, but Interior in this
comparison is the container that was just intersected, right?  If I'm
wrong, then what is Interior?

But assuming Interior is the glass, the function will return the index to
the glass (which is removed from the list), and nr will be greater than or
equal to 0.  Note the comment, the ray is leaving the current object, i.e.
the glass.

Now, NRay.Index should be non-negative after the Ray_Exit() call, since
we're still in the water.  So we move into the next else block, which is
commented as "The ray is leaving into another object", i.e. the water.
Note that it does a 1.57:1.33 transition AGAIN.

Now, I haven't stepped through the code, so I may be missing something.  But
what is it?


Post a reply to this message

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