shirley@uiucdcsm.cs.uiuc.edu (01/27/88)
I was wondering if anyone has an ELEGANT solution to my ray tracing problem: how should I handle to clear objects that touch. Here is my typical treatment without this: function ray(origin, direction, IO) {returns color} if an object OB is hit if OB->transparent if IO is INSIDE {OB} incident index of refraction = OB->index_R transmitted index = 1.0 else incident index of refraction = 1.0 transmitted index = OB->index_R < other junk > return (direct_lighting + OB->ks*ray(new_origin, reflection_dirction, IO) + OB->kt*ray(new_origin, refraction_dirction, !IO)) else return background(origin, direction) This works just fine. When I use a CSG ray tracer it's even easier: the IN/OUT lists handle the IO bookkeeping automatically. Now here is the problem: Suppose I want a clear glass filled with water. In my CSG program I have a very ugly kludge: If two objects have a separation less than some constant, then they are considered to be touching, and the refraction is calculalated accordingly. For the code above (presumably with polygon primitives), I could add a 'current indexR' parameter in the ray list, and assume that any if OB has a different index_R, it is at an interface. My only trouble with this is that I'll have to be careful when modeling. For example, the glass would have to be modeled: *** *** * * * * * = glass * * * * ~ = water * ~~~~~~~~~~ * * ~ ~ * * ~ ~ * * ~~~~~~~~ * ******** It bothers me that I have to understand the guts of my renderer when doing the modeling. Does anyone have a good (or different) way of handling this? I've never seen anything in print on such details. Has anyone else? Thanks, Peter Shirley U of Illinois at UC