Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.
-
Upload
oswin-johns -
Category
Documents
-
view
215 -
download
0
Transcript of Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.
![Page 1: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/1.jpg)
Raytracing and Global IlluminationIntro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara
![Page 2: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/2.jpg)
Rasterization vs. Raytracing
Rasterize:
- Project polygons onto picture plane- Efficient hardware. OpenGL, DirectX
Raytrace:
- Cast light rays into scene through picture plane.
project cast
![Page 3: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/3.jpg)
Inverse View Matrix
- Compute ray directions using Inverse Projection and Camera matrix
- Loop over all pixels in image. Start with 3D ray extending from camera
p = Cam Cam Proj p’(x,y)
p’(x,y) = clip ( P V M p(x,y,z) ) = Proj View p
T R-1 -1 -1
p
p -1
![Page 4: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/4.jpg)
Inverse Projection Matrix
- Where else have we see the Inverse Projection Matrix?
- Just draw a line from the origin to the pixel (x, y)
p
x
y
![Page 5: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/5.jpg)
![Page 6: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/6.jpg)
Ray-Sphere Intersection
r
p(t) = R + t R t > 0 Ray definition
p: (x – xc) + (y – yc) + (z – zc) = r Sphere definition2 2 2 20 dir
Solve for p:
p
0R
dirR
A t + B t + C = 02A = Rx + Ry + RzB = 2 * (Rx (Rx0–Sx) + Ry (Ry0-Sy) + Rz(Rz0-Sz) )C = (Rx0–Sx) + (Ry0–Sy) + (Rz0–Sz)
2 2 2
2 2 2
![Page 7: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/7.jpg)
![Page 8: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/8.jpg)
- What do we do when we hit an object?
- Warn lighting model. Trace rays to each light source, and also new terms for reflected and trasmitted light
Raytracing – Illumination Model
![Page 9: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/9.jpg)
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
![Page 10: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/10.jpg)
Raytracing - History
Turner WhittedAn improved illumination model for shaded displayCommunications of the ACM, v.23 n.6, p.343-349, June 1980
ABSTRACT To 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.
![Page 11: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/11.jpg)
![Page 12: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/12.jpg)
![Page 13: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/13.jpg)
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
![Page 14: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/14.jpg)
![Page 15: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/15.jpg)
What might be some limitations of raytracing?
![Page 16: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/16.jpg)
What might be some limitations of raytracing?
1. Performance
2. Light propagation - no caustics
3. Memory – All geometry must fit in memory
10 million rays, simple scene
Solution: Acceleration structures: k-d Tree, Octree
Monsters, Inc. (Pixar) 13 hours per single frame,most of that is spent raytracing individual hairs of fur.
![Page 17: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/17.jpg)
Acceleration:
k-d Tree Special case of BSP Tree.. Axis-aligned BSP Tree
Geometry is inserted in tree.
Rays traversethrough it.
![Page 18: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/18.jpg)
![Page 19: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/19.jpg)
![Page 20: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/20.jpg)
![Page 21: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/21.jpg)
![Page 22: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/22.jpg)
![Page 23: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/23.jpg)
Daniel Horn, Jeremy Sugerman, Mike Houston, Pat Hanrahan“Interactive k-D Tree GPU Raytracing”, 2007
GPU Raytracing
18x
8x
4x
16.3 million rays/sec
CPU (AMD 2.4ghz) 2.4 fpsGPU (ATI X1900): 14.2 fpsPS3 (Cell Proc): 20.0 fps
Free source code
![Page 24: Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.](https://reader036.fdocuments.us/reader036/viewer/2022062804/56649eba5503460f94bc1c96/html5/thumbnails/24.jpg)