Return-Path: <71530.2536@compuserve.com>
Received: from aerospace.aero.org by antares.aero.org (4.1/AMS-1.0)
	id AA15778 for  /u/strauss/bin/mail_handler.pl strauss; Tue, 8 Dec 92 21:39:08 PST
Received: from ihb.compuserve.com by aerospace.aero.org with SMTP (5.65c/6.0.GT)
	id AA14990 for strauss@antares.aero.org; Tue, 8 Dec 1992 21:39:02 -0800
Posted-Date: 09 Dec 92 00:33:05 EST
Received: by ihb.compuserve.com (5.65/5.910516)
	id AA05953; Wed, 9 Dec 92 00:38:59 -0500
Date: 09 Dec 92 00:33:05 EST
From: Malcolm Blanchard <71530.2536@compuserve.com>
To: Blind Copy List:@compuserve.com;
Subject: shadows
Message-Id: <921209053305_71530.2536_DHM55-1@CompuServe.COM>
X-Filed: misc

I've just joined the list, so forgive me if I'm repeating information that
has been passed around already.  The first message I received was someone
theorizing that there were people who have created shadows with RenderMan, but
there was some question in the poster's mind that these people might be a
modern-day echo of the unicorn myths.  I am here to testify that it can be
done.  In fact, I've done it many times, though it's been a couple of years.
Here's the steps from my faultering memory:

1. "Render" the image from the point of view of the light source and create
   a "Z" file.  The file is a special format, not a TIFF file. The 'type'
   to specify to RiDisplay is RI_FILE and the 'mode' is RI_Z. For the sake
   of efficiency, you should remove all shaders except for displacement
   shaders (unless you think they won't make a difference).  You should also
   remove all geometry that doesn't cast shadows, e.g. floors, walls, and
   backdrops.

   For a distant light you should use an orthographic projection.  For a spot
   light you should use a perspective projection with a field of view
   corresponding to the angle of the light. For point lights, you should think
   very long and hard (you'll need to create several Z files and select between
   their corresponding shadow files in the light shader--it can be done, but
   Don Schreiter, at Pixar, is the only person I've known to accomplish this).

2. Create a "shadow" file with RiMakeShadow.  This, again, is a special format.

3. Use the "shadow" file in a light shader that explicitly uses a shadow, i.e.
   the shader must make a call to the "shadow" operator.

This should get you basic shadows.  There is a problem with "self-shadowing"
in Photorealistic RenderMan. Due to round-off errors, it is possible for an
object to shadow itself.  The work-around is to to use RiOption to set two
"shadow" values called "bias0" and "bias1" when you render the final scene.
These are mysterious values that cause shadows to be slightly offset from the
objects casting them. The two values specify a stochastic range for the offset.

They should be set to something like one percent of the diameter of the model
you're rendering.  Make them too large and the shadow will be offset
sufficiently to make it look as if objects are floating; too small and you'll
get self-shadowing.

You should also watch out for shadow-casting lights that just graze a flat
surface, e.g. a light that is on a wall and shines along it.  The whole z-map
technique tends to fall apart in this situation, so there really isn't much
you can do about it other than to avoid it.

Pixar has an application note dealing with creating shadows. "PhotoRealistic
RenderMan Application Note #15 -- Making Shadows with RenderMan."  It's part
of their Developer's Stuff package.  Maybe if someone had the disk space and
they asked Pixar nicely, these notes might be made available via ftp.  Just a
thought.

-Malcolm Blanchard
71530.2536@@compuserve.com

