computer graphics (fall 2003)
DESCRIPTION
Computer Graphics (Fall 2003). COMS 4160, Lecture 17: Ray Tracing Ravi Ramamoorthi. http://www.cs.columbia.edu/~cs4160. The Internet Ray Tracing Competition: http://www.irtc.org. Image courtesy Paul Heckbert 1983. Effects needed for Realism. Shadows - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/1.jpg)
Computer Graphics (Fall 2003)
COMS 4160, Lecture 17: Ray Tracing Ravi Ramamoorthi
http://www.cs.columbia.edu/~cs4160
The Internet Ray Tracing Competition: http://www.irtc.org
![Page 2: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/2.jpg)
Image courtesy Paul Heckbert 1983
![Page 3: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/3.jpg)
Effects needed for Realism
• Shadows• Reflections (Mirrors)• Transparency • Interreflections• Detail (Textures etc.)• Complex Illumination• Realistic Materials• And many more
![Page 4: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/4.jpg)
Turner Whitted 1980
![Page 5: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/5.jpg)
Ray Tracing: History
• Appel 68• Whitted 80 [recursive ray tracing] (picture)
– Landmark in computer graphics
• Lots of work on various geometric primitives• Lots of work on accelerations• Current Research
– Real-Time raytracing (historically, slow technique)
– Ray tracing architecture
![Page 6: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/6.jpg)
The Pinhole Camera
Image plane Pinhole
Illustration courtesy Greg Humphries
![Page 7: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/7.jpg)
Ray Casting
![Page 8: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/8.jpg)
Ray Tracing
• Shoot rays through pixels into the world
• For each pixel,– Find closest intersection in scene– Evaluate illumination model to color pixel
![Page 9: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/9.jpg)
Comparison to Scan-Line
• Per-pixel evaluation, per-pixel rays (not scan-convert each object). On face of it, costly
• More complex shading, lighting effects possible
![Page 10: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/10.jpg)
Ray paths
• LR*E
• Arbitrary paths: realism
• Trace from light or eye?– Most light rays don’t hit
eye
– Importance sampling
• Eye Ray tracing– Primary Rays
– Shadow Rays
– Reflected/Transmitted Rays
Appel 68
![Page 11: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/11.jpg)
Recursive Ray Tracing
For each pixel– Trace Primary Ray, find intersection– Trace Shadow Ray(s) to light(s)
• Color = Visible ? Illumination Model : 0 ;
– Trace Reflected Ray• Color += reflectivity * Color of reflected ray
![Page 12: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/12.jpg)
Shadow Rays
• How much light is reaching point P?• Fire a shadow ray towards each light in the scene• Numerical problems?
AB
S
P
![Page 13: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/13.jpg)
Problems with Recursion
• Reflection rays may be traced forever
• Generally, set maximum recursion depth
• Same for transmitted rays (take refraction into account)
![Page 14: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/14.jpg)
Ray/Object Intersections
• Heart of Ray Tracer– One of the main initial research areas
– Optimized routines for wide variety of primitives
• Various types of info– Shadow rays: Intersection/No Intersection
– Primary rays: Point of intersection, material, normals
– Texture coordinates
• Work out examples– Triangle, sphere, general implicit surface
![Page 15: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/15.jpg)
More on Intersections
• Basic Algorithm– Test each object for intersection– Sort objects to find closest one– Trace shadow ray. If unblocked, compute
illumination
• Issues– Precision: self shadowing – Aliasing, Supersampling– Stochastic, Jittered sampling
![Page 16: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/16.jpg)
Precision• Floating point calculations are imprecise!• Often, a ray’s origin is supposed to be on a
surface, but this might happen:
• Typical hack is to only allow t values above some small threshold, like .0000001
![Page 17: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/17.jpg)
Comparisons
• Scan Conversion vs. Ray tracing– Ray tracing is (has been) much much slower
• Is this still true if number of objects large? Fractals?
• Acceleration structures (next), but still very slow usually
– Realism in imagery• Reflections, Refractions, soft shadows, complex lighting,
shading trivial in ray tracing. In scan conversion?
– Future?• Currently OpenGL uses scan conversion
• Real-Time raytracing? (already possible)
• Ray Tracing architecture (research at Stanford)
![Page 18: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/18.jpg)
Acceleration
• Testing each object for each ray is slow– Fewer Rays
• Adaptive sampling [HW] , depth control
– Generalized Rays• Beam tracing, cone tracing, pencil tracing etc.
– Faster Intersections• Optimized Ray-Object Intersections
• Fewer Intersections
![Page 19: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/19.jpg)
Acceleration Structures
• Reducing number of intersections– Bounding Volume hierarchy– If no intersection with bounding box, needn’t
check objects
• Grids– Uniform, Hierarchical
• Spatial Hierarchies– Oct-trees, kd trees, BSP trees
![Page 20: Computer Graphics (Fall 2003)](https://reader035.vdocuments.us/reader035/viewer/2022062314/56814012550346895dab564e/html5/thumbnails/20.jpg)
Acceleration Structures