cs 148, summer 2012 introduction to computer graphics and...
TRANSCRIPT
![Page 1: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/1.jpg)
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAAAAAA
CS 148, Summer 2012 Introduction to Computer Graphics and Imaging
Justin Solomon
http://www.futuretech.blinkenlights.nl/misc/scene_1024x768.jpg
![Page 2: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/2.jpg)
http://www.publicdomainpictures.net/view-image.php?picture=female-photographer&image=4360&large=1 http://bloodredpencil.blogspot.com/2010/09/need-help-get-help.html
![Page 3: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/3.jpg)
http://www.publicdomainpictures.net/view-image.php?picture=female-photographer&image=4360&large=1 http://bloodredpencil.blogspot.com/2010/09/need-help-get-help.html
![Page 4: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/4.jpg)
http://software.intel.com/file/37491
![Page 5: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/5.jpg)
Light source
http://software.intel.com/file/37491
![Page 6: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/6.jpg)
Light interacts with objects in scene
http://software.intel.com/file/37491
![Page 7: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/7.jpg)
Image plane
http://software.intel.com/file/37491
![Page 8: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/8.jpg)
Most light doesn’t reach the camera http://software.intel.com/file/37491
??
![Page 9: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/9.jpg)
Most light doesn’t reach the camera http://software.intel.com/file/37491
??
![Page 10: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/10.jpg)
Many lighting effects are reversible
![Page 11: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/11.jpg)
Trace rays from light to camera
![Page 12: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/12.jpg)
Trace rays from light to camera
![Page 13: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/13.jpg)
Draw viewing ray through each pixel
![Page 14: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/14.jpg)
Intersect with geometry
![Page 15: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/15.jpg)
Compute light ray
![Page 16: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/16.jpg)
Evaluate shading
µ
![Page 17: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/17.jpg)
Take closest one
![Page 18: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/18.jpg)
Redirect ray
µ
µ
![Page 19: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/19.jpg)
Redirect ray
µ
µ
![Page 20: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/20.jpg)
Rasterization for (each object in scene)
drawObject();
![Page 21: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/21.jpg)
Rasterization
Ray Tracing
for (each object in scene)
drawObject();
for (each pixel in image)
sendRay();
![Page 22: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/22.jpg)
Rasterization
Ray Tracing
for (each object in scene)
drawObject();
for (each pixel in image)
sendRay();
![Page 23: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/23.jpg)
for each pixel do
compute viewing ray
if (ray hits an object with t>0) then
Compute normal
Evaluate shading model
else
Set pixel color to background color
Textbook page 85
![Page 24: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/24.jpg)
Ray
~o = origin
~d = direction
![Page 25: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/25.jpg)
Ray
~o = origin
~d = directionDoes not have to be unit length!
![Page 26: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/26.jpg)
Point on Ray
~o+ t~dt 2 (0;1)
t ¸ 1
![Page 27: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/27.jpg)
Point on Ray
~o+ t~d
t < 0
![Page 28: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/28.jpg)
Point on Ray
~o+ t~d
t < 0
![Page 29: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/29.jpg)
Generating rays
No perspective transformation
needed!
~p0
~j
~i
~p = ~p0 + u~i+ v~ju 2 [0;w]; v 2 [0; h]
![Page 30: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/30.jpg)
Ray-object intersection
~o+ t~d
k~x¡~ck2 = R2
![Page 31: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/31.jpg)
Ray-object intersection
~o+ t~d k~x¡~ck2 = R2
![Page 32: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/32.jpg)
Ray-object intersection
~o+ t~d k~x¡~ck2 = R2
k~o+ t~d¡~ck2 = R2
![Page 33: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/33.jpg)
Ray-object intersection
~o+ t~d k~x¡~ck2 = R2
k~o+ t~d¡~ck2 = R2
(~o+ t~d¡~c) ¢ (~o+ t~d¡~c) = R2
![Page 34: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/34.jpg)
Ray-object intersection
~o+ t~d k~x¡~ck2 = R2
k~o+ t~d¡~ck2 = R2
(~o+ t~d¡~c) ¢ (~o+ t~d¡~c) = R2
k~dk2t2 +2((~o¡~c) ¢ ~d)t+ k~o¡~ck2 =R2
![Page 35: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/35.jpg)
Ray-object intersection CS 148, fall 2011
![Page 36: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/36.jpg)
Normals
~x~c~N =
~x¡~c
k ¢ k
![Page 37: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/37.jpg)
Normals http://designjk.files.wordpress.com/2011/12/teapot-decorated.png
~v1
~v2
~v3
~v2 ¡~v1
~v3 ¡~v1
~N =(~v2 ¡ ~v1)£ (~v3 ¡ ~v1)
k(~v2 ¡ ~v1)£ (~v3 ¡ ~v1)k
![Page 38: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/38.jpg)
Light rays
~x
~l1 ¡ ~x~l2 ¡ ~x
¢ ¢ ¢
![Page 39: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/39.jpg)
http://www.spot3d.com/vray/help/150SP1/images/examples/shadows/03_raytraced_colored.png
![Page 40: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/40.jpg)
http://2.bp.blogspot.com/-2CpxoSdtNE8/T5nMClgobpI/AAAAAAAAAJ4/XgaZ168HpKg/s1600/P0008_I004.png
Intersect light ray with scene
![Page 41: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/41.jpg)
abstract class surface
virtual hit-record hit(ray, t0, t1)
virtual box bounding-box()
struct hit-record
vector3d position, normal
surface hit-surface
…
abstract class material
color evaluate(in-ray, normal, pos)
…
![Page 42: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/42.jpg)
color ray-trace(ray r)
hit-record record = intersect(r);
…
if (record.hit-surface.is-reflective)
ray reflected-ray =
reflect(r,record.normal);
color reflected-color =
ray-trace(reflected-ray);
compute-spectral-component(
reflected-color);
…
![Page 43: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/43.jpg)
Lots of bounces Fewer bounces
CS 148, fall 2011
Save time; avoid infinite recursion
![Page 44: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/44.jpg)
http://www.deepakantony.com/wp-content/uploads/2012/04/ambientocclusion_instancing.png http://members.optusnet.com.au/pennywyatt/Images/People.png
Deal with repeated objects
![Page 45: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/45.jpg)
Deal with repeated objects
http://members.optusnet.com.au/pennywyatt/Images/People.png
Store object once, use often
![Page 46: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/46.jpg)
Deal with repeated objects
Each instance stores a
transformation matrix M
(can stretch, rotate, etc!)
![Page 47: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/47.jpg)
Deal with repeated objects
Object coordinates World coordinates
M 2 R3£3
![Page 48: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/48.jpg)
Deal with repeated objects
M 2 R3£3
~o+ t~d
![Page 49: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/49.jpg)
Deal with repeated objects
M 2 R3£3
~o+ t~dM¡1~o+ tM¡1~d
Do intersection here!
![Page 50: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/50.jpg)
Deal with repeated objects
M 2 R3£3
~o+ t~dM¡1~o+ tM¡1~dSame t!
![Page 51: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/51.jpg)
Deal with repeated objects
M 2 R3£3
~N ~M ~N
![Page 52: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/52.jpg)
Binary operations for shape http://upload.wikimedia.org/wikipedia/commons/8/8b/Csg_tree.png
![Page 53: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/53.jpg)
Binary operations for shape http://en.wikipedia.org/wiki/Constructive_solid_geometry
A B
A[B A¡B A\B
![Page 54: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/54.jpg)
Binary operations for shape http://en.wikipedia.org/wiki/Constructive_solid_geometry
A B
A[B A¡B A\B
![Page 55: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/55.jpg)
Store “inside intervals”
in(A) = [1; 3]
in(B) = [2; 6]
in(A \B) = [2; 3]
in(A [B) = [1; 6]
in(A¡B) = [1; 2)
A B
![Page 56: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/56.jpg)
Store “inside intervals”
in(A) = [1; 3]
in(B) = [2; 6]
in(A \B) = [2; 3]
in(A [B) = [1; 6]
in(A¡B) = [1; 2)
A B
![Page 57: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/57.jpg)
Store “inside intervals”
in(A) = [1; 3]
in(B) = [2; 6]
in(A \B) = [2; 3]
in(A [B) = [1; 6]
in(A¡B) = [1; 2)
A B
![Page 58: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/58.jpg)
Store “inside intervals”
in(A) = [1; 3]
in(B) = [2; 6]
in(A \B) = [2; 3]
in(A [B) = [1; 6]
in(A¡B) = [1; 2)
A B
![Page 59: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/59.jpg)
http://ps-2.kev009.com/CATIA-B18/basug_C2/basugbt1510.htm
![Page 60: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/60.jpg)
http://www.hackification.com/2008/08/31/experiments-in-ray-tracing-part-8-anti-aliasing/
![Page 61: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/61.jpg)
Scatter rays to make ray tracing less crisp.
![Page 62: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/62.jpg)
Multiple rays per pixel
![Page 63: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/63.jpg)
Multiple rays per pixel
Moiré pattern
http://upload.wikimedia.org/wikipedia/commons/f/fb/Moire_pattern_of_bricks_small.jpg
![Page 64: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/64.jpg)
Remove Moiré patterns http://en.wikipedia.org/wiki/File:Moire_pattern_of_bricks.jpg
![Page 65: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/65.jpg)
?
?
?
![Page 66: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/66.jpg)
![Page 67: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/67.jpg)
![Page 68: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/68.jpg)
http://erich.realtimerendering.com/shadow_comparison.html
Hard shadows Soft shadows
![Page 69: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/69.jpg)
http://user.online.be/felixverbelen/lunecl.jpg
Lights aren’t all point sources
![Page 70: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/70.jpg)
Randomly sample light rays
![Page 71: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/71.jpg)
Shadow computed per ray
![Page 72: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/72.jpg)
Shadow computed per ray
![Page 73: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/73.jpg)
Shadow computed per ray
![Page 74: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/74.jpg)
http://liam887.files.wordpress.com/2010/08/weaver.jpg
![Page 75: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/75.jpg)
Randomly sample eye positions
Square lens “Focus plane”
![Page 76: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/76.jpg)
https://graphics.stanford.edu/wikis/cs148-11-fall/RaytracingResults http://www.baylee-online.net/Projects/Raytracing/Algorithms/Glossy-Reflection-Transmission
Randomly sample reflected rays
![Page 77: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/77.jpg)
http://www.matkovic.com/anto/3dl-test-balls-01.jpg
Randomly sample positions
![Page 78: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/78.jpg)
Brightness depends on nearby geometry http://en.wikipedia.org/wiki/Ambient_occlusion
Diffuse Ambient
![Page 79: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/79.jpg)
Account for indirect lighting http://en.wikipedia.org/wiki/Global_illumination
![Page 80: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/80.jpg)
Account for indirect lighting
Diffuse inter-reflection http://en.wikipedia.org/wiki/Global_illumination
![Page 81: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/81.jpg)
Account for indirect lighting
Caustics http://en.wikipedia.org/wiki/Global_illumination
![Page 82: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/82.jpg)
Rasterization:
O(bm)
Ray tracing:
O(bp)
Accelerated ray tracing:
O(p log b)
Value Variable
p Pixels on screen
b Objects in scene
m Average pixels/object
CS 148, fall 2011
![Page 83: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/83.jpg)
Bounding Volume Hierarchy (BVH)
http://sopra.le-gousteau.de/images/2/2e/Bv_bvh_bspheres.jpg http://graphics.ucsd.edu/courses/rendering/2004/ssaha/index_files/finalbvh.jfif
![Page 84: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/84.jpg)
Binary Space Partitioning (BSP) trees http://algorithmicarts.com/images/2008/bsptree-cutaway1269x684.png
![Page 85: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/85.jpg)
Uniform subdivision grid http://www.cs.berkeley.edu/~sequin/CS184/IMGS/spatialSubdiv.gif
![Page 86: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/86.jpg)
“Embarrassingly parallel,” but not SIMD? [NVIDIA, SIGGRAPH 2008]
![Page 87: CS 148, Summer 2012 Introduction to Computer Graphics and ...graphics.stanford.edu/.../lecture10_ray_tracing.pdf · Accelerated ray tracing: O(p log b) Value Variable p Pixels on](https://reader035.vdocuments.us/reader035/viewer/2022071022/5fd64c3652dd5d008318265a/html5/thumbnails/87.jpg)
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAAAAAA
CS 148, Summer 2012 Introduction to Computer Graphics and Imaging
Justin Solomon
http://www.futuretech.blinkenlights.nl/misc/scene_1024x768.jpg