Return-Path: <strauss@aero.org>
Received: from aerospace.aero.org by antares.aero.org (4.1/AMS-1.0)
	id AA28546 for  /u/strauss/bin/mail_handler.pl strauss; Wed, 9 Dec 92 18:23:00 PST
Received: from antares.aero.org by aerospace.aero.org with SMTP (5.65c/6.0.GT)
	id AA05787 for strauss@antares.aero.org; Wed, 9 Dec 1992 18:22:57 -0800
Posted-Date: Wed, 09 Dec 92 18:22:53 PST
Message-Id: <199212100222.AA05787@aerospace.aero.org>
Received: from altair.aero.org by antares.aero.org (4.1/AMS-1.0)
	id AA28543 for rman@aero.org; Wed, 9 Dec 92 18:22:56 PST
To: rman@aero.org
Subject: How to do shadows
Date: Wed, 09 Dec 92 18:22:53 PST
From: strauss@aero.org


Friends,
	Shadows really aren't that hard in RenderMan. It is true that
you need to create a shadow file for each light that will produce
shadows. That means you render a scene multiple times. What you need to
do is position the camera in the same location and orientation as that
of your light source. Then you use the camera to generate a depth file
which essentially indicates which objects are illuminated by your light.
Then you translate that depth file into a texture map. Finally you
generate your scene using a light source that includes shadows. Here's
some example RIB code:

----- 
sample.rib: This is my basic scene. A floor plane with a sphere on it
and one light source
-----
# A simple Renderman scene
Display "sample.tiff" "file" "rgb"
Format 256 256 1
Projection "perspective" "fov" 40
Rotate 55 1 0 0
Translate 0 5 5
WorldBegin
LightSource "mylight" "distantlight" "intensity" 1.5 "from" [1 -1 -5] 
	"to" [0 0 0]
Color .5 .5 .5
Surface "matte"
Sphere 1 -1 1 360
Color .75 .75 .75
Patch "bilinear" "P" [-5 2 -5  -5 2 5  5 2 -5  5 2 5]
WorldEnd

-----
generateshadow.rib: This is the rib to create the shadow for the given
light. I've moved the camera to the light's location and I make a shadow
texture map.
-----
# A simple Renderman scene
Display "shadow.pic" "zfile" "z"
Format 256 256 1
Projection "perspective" "fov" 40
Rotate 11 1 0 0
Rotate 11 0 1 0
Translate -1 1 5
WorldBegin
Color .5 .5 .5
Sphere 1 -1 1 360
Color .75 .75 .75
Patch "bilinear" "P" [-5 2 -5  -5 2 5  5 2 -5  5 2 5]
WorldEnd

MakeShadow "shadow.pic" "shadow.tx"

-----
sampleshadow.rib: Finally I go back to my original rib and I change the
distantlight to shadowdistant (the shader with shadows)
-----
# A simple Renderman scene
Display "sample.tiff" "file" "rgb"
Format 256 256 1
Projection "perspective" "fov" 40
Rotate 55 1 0 0
Translate 0 5 5
WorldBegin
Declare "intensity" "float"
Declare "from" "point"
Declare "to" "point"
Declare "shadowname" "string"
LightSource "mylight" "shadowdistant" "intensity" 1.5 "from" [1 -1 -5] 
	"to" [0 0 0] "shadowname" "shadow.tx"
Color .5 .5 .5
Surface "matte"
Sphere 1 -1 1 360
Color .75 .75 .75
Patch "bilinear" "P" [-5 2 -5  -5 2 5  5 2 -5  5 2 5]
WorldEnd

-----

Voila. A scene with a shadow. Not so hard really, once you know the
process.

						- |Daryll


