Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!think!ames!pasteur!agate!saturn!skinner
From: skinner@saturn.ucsc.edu (Robert Skinner)
Newsgroups: comp.graphics
Subject: Re: Village Idiot asks about Ray Tracing (Long)
Message-ID: <5647@saturn.ucsc.edu>
Date: 6 Dec 88 20:13:23 GMT
References: <859@amethyst.ma.arizona.edu>
Reply-To: skinner@saturn.ucsc.edu (Robert Skinner)
Organization: University of California, Santa Cruz
Lines: 134

In article <859@amethyst.ma.arizona.edu> chris@spock.ame.arizona.edu (Chris Ott) writes:
>
>ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
>>	I was doing a few gedanken experiments with raytracing, and came up
>> with a few questions.  Realize that I've never written a raytracer.
>
>     I'm writing a ray tracer right now and have some experience.

I haven't written a ray tracer, but I've talked to people that have

>>  [in summary, Leo asks:]
>> does ray tracing produce secondary illumination, i.e. does the light
>> bouncing off of a mirror illuminate an object?
>
>     Software that does true ray tracing would definitely illuminate the
>object. For example, the ray could be sent from the eye through a specific
>pixel on the screen to the object, bounce off the object into the mirror,
>and finally, off the mirror into a light source. Then, given the color of
>the object and the light source, the pixel's color can be computed. At
>least mine works this way. The way my code looks, it seems as if this
>would be intrinsically part of ray tracing, i.e. I didn't have to make
>a special case for mirrors.

	Say you've got one sphere, one light source, and 40 mirrors, but
only one miror reflects the light source onto the sphere.
How do you know which mirror contributes light without casting test
rays towards the mirrors?  And how many rays do you cast before you
give up?  The mirror may be large, and the light only comes from one
small part of it.

	This also goes for secondary illumination from non-mirrors
(all objects reflect, except a black body).  Imagine two surfaces that
face each other, one is directly illuminated but the second is not.  
The second surface should be illuminated from the first one.

	If you have an algorithm that can do this naturally without
using rays to search for the illuminant, then you should publish.  I'm
sure it would be accepted by SIGGRAPH.  Jim Kajiya is the only one I'm
aware of that has published anything about ray tracing that can handle
secondary illumination, and this is how he does it.  (He said he had
to use HUGE lights to get it to work.)

>
>>	Suppose I have a flat surface, a light source, and an object in the
>> shape of a convex lens above the surface under the light.  Suppose further
>> that the object is set up to be perfectly clear, and refracts light like
>> glass.  Question:  Will the light beneath the lens object be intensely
>> focused on the surface below, just like a real lens?
>
>     Again, true ray tracing would definitely produce this result.

You can't get this without the secondary illumination you are asking
for above.

>
>Then ranjit@eniac.seas.upenn.edu (Ranjit Bhatnagar) writes:
>
># ... most ray tracers do NOT model reflected light,
># ... you have to cast rays in EVERY DIRECTION, ..
>#
># A nice application of stochastic techniques is to cast a moderate
># number of rays in RANDOM directions, hoping that they will hit a mirror
># if there's one to hit.  If the jitter is done well, then the effect
># will not be bad.
>
>     This does not sound correct to me. My understanding is that the only
>rays we are interested in are the ones that the eye can see, so we just
>need to cast a ray (more than one, if we want some reasonable anti-aliasing)
>from the eye-point through each pixel. At least that's the way I did it
>and it gives very realistic results. Any comments?

I agree with Ranjit.  You are right as far as primary rays are
concerned, but once you hit an object, what do you know about how it
is illuminated?  You know the positions of the lights, no sweat there.
You know the positions of mirrors that may reflect light onto this
object, but you don't know what part of the mirror really does it.
Take the example above of the light being focused onto the object (a
caustic).  The light is intensified at the caustic, so you must take
into account that the light is being reflected from many places on the
mirror onto one spot on the surface.  (Many of your test rays bounced
off of the mirror and hit the light).  A short distance away from the
caustic, there is no extra illumination.  (All of the test rays bounced
off of the mirror and MISSED the light).
>
>>	The point of the above two questions is to find out if, in general,
>> raytracers handle illumination from light bounced off of or refracted
>> through other objects.
>
>     Yes.

No

>
>>	Finally, has anyone come up with a raytracer whose refraction model
>> takes into account the varying indicies of refraction of different light
>> frequencies?  In other words, can I find a raytracer that, when looking
>> through a prism obliquely at a light source, will show me a rainbow?
>
>     This could be tough. ...

This is the easy part.  Rob Cook wrote a paper on stochastic sampling
the screen pixel positions for antialiasing, the position of finite 
width light sources for shadow penumbras, object positions in time for
motion blur, and aperture position for depth of field.  So all you
have to do is sample the frequency of light.  
You fire say 16 rays per pixel anyway to do
antialiasing, and assign each one a color (frequency).  When the ray
is refracted through an object, take into account the index of
refraction and apply Snell's law.  A student here did that
and it worked fine.  He simulated rainbows and diffraction effects
through prisms.  What he couldn't do is to shine a light through a
prism and cast a spectrum on a surface.  But the sectrum is just a
special case of a caustic, so if you do secondary illumination it will
work.

	(Spencer Thomas (U. Utah, or is it U. Mich. now?) also implemented 
the same sort of thing at about the same time.  (Oh yeah?  Well I
thought about doing it a year before that :^)... sure)

>
>>	Something tells me that all three questions are rather hard.
>
>Nah. They were easy.

Please show us how the first two are easy.  Sorry if I sound overly
cynical, but I don't see how it falls out naturally without sending
out test rays to search for secondary illumination.  If you really can
do this, by all means let us know.  The world anxiously awaits.

Robert Skinner
skinner@saturn.ucsc.edu
-- 
----
this is a test