Description
Assignment 2
• Part B (Assignment 2): You will extend the program in Part A to produce an image which contains the following shading effects:
1. Lighting: The lighting is calculated with the Phong lighting model.
2. Shadow: Trace a ray from the surface to the light position to determine if it is in the shadow. Keep the ambient component but ignore the diffuse and specular components for shadowed areas.
3. Reflection: Compute the reflection direction and trace a ray recursively if the material is reflective (i.e. the ratio of reflection is non-zero).
• The format of the input file is modified to include the following:
✓ Eye position: E x y z
✓ View direction: V Dx Dy Dz Ux Uy Uz
✓ Field of view: F angle
✓ Resolution: R w h
✓ Sphere: S Ox Oy Oz r
✓ Triangle: T x1 y1 z1 x2 y2 z2 x3 y3 z3
✓ Light position: L x y z
✓ Material: M r g b Ka Kd Ks exp Reflect
where (r, g, b) is the surface color; Ka, Kd, Ks are the coefficients of the ambient, diffuse, and specular components; exp is the specularity; Reflect is within the range of [0, 1] and represent the ratio of reflection.
• Please name your programs “hw2” and submit it on Moodle
(https://moodle3.ntnu.edu.tw/course/view.php?id=29630). If you submit multiple files, then please pack your source files in a single ZIP or RAR file for the upload.
Reviews
There are no reviews yet.