http://www.futuretech.blinkenlights.nl/misc/scene_1024x768.jpg CS 148, Summer 2012 Introduction to Computer Graphics and Imaging Justin Solomon
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
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
http://software.intel.com/file/37491
Light source http://software.intel.com/file/37491
Light interacts with objects in scene http://software.intel.com/file/37491
Image plane http://software.intel.com/file/37491
?? http://software.intel.com/file/37491 Most light doesn t reach the camera
?? http://software.intel.com/file/37491 Most light doesn t reach the camera
Many lighting effects are reversible
Trace rays from light to camera
Trace rays from light to camera
Draw viewing ray through each pixel
Intersect with geometry
Compute light ray
Evaluate shading µ
Take closest one
µ µ Redirect ray
µ µ Redirect ray
Rasterization for (each object in scene) drawobject();
Rasterization for (each object in scene) drawobject(); Ray Tracing for (each pixel in image) sendray();
Rasterization for (each object in scene) drawobject(); Ray Tracing for (each pixel in image) sendray();
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
~d = direction ~o = origin Ray
~d = direction Does not have to be unit length! ~o = origin Ray
t 1 t 2 (0; 1) ~o + t ~ d Point on Ray
~o + t ~ d t < 0 Point on Ray
~o + t ~ d t < 0 Point on Ray
No perspective transformation needed! ~j ~p 0 ~p = ~p 0 + u~i + v~j u 2 [0; w]; v 2 [0; h] ~i Generating rays
k~x ~ck 2 = R 2 ~o + t ~ d Ray-object intersection
~o + t ~ d k~x ~ck 2 = R 2 Ray-object intersection
~o + t ~ d k~x ~ck 2 = R 2 k~o + t ~ d ~ck 2 = R 2 Ray-object intersection
~o + t ~ d k~x ~ck 2 = R 2 k~o + t ~ d ~ck 2 = R 2 (~o + t ~ d ~c) (~o + t ~ d ~c) = R 2 Ray-object intersection
~o + t d ~ k~x ~ck 2 = R 2 k~o + t d ~ ~ck 2 = R 2 (~o + t d ~ ~c) (~o + t d ~ ~c) = R 2 k dk ~ 2 t 2 + 2((~o ~c) d)t ~ + k~o ~ck 2 = R 2 Ray-object intersection
Ray-object intersection CS 148, fall 2011
~x ~c ~ N = ~x ~c k k Normals
~v 3 ~N = (~v 2 ~v 1 ) (~v 3 ~v 1 ) k(~v 2 ~v 1 ) (~v 3 ~v 1 )k ~v 3 ~v 1 ~v 1 ~v 2 ~v 2 ~v 1 http://designjk.files.wordpress.com/2011/12/teapot-decorated.png Normals
~ l2 ~x ~ l1 ~x ~x Light rays
http://www.spot3d.com/vray/help/150sp1/images/examples/shadows/03_raytraced_colored.png
http://2.bp.blogspot.com/-2cpxosdtne8/t5nmclgobpi/aaaaaaaaaj4/xgaz168hpkg/s1600/p0008_i004.png Intersect light ray with scene
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)
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);
Lots of bounces Fewer bounces CS 148, fall 2011 Save time; avoid infinite recursion
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
Store object once, use often http://members.optusnet.com.au/pennywyatt/images/people.png Deal with repeated objects
Each instance stores a transformation matrix M (can stretch, rotate, etc!) Deal with repeated objects
M 2 R 3 3 Object coordinates World coordinates Deal with repeated objects
M 2 R 3 3 ~o + t ~ d Deal with repeated objects
Do intersection here! M 2 R 3 3 M 1 ~o + tm 1 ~ d ~o + t ~ d Deal with repeated objects
M 2 R 3 3 M 1 ~o + tm 1 ~ d Same t! ~o + t ~ d Deal with repeated objects
M 2 R 3 3 ~N ~ M ~ N Deal with repeated objects
http://upload.wikimedia.org/wikipedia/commons/8/8b/csg_tree.png Binary operations for shape
A B A [ B A B A \ B http://en.wikipedia.org/wiki/constructive_solid_geometry Binary operations for shape
A B A [ B A B A \ B http://en.wikipedia.org/wiki/constructive_solid_geometry Binary operations for shape
A B in(a) = [1; 3] in(b) = [2; 6] in(a \ B) = [2; 3] in(a [ B) = [1; 6] in(a B) = [1; 2) Store inside intervals
A B in(a) = [1; 3] in(b) = [2; 6] in(a \ B) = [2; 3] in(a [ B) = [1; 6] in(a B) = [1; 2) Store inside intervals
A B in(a) = [1; 3] in(b) = [2; 6] in(a \ B) = [2; 3] in(a [ B) = [1; 6] in(a B) = [1; 2) Store inside intervals
A B in(a) = [1; 3] in(b) = [2; 6] in(a \ B) = [2; 3] in(a [ B) = [1; 6] in(a B) = [1; 2) Store inside intervals
http://ps-2.kev009.com/catia-b18/basug_c2/basugbt1510.htm
http://www.hackification.com/2008/08/31/experiments-in-ray-tracing-part-8-anti-aliasing/
Scatter rays to make ray tracing less crisp.
Multiple rays per pixel
Moiré pattern http://upload.wikimedia.org/wikipedia/commons/f/fb/moire_pattern_of_bricks_small.jpg Multiple rays per pixel
Remove Moiré patterns http://en.wikipedia.org/wiki/file:moire_pattern_of_bricks.jpg
???
Hard shadows Soft shadows http://erich.realtimerendering.com/shadow_comparison.html
http://user.online.be/felixverbelen/lunecl.jpg Lights aren t all point sources
Randomly sample light rays
Shadow computed per ray
Shadow computed per ray
Shadow computed per ray
http://liam887.files.wordpress.com/2010/08/weaver.jpg
Square lens Focus plane Randomly sample eye positions
https://graphics.stanford.edu/wikis/cs148-11-fall/raytracingresults http://www.baylee-online.net/projects/raytracing/algorithms/glossy-reflection-transmission Randomly sample reflected rays
http://www.matkovic.com/anto/3dl-test-balls-01.jpg Randomly sample positions
Diffuse Ambient http://en.wikipedia.org/wiki/ambient_occlusion Brightness depends on nearby geometry
Account for indirect lighting http://en.wikipedia.org/wiki/global_illumination
Diffuse inter-reflection Account for indirect lighting http://en.wikipedia.org/wiki/global_illumination
Caustics Account for indirect lighting http://en.wikipedia.org/wiki/global_illumination
Value p b m Variable Pixels on screen Objects in scene Average pixels/object Rasterization: O(bm) Ray tracing: O(bp) Accelerated ray tracing: O(p log b) CS 148, fall 2011
http://sopra.le-gousteau.de/images/2/2e/bv_bvh_bspheres.jpg http://graphics.ucsd.edu/courses/rendering/2004/ssaha/index_files/finalbvh.jfif Bounding Volume Hierarchy (BVH)
http://algorithmicarts.com/images/2008/bsptree-cutaway1269x684.png Binary Space Partitioning (BSP) trees
Uniform subdivision grid http://www.cs.berkeley.edu/~sequin/cs184/imgs/spatialsubdiv.gif
[NVIDIA, SIGGRAPH 2008] Embarrassingly parallel, but not SIMD?
http://www.futuretech.blinkenlights.nl/misc/scene_1024x768.jpg CS 148, Summer 2012 Introduction to Computer Graphics and Imaging Justin Solomon