ray tracing assignment
play

Ray Tracing Assignment Goal is to reproduce the following So You - PDF document

Ray Tracing Assignment Goal is to reproduce the following So You Want to Write a Ray Tracer Checkpoint 3 Basic Shading Whitted, 1980 Ray Tracing Assignment Ray Tracing Assignment Seven checkpoints Seven checkpoints 1.


  1. Ray Tracing Assignment • Goal is to reproduce the following So You Want to Write a Ray Tracer Checkpoint 3 – Basic Shading Whitted, 1980 Ray Tracing Assignment Ray Tracing Assignment • Seven checkpoints • Seven checkpoints 1. Setting the Scene 1. Setting the Scene 2. Camera Modeling 2. Camera Modeling 3. Basic Shading 3. Basic Shading 4. Procedural Shading 4. Procedural Shading 5. Recursive Ray Tracing – Reflection 5. Recursive Ray Tracing – Reflection 6. Recursive Ray Tracing – Transmission 6. Recursive Ray Tracing – Transmission 7. Tone Reproduction 7. Tone Reproduction Basic Shading Illumination Models • Add Phong Illumination to your ray tracer. • Geometry – On intersection N V H • Rather than return color of object hit viewer normal • Calculate color at intersection point using Phong Half-way Illumination model R S reflection source 1

  2. Illumination Models Phong Model • Geometry • Phong Model – N - normal vector – introduces specular (mirror-like) reflections – S - direction of incoming light – Viewer direction becomes more important – R - direction of perfect mirror reflection – three components • ambient - background light (k a ) – H - halfway between light direction and viewing direction. • diffuse - Lambertian reflection (k d ) • specular – mirror-like reflection(k s ) – V - viewing direction. Phong Model Illumination Models • Recall from Linear Algebra u θ v • = θ u v u v cos ∑ ∑ = + • + • k L ( V ) k L k L ( S N) k L ( R V) e a a d i i s i i i i ambient Just one reason to normalize! diffuse specular Note: L n are radiance terms, include both light and material info Parameters to add Parameters to add • To your world: • To each object – Phong parameters – Ambient light – background light (r,g,b) • ambient - background light (k a ) • To the light source • diffuse - Lambertian reflection (k d ) • specular – mirror-like reflection(k s ) – Color (r,g,b) gives intensity and chroma. • exponent – controls size of specular highlight (k e ) – Object “color” • ambient / diffuse color – basic color of object • Specular color – color of specular highlight (white usually) 2

  3. Phong Model Vectors you will need • Point of intersection – Get from intersection calculation • N - normal vector – Get from intersection calculation • S - direction of incoming light – Light position – point of intersection Ambient light color x light source color x light source color x – Shadow ray: Need to know if we can see the light ambient object color diffuse object color specular object color • R - direction of perfect mirror reflection ∑ ∑ = + • + • – On next slides k L ( V ) k L k L ( S N) k L ( R V) e a a d i i s i i • V - viewing direction. i i ambient – Camera position – point of intersection diffuse specular • NORMALIZE ALL VECTORS Only apply if you can see the light from point of intersection! Calculating Reflection Reflection Reflection a a Angle of incidence of ray = Angle of reflectance n Perfect mirror surface θ θ S i r r θ θ i r where S is the ray from the d r • S n intersection point to the light = + = − r S 2a S 2 n 2 source, r is the reflected ray, n and θ r equals θ i For derivation, see http://astronomy.swin.edu.au/~pbourke/geometry/reflected. Applying Phong Basic Shading • If there is an intersection • Due date: – Must be posted to Web site by Midnight April 7 th . – Calculate ambient component – Get the point of intersection (P) – Spawn a shadow ray from P to the light source – Recall: – If the ray reaches the light before any other object • 10% penalty per day – Having trouble? • Obtain N, V, S, and calculate R • Calculate specular and diffuse components • Let me know EARLY. • Add to ambient componet • Questions? – Return resultant color. 3

Recommend


More recommend