Presentation is loading. Please wait.

Presentation is loading. Please wait.

Project 3 Help Session: Ray Tracing. Getting Started Download the starter pack. 1.sample_ray.exe 2.ray-skel directory 3.scenes directory Look at the Road.

Similar presentations


Presentation on theme: "Project 3 Help Session: Ray Tracing. Getting Started Download the starter pack. 1.sample_ray.exe 2.ray-skel directory 3.scenes directory Look at the Road."— Presentation transcript:

1 Project 3 Help Session: Ray Tracing

2 Getting Started Download the starter pack. 1.sample_ray.exe 2.ray-skel directory 3.scenes directory Look at the Road MapRoad Map Try tracing some scenes with sample_ray.exe

3 Scenes Examples (in scenes/simple/)Examples Syntax (and how to extend the parser)Syntax

4 Materials emissive: ke, the emissive color. ambient: ka, the ambient color. specular: ks, the specular color. reflective: kr, the reflective color. Defaults to ks if not specified. diffuse: kd, the diffuse color. transmissive: kt, the ability for this material to transmit light in each channel (as a 3-tuple). shininess: ns, the shininess (between 0 and 1). index: the material's index of refraction.

5 Casting Rays Two steps: 1.Create the ray. ray r( Vec3d(0,0,0), Vec3d(0,0,0),ray::VISIBILITY ); 2.Then cast it by calling traceRay(r). isect i; // an intersection object. if( scene->intersect( r, i ) ) { // There was an intersection with an object in the scene. // Do something with i. (Perhaps cast more rays from the point // of intersection. }else{ // There is no intersection, the ray is shot into the black void of space. }

6 ray Class ray r (start position, direction, RayType) enum RayType{VISIBILITY, REFLECTION, REFRACTION, SHADOW}; r.at(t), a method that determines the position of the ray r as a function of t, the distance from the start position.

7 isect Class An isect represents the location where a ray intersects a specific object. Important member variables: const SceneObject *obj; // the object that was intersected. double t; // the distance along the ray where it occurred. Vec3d N; // the normal to the surface where it occurred Vec2d uvCoordinates; // texture coordinates on the surface. [1.0,1.0] Material *material; // non-NULL if exists a unique material for this intersect. const Material &getMaterial() const; // return the material to use *red ones are important

8 The Skeleton Code Intersection for boxes and spheres is missing. (Box::intersectLocal()) Implement the Phong shading model. (Material::shade()) Implement recursive ray tracing! This includes Shadow Attenuation, Reflection, Refraction, and Antialiasing. ( RayTracer::traceRay())

9 intersectLocal() The ray and object are transformed back to the origin. Only write intersect code for the geometry in canonical form! (i.e. the unit sphere and the box extending 0.5 in all directions.)

10 The Complexities of Refraction Indices of refractionIndices Remember Snell’s Law?Snell’s Law How can you use the normal to determine whether you are entering or exiting?? n air =1.00029 n glass =1.5

11 RAY_EPSILON To avoid round-off error, add RAY_EPSILON (=0.0001) to the start position of rays fired from points of intersection. given isect i and ray r: new_position = r.at(i.t + RAY_EPSILON) RAY_EPSILON


Download ppt "Project 3 Help Session: Ray Tracing. Getting Started Download the starter pack. 1.sample_ray.exe 2.ray-skel directory 3.scenes directory Look at the Road."

Similar presentations


Ads by Google