Hn <Hn@[EMAIL PROTECTED]
> writes:
>> glass air
>> glass water
>> glass ice
>>
>> depending on where a ray is. Today I use a list of medium being
>> traversed but I can't seem to be able to exit a material directly
>> into another one..
>
> Can you use a stack? Push the old IOR's as you enter a new medium (from
> the 'front' ), then pop them back when you exit a medium (from the back)
I suspect he's already using a stack (the "list of medium being
traversed"), but the problem is often it's convenient to be able to have
"objects" which aren't properly nested.
E.g.,
R
/
---+ +----------4-+ +---
| | I / | |
+-------+--------3---+--------+
\ | / | /
| +------2-----+ |
| / |
| W/ |
\ / /
+--------1----------------+
/
G .
.
-------0-----------------------
I being the ice cube, W the water and G the glass. The ray R traverses
various interfaces at points 1 - 4.
You can handle the G->W at point 1 transition using the method I
previously mentioned (since that interface is probably static), and the
W->I interface at point 2 because it's an "entering" transition, but
what do you do at point 3 and 4?
That would seem more amenable to treating the list of "active" media as
a set than as a proper stack -- e.g., when you make an "exit"
transition, go back through the history of the ray, and find the
innermost medium which hasn't been exited.
So at point 3, you have a ray history like:
0: enter G, from IOR = 1
1: exit G
+ enter W (special handling because it's a dual interface)
2: enter I, from IOR = W's IOR
3: exit W
[The "from IOR" at each "enter" point is just whatever IOR was current
at that point.]
I is the innermost active medium, so you'd use W's IOR as the new
current IOR.
At point 4, you have additionally:
4: exit I
So no medium is active, and you'd just use 1 as the new IOR.
[I suppose the overlap between the ice cube and the water isn't quite
proper, but it's very convenient from a scene-definition point of view
to be able to do that kind of thing...]
-Miles
--
My spirit felt washed. With blood. [Eli ****n, on "The Passion of the
Christ"]


|