Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
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
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
Most light doesn’t reach the camera http://software.intel.com/file/37491
??
Most light doesn’t reach the camera http://software.intel.com/file/37491
??
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
Ray Tracing
for (each object in scene)
drawObject();
for (each pixel in image)
sendRay();
Rasterization
Ray Tracing
for (each object in scene)
drawObject();
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
Ray
~o = origin
~d = direction
Ray
~o = origin
~d = directionDoes not have to be unit length!
Point on Ray
~o+ t~dt 2 (0;1)
t ¸ 1
Point on Ray
~o+ t~d
t < 0
Point on Ray
~o+ t~d
t < 0
Generating rays
No perspective transformation
needed!
~p0
~j
~i
~p = ~p0 + u~i+ v~ju 2 [0;w]; v 2 [0; h]
Ray-object intersection
~o+ t~d
k~x¡~ck2 = R2
Ray-object intersection
~o+ t~d k~x¡~ck2 = R2
Ray-object intersection
~o+ t~d k~x¡~ck2 = R2
k~o+ t~d¡~ck2 = R2
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
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
Ray-object intersection CS 148, fall 2011
Normals
~x~c~N =
~x¡~c
k ¢ k
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
Light rays
~x
~l1 ¡ ~x~l2 ¡ ~x
¢ ¢ ¢
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
Deal with repeated objects
http://members.optusnet.com.au/pennywyatt/Images/People.png
Store object once, use often
Deal with repeated objects
Each instance stores a
transformation matrix M
(can stretch, rotate, etc!)
Deal with repeated objects
Object coordinates World coordinates
M 2 R3£3
Deal with repeated objects
M 2 R3£3
~o+ t~d
Deal with repeated objects
M 2 R3£3
~o+ t~dM¡1~o+ tM¡1~d
Do intersection here!
Deal with repeated objects
M 2 R3£3
~o+ t~dM¡1~o+ tM¡1~dSame t!
Deal with repeated objects
M 2 R3£3
~N ~M ~N
Binary operations for shape http://upload.wikimedia.org/wikipedia/commons/8/8b/Csg_tree.png
Binary operations for shape http://en.wikipedia.org/wiki/Constructive_solid_geometry
A B
A[B A¡B A\B
Binary operations for shape http://en.wikipedia.org/wiki/Constructive_solid_geometry
A B
A[B A¡B A\B
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
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
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
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
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
Multiple rays per pixel
Moiré pattern
http://upload.wikimedia.org/wikipedia/commons/f/fb/Moire_pattern_of_bricks_small.jpg
Remove Moiré patterns http://en.wikipedia.org/wiki/File:Moire_pattern_of_bricks.jpg
?
?
?
http://erich.realtimerendering.com/shadow_comparison.html
Hard shadows Soft shadows
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
Randomly sample eye positions
Square lens “Focus plane”
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
Brightness depends on nearby geometry http://en.wikipedia.org/wiki/Ambient_occlusion
Diffuse Ambient
Account for indirect lighting http://en.wikipedia.org/wiki/Global_illumination
Account for indirect lighting
Diffuse inter-reflection http://en.wikipedia.org/wiki/Global_illumination
Account for indirect lighting
Caustics http://en.wikipedia.org/wiki/Global_illumination
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
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
Binary Space Partitioning (BSP) trees http://algorithmicarts.com/images/2008/bsptree-cutaway1269x684.png
Uniform subdivision grid http://www.cs.berkeley.edu/~sequin/CS184/IMGS/spatialSubdiv.gif
“Embarrassingly parallel,” but not SIMD? [NVIDIA, SIGGRAPH 2008]
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