1 / 11

Project 3 Help Session:

Project 3 Help Session:. Ray Tracing. Getting Started. Download the starter pack. sample_ray.exe ray-skel directory scenes directory Look at the Road Map Try tracing some scenes with sample_ray.exe. Scenes. Examples (in scenes/simple/) Syntax (and how to extend the parser).

haslam
Download Presentation

Project 3 Help Session:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Project 3 Help Session: Ray Tracing

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

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

  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: • 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 refraction • Remember Snell’s Law? • How can you use the normal to determine whether you are entering or exiting?? nair=1.00029 nglass=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

More Related