<html>
<head>
<title>
Project 1 Help Session: Notes from the TA
</title>
</head>
<body>
<h1>
Project 1 Help Session
</h1>
CS 348B - Computer Graphics: Image Synthesis Techniques<br>
Spring Quarter, 1997<br>
Mark Levoy<br>
TA:  Lucas Pereira <br>

<h3> Note </h3>
If you are taking the class for credit (especially SITN students), 
please check 
<a href="http://www-graphics.stanford.edu/courses/cs348b-97/students.html">
http://www-graphics.stanford.edu/courses/cs348b-97/students.html </a>
and make sure that we have received your questionnaire.  If you are not
on the list, please fill out the online questionnaire:
<a href="http://www-graphics.stanford.edu/courses/cs348b-97/questionnaire_form.html">
http://www-graphics.stanford.edu/courses/cs348b-97/questionnaire_form.html
</a>.

<h3> Outline </h3>

<ul>
<li> Assignment overview
<li> The /usr/class/cs348b tree
<li> Going from the xsupport example program to a working raytracer
	<ul>
        <li> what's provided: example.c
        <li> what you have to write
        <li> composer constants
	</ul>
<li> Modeling demo:  i3dm -> composer -> your raytracer 
<li> Questions
</ul>

<h3> Assignment overview </h3>

<ul>
<li> Inspiration:  renderings from previous years:
<ul>
	<li> <a href="http://www-graphics.stanford.edu/courses/cs348b-competition/cs348b-92">Winter, 1992</a>
	<li> <a href="http://www-graphics.stanford.edu/courses/cs348b-competition/cs348b-93">Winter, 1993</a>
	<li> <a href="http://www-graphics.stanford.edu/courses/cs348b-competition/cs348b-94">Winter, 1994</a>
	<li> <a href="http://www-graphics.stanford.edu/courses/cs348b-competition/cs348b-95">Winter, 1995</a>
	<li> <a href="http://www-graphics.stanford.edu/courses/cs348b-competition/cs348b-96">Spring, 1996</a>
	</ul>
