DOC PREVIEW
MIT 6 837 - Ray Tracing and Phong Materials

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

6.837 Introduction to Computer GraphicsAssignment 3:Ray Tracing and Phong MaterialsDue Wednesday October 1, 2003 at 11:59pmThis week, we add local and global illumination to our Ray Caster. Becausewe cast secondary rays to account for shadows, reflection and refraction, we nowcall it a Ray Tracer.We clean up and improve shading calculation (local illumination). We definean abstract material class and derive a Phong Material class that implements adiffuse and a specular component (highlight).You will encapsulate the high-level computation in a RayTracer class thatwill be responsible for sending rays and recursively computing colors along them.To compute cast shadows, you will send rays from the visible point to thelight source. If an intersection is reported, the visible point is in shadow andthe contribution from that light source is ignored. Note that shadow rays mustbe sent to all light sources.You will add reflection and refraction effects. For this, you need to send sec-ondary rays in the mirror and transmitted directions, as explained in class. Thecomputation is recursive to account for multiple reflections and or refractions.1 Tasks• Implement an abstract Material class and derive a PhongMaterial classthat computes Phong shading.• Update your intersection routines to return the Material of the intersectedobject, instead of just a simple color.• Create a new class RayTracer that computes radiance (color) along a ray.Update your main function to use this class for the rays through eachpixel.• Treat the case of multiple light sources by accumulating shading contri-butions for all light sources.• Compute cast shadows by sending rays toward the light sources.1• Compute perfect mirror reflection by sending rays recursively in the mirrordirection.• Compute transparency effects by sending rays recursively in the refracteddirection.• Provide a README.txt file that discusses any problems you encountered,how long it took to complete the assignment, any extra credit work thatyou did and how we can test the new features.• Extra credit: semi-transparent shadows where the attenuation depends onthe distance traveled in the transparent object; nested refracting materials;shadow ray acceleration using early termination and without returning thenormal and material; Fresnel reflection term; other BRDF models such asCook-Torrance or Ward; anisotropic BRDFs; solid textures.2 Classes you need to update/writeThe Object3D and Hit classes must now store more detailed information aboutthe properties of the surface, encapsulated in a Material class. You mustupdate your Object3D class (and the constructors of all subclasses) to replacethe color by a pointer to a Material. You must also update your intersectionroutines so that they return a pointer to a Material and not a color in case ofan intersection.2.1 Material and PhongMaterialThe Material class has a pure virtual method Shade that computes the localinteraction of light and the material. It takes as input the viewing ray, the Hitdata structure, and light information.virtual Vec3f Material::Shade(const Ray &ray, const Hit &hit, const Vec3f &dirToLight,const Vec3f &lightColor) const = 0;In addition to the diffuse object color used in the last assignment, theMaterial class stores information about transparency and reflection. It muststore two colors for the reflection and transparency coefficients, and an index ofrefraction. You must implement accessor functions for these fields.Material::Material(const Vec3f &diffuseColor,const Vec3f &transparentColor,const Vec3f &reflectiveColor,float indexOfRefraction);You must derive a subclass PhongMaterial that computes shading usingboth a diffuse and specular term. The class takes as additional parameters aspecular color and a scalar exponent. The constructor expected by the parseris:2PhongMaterial::PhongMaterial(const Vec3f &diffuseColor,const Vec3f &specularColor,float exponent,const Vec3f &transparentColor,const Vec3f &reflectiveColor,float indexOfRefraction);Implement the PhongMaterial::Shade function using the version of thePhong model taught in class based on the angle between the eye ray and thereflected ray.2.2 RayTracerThe RayTracer class encapsulates the computation of radiance (color) alongrays. It stores a pointer to the SceneParser for access to the geometry andlight sources. The constructor is:RayTracer(SceneParser *s, int max_bounces, float min_weight);The main method of this class is traceRay that, given a ray, computes thecolor seen from the origin along the direction. This computation can be recur-sive because of reflection and refraction. We therefore need a stopping criterionto prevent infinite recursion. traceRay takes as additional parameters the cur-rent number of bounces (recursion depth) and a ray weight that indicates howmuch the contribution will be dimmed in the final image. The correspondingmaximum recursion depth and the minimum ray weight are fields of RayTracer,which are passed as command line arguments to the program. Note that theweight is a scalar that corresponds to the magnitude of the color vector.Vec3f traceRay(Ray &ray, float tmin, int bounces,float weight, float indexOfRefraction, Hit &hit) const;First, implement traceRay so that it computes the closest intersection withthe scene and performs shading. For ambient lighting, you should use thegetDiffuseColor method of the Material pointer stored by Hit and mul-tiply it by the ambient light of the SceneParser. Add the contributions ofthe light sources in the scene by iterating over the light sources stored by theSceneParser and call the Shade method of the Material.ShadowsNext, you need to implement cast shadows. Modify the code described above totest for each light whether the line segment joining the intersection point andthe light source intersects an object. If there is an intersection, then discard thecontribution of that light source. Recall that you must displace the ray originslightly away from the surface, or equivalently set tmin as . Note that in thisna¨ive version, semi-transparent objects still cast opaque shadows. Implementsomething better for extra credit.3Mirror reflectionYou will then implement mirror reflection. This involves the use of secondaryrays in the direction symmetric with respect to the normal. If the material isreflective (getReflectiveColor() > (0,0,0)), then you must create a new raywith origin the current intersection point, and direction the mirror direction.For


View Full Document

MIT 6 837 - Ray Tracing and Phong Materials

Documents in this Course
Shadows

Shadows

64 pages

Animation

Animation

37 pages

Radiosity

Radiosity

25 pages

Color

Color

86 pages

InterArch

InterArch

14 pages

Color

Color

15 pages

Animation

Animation

61 pages

Luxo Jr

Luxo Jr

14 pages

Animation

Animation

52 pages

Radiosity

Radiosity

37 pages

Load more
Download Ray Tracing and Phong Materials
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Ray Tracing and Phong Materials and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Ray Tracing and Phong Materials 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?