1 / 27

Raytracing and Global Illumination

Raytracing and Global Illumination. R. Hoetzlein. Rasterization vs. Raytracing. project. cast. Rasterize: - Project polygons onto picture plane - Efficient hardware. OpenGL, DirectX. Raytrace: - Cast light rays into scene through picture plane. Ray-Sphere Intersection. R. 0. r. p.

janice
Download Presentation

Raytracing and Global Illumination

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. Raytracing and Global Illumination R. Hoetzlein

  2. Rasterization vs. Raytracing project cast Rasterize: - Project polygons onto picture plane- Efficient hardware. OpenGL, DirectX Raytrace: - Cast light rays into scene through picture plane.

  3. Ray-Sphere Intersection R 0 r p R dir p(t) = R + t R t > 0 Ray definition p: (x – xc) + (y – yc) + (z – zc) = r Sphere definition 0 dir 2 2 2 2 Solve for p: 2 2 2 A = Rx + Ry + Rz B = 2 * (Rx (Rx0–Sx) + Ry (Ry0-Sy) + Rz(Rz0-Sz) ) C = (Rx0–Sx) + (Ry0–Sy) + (Rz0–Sz) 2 A t + B t + C = 0 2 2 2

  4. Remember: Phong Illumination Model Ambientterm Diffuseterm Specularterm I total Total light received at surfaceka Ambient color of surface (RGB vector)I lightIntensity of light source (RGB vector)kd Diffuse color of surface (RGB vector)ks Specular color of surface (RGB vector)N Surface normal vector (normalized 3D)L Light direction vector (normalized 3D)R Reflection vector (normalized 3D)V Viewing direction vector (normalized 3D)

  5. Raytracing Illumination Model • What do we do when we hit an object? • Trace rays to each light source,and also new terms for reflected and refracted light

  6. First application of Raytracing: Rene Descarte, Geometry of Rainbows, 1641 - Rainbows are caused by refraction of light in a spherical water dropplet- Proved that rainbows always occur at 42 degs between viewer & sun

  7. Raytracing - History Turner Whitted An improved illumination model for shaded display Communications of the ACM, v.23 n.6, p.343-349, June 1980 ABSTRACTTo accurately render a two-dimensional image of a three-dimensional scene, global illumination information that affects the intensity of each pixel of the image must be known at the time the intensity is calculated. In a simplified form, this information is stored in atree of “rays” extending from the viewer to the first surface encountered and from there to other surfaces and to the light sources. Consideration of all of these factors allows the shader to accurately simulate true reflection, shadows, and refraction, as well as the effects simulated by conventional shaders.

  8. Monte Carlo Raytracing - Multiple rays per pixel = Anti-aliasing- Multiple rays per light = Soft shadows- Multiple rays per reflect = Diffuse reflections - Multiple rays per frame = Motion blur

  9. Inverse View Matrix p -1 p p’(x,y) = clip ( P V M p(x,y,z) ) = Proj View p -1 -1 -1 p = Cam Cam Proj p’(x,y) T R - Compute ray directions using Inverse Projection and Camera matrix- Loop over all pixels in image. Start with 3D ray extending from camera

  10. Inverse Projection Matrix x y p - Just draw a line from the origin to the pixel (x, y) - Where else have we see the Inverse Projection Matrix?

  11. What might be some limitations of raytracing?

  12. What might be some limitations of raytracing? • Performance • Light propagation - no caustics • Global Illumination – no global diffuse light • Memory – All geometry must fit in memory 10 million rays, simple scene Monsters, Inc. (Pixar) 13 hours per single frame,most of that is spent ray tracing individual hairs of fur.

  13. Raytracing PerformanceAssume image is: 1024 x 1024Assume scene is: 10,000 polygonsThen there are: 786,423 pixel, or primary raysMultiply byrecursion depth: 5 * 786,423 = 3.93 million raysWorst case each ray must check 10,000 polygons: 3.9 trillion intersection tests

  14. Geometry is inserted in tree. Rays traversethrough it. Acceleration: k-d Tree Special case of BSP Tree.. Axis-aligned BSP Tree

  15. Why is raytracing difficult in GPU shaders? Hint: What is the most complicated part of raytracing?

  16. GPU Raytracing 16.3 million rays/secCPU (AMD 2.4ghz) 2.4 fpsGPU (ATI X1900): 14.2 fpsPS3 (Cell Proc): 20.0 fpsFree source code 18x 8x 4x Daniel Horn, Jeremy Sugerman, Mike Houston, Pat Hanrahan“Interactive k-D Tree GPU Raytracing”, 2007

  17. Lab 1) Model a box in OpenGL2) Model a cylinder in OpenGL3) Coca-Cola challenge4) Mini-Project5) Raytracing an arbitrary sphere6) Other..

More Related