<li> Images for this project
<li> <a href="http://www-graphics.stanford.edu/courses/cs348b-97/proj1.html">
	Project Assignment (HO #7) </a>
	<ul>
	<li> C or C++:
		<ul>
		<li> Either is fine
		<li> If C++, don't overdo the classes for vector math, since speed is an issue in proj2
		</ul>
	<li> Read the README files in /usr/class/cs348b/</li>
	<li> Only need to handle spheres and triangles
	<li> Assume one material per face
	<li> Per-vertex normals optional
	</ul>
</ul>

<h3> The /usr/class/cs348b tree </h3>
<ul>
<li>README
<li>README.composer
<li>README.submit
<li>README.xsupport
<li>README.porting
<li>bin/
<li>example/
	<ul>
	<li> (start here -- copy to your directory)
	<li> (uses scene_io and xsupport)
	</ul>
<li>include/
	<ul>
	<li> scene_io.h
	<li> xsupport.h
	</ul>
<li>init/
	<ul>
	<li> (source init.csh)
	</ul>
<li>lib/
	<ul>
	<li> XXX/libxsupport.a
	</ul>
<li>proj1/
	<ul>
	<li> README
	<li> tests/
		<ul>
		<li> README
		<li> testx.iv
		<li> testx.out
		<li> testx.rgb
		</ul>
	</ul>
<li>resources/
	<ul>
	<li> XXX/Xresources (used by cs348b/init/init.csh)
	</ul>
<li>tools/
	<ul>
	<li> composer/ (includes source code)
	<li> iv2out/   (ignore)
	<li> out2out/  (ignore) 
	<li> soft2out/ (ignore)
	</ul>
<li>useful-code/
	<ul>
	<li> README
	<li> (Graphics Gems vector and matrix algebra routines)
	</ul>
<li>xsupport/
	<ul>
	<li> obj/
	<li> src/
		<ul>
		<li> (Source to recompile xsupport, to run on other platforms)
		<li> (Uses Motif widget library)	
		</ul>
	</ul>
</ul>


<h3> Going from the xsupport example program to a working raytracer </h3>
<ul>
<li> <b> What's provided: example.c </b>
	<ul>
	<li> Demonstrates widgets for your control box
	<li> Starts with two Canvases
	<li><code>ReadComposer()</code> and <code>LoadScene(char *name) </code>
		<ul>
		<li> Reads scene (e.g. testx.out)
			<ul>
			<li> (see /usr/class/cs348b/include/scene_io.h
				for data structures)
			<li> structures: SceneIO, CameraIO, LightIO,
				ObjIO, MaterialIO, VertexIO, PolygonIO

			</ul>
		<li> writes scene out in ASCII (to verify it)
		<li> deletes the scene
		</ul>
		<li> <code> LoadPPM() </code>
		<li> <code> SavePPM() </code>

		<li> <code> main() </code>
			<ul>
			<li> Initialize Canvases
			<li> Calls <code> LiftOff() </code>
				<ul>
				<li> After this, user events trigger 
					callback functions
				</ul>
			</ul>
		</ul>
		
<li> <b> What you have to write </b>
	<ul>
	<li> Modify control widgets to do meaningful things, such as
		control ray tree depth and image size
	<li> Modify <code>ReadComposer()</code> and 
	<code>LoadScene(char *name) </code> so that you don't delete the scene
		immediately
	<li> Write <code> Render()</code>
		<ul>
		<li> raytrace the scene to the canvas image buffer
		<li> <code> UpdateCanvas()</code>, so you can see the image
		</ul>
	</ul>
<li> <b> Composer constants </b>
	<br>(from README.composer)
	<ul>
	<li> Whitted's Eqn (16.55 of FvDH): <br>
		I = k<sub>a</sub> I<sub>a</sub> O<sub>d</sub> +
		<b>Sum<sub>i</sub> ( </b>
		S<sub>i</sub> f<sub>atti</sub> I<sub>pi</sub> [
		k<sub>d</sub> O<sub>d</sub> (<b>N</b>*<b>L</b><sub>i</sub>) +
		k<sub>s</sub> (<b>N</b>*<b>H</b><sub>i</sub>)<sup>n</sup> ]
		<b> ) </b> +
		k<sub>s</sub> I<sub>r</sub> + k<sub>t</sub> I<sub>t</sub>
		
	<li> (k<sub>d</sub>*O<sub>d</sub>) is given by "diffColor"
	<li> Composer outputs a single "ambient color", whereas the ambient
		term in Whitted's equation is given by k<sub>a</sub> 
		I<sub>a</sub> O<sub>d</sub>.  We suggest treating the 
		ambient color you get from Composer as I<sub>a</sub> and 
		multiplying it by the diffuse color K<sub>d</sub>
		O<sub>d</sub> to get your ambient term.
	<li>For (semi-)transparent surfaces, you should probably multiply
   		the diffuse and ambient terms by (1-k<sub>t</sub>).  
		Otherwise, the diffuse and transmitted rays will add up, 
		and the surface will become washed-out. 
	<li>k<sub>s</sub> is given by "specColor". Note that the latter 
	 	is a vector which has all three values identical. This 
		value is k<sub>s</sub>. The redundancy is being maintained 
		for historical reasons.
	<li>For assignment 1, always use a refractive index of 1.5 where 
		applicable.
	<li>Ignore the emissive component output by composer.
	<li>For <sup>n</sup>, use shininess*128 (where shininess is composer's 
		shininess output between 0 and 1).
	<li>For f<sub>att</sub> (attenuation of light sources), 
		use FvDFH equation 16.8
		( f<sub>att</sub> = min(1, 1 / (
		c<sub>1</sub> + c<sub>2</sub> d<sub>L</sub> +
		c<sub>3</sub> d<sub>L</sub><sup>2</sup>
		) ), with 
		c<sub>1</sub> = 0.25, c<sub>2</sub> = 0.1 and c<sub>3</sub> 
		=  0.01. (If your results don't look satisfactory to you, 
		feel free to play with this parameter). Secondary 
		rays (reflected and transmitted rays) are not attenuated.
	<li> Use an aspect ratio of 1 for the screen. 
	<li> The ambient colors and headlight strength output by Composer may 
   		be scaled such that if you blindly implement Whitted's 
		equation, your scenes may appear washed out.  Scale these 
		factors until your ray traced image looks roughly similar 
		to the sample images in /usr/class/cs348b/proj1/tests.

</ul>

<h3> Modeling demo:  i3dm -> composer -> your raytracer  </h3>


<h3> Questions </h3>


<p>
<hr>
<address>
lucasp@cs.stanford.edu
</address>
<b>Copyright &copy; 1997 Marc Levoy</b>
<br>
Last update: Friday, 11-Apr-97 
</body>
</html>
