Project 3 Help Session


This session is to help you get started with the third project: a raytracer.


Starting the Project

After copying the files from course web page, the ray trace program can be run by typing double clicking the .dsw project file and building the project in MSVC. This raytracer reads files with the .out file extension. Load a scene such as simple.out and hit the render button to see how the basic program works. Note that the size of the render window is adjustable. The smaller your window, the quicker the scene will render. The sphere and box in the scene should appear as flat disks when rendered, since the routines that compute the color of each pixel have been gutted for your educational benefit.


Useful Files

This program has quite a few source files associated with it, but don't be alarmed, because most of your of your work on this project will be concentrated in only a few files. In fact, all of the required extensions require modifying only the Shade() function in Raytrace.cpp. Here are a list of some of the most important of the files:


Shade() Function

The function in which you will implement all the required extensions is the Shade function in Raytrace.c:
Void
Shade(SceneIO *scene, int level, float weight, Vector3f P, Vector3f N,
	Vector3f I, struct IsectType *intersect, Vector3f color,
RTParameters* g_params);
This function calculates the color of an intersection point of a ray that is cast into the scene.


MaterialIO

The struct MaterialIO contains information about the properties of an intersection point on an object. The comments following the elements of the struct contain the symbols used in the Phong shading model presented in class.
typedef struct MaterialIO
{
	Color3f diffColor;  /* Diffuse color: kd */
	Color3f ambColor;   /* Ambient color: ka */
	Color3f specColor;  /* Specular color: ks */
	Color3f emissColor; /* Emissive color- do not need for assignment */
	float shininess;    /* Shininess: ns */
	float ktran;        /* Transparency: ktran */
} MaterialIO;


Ray

This struct contains the information about the ray cast by the intersection routine.
typedef struct Ray
{
	Point3f P;         /* point of origin of the ray */
        Point3f D;         /* direction ray is traveling */
} Ray;


RTParameters

This struct contains information used for recursion.
typedef struct RTParameters
{
	float rayeps;      /* epsilon value for ray intersections */
	float minweight;   /* min weight to keep tracing a ray - 
		Note: this may be used to implement one of the whistles */
	float maxlevel;    /* max number of tracing levels - 
		Note: max level can be 4 for the basic assignment */
} RTParameters;


Additional Information


Send questions or comments about the help session and handouts to Doug (dougz@cs) or Michael(maucoin@cs).