2 Lecture 31of 41 Lecture Outline

Ray Tracing, Part 1 of 2:  Reading for Last Class: §5.3, Eberly 2e; CGA Handout Intersections, Ray Trees & Recursion  Reading for Today: Chapter 14, Eberly 2e  Reading for Next Class: Handout  Last Time: Animation Part 3 of 3 – Inverse Kinematics William H. Hsu  FK vs. IK Department of Computing and Information Sciences, KSU  IK  Autonomous agents vs. hand-animated movement KSOL course pages: http://bit.ly/hGvXlH / http://bit.ly/eVizrE  Public mirror web site: http://www.kddresearch.org/Courses/CIS636 Analytical vs. iterative solutions Instructor home page: http://www.cis.ksu.edu/~bhsu  Rag doll physics, rigid-body dynamics, physically-based models  End of Material on: Particle Systems, Collisions, CGA, PBM Readings:  Today: Ray Tracing, Part 1 of 2 Last class: §5.3, Eberly 2e – see http://bit.ly/ieUq45; CGA Handout  Vectors: Light/shadow (L), Reflected (R), Transmitted/refracted (T) Today: Chapter 14, Eberly 2e Next class: Ray Tracing Handout  Basic recursive ray tracing: ray trees Reference – Wikipedia, Ray Tracing: http://bit.ly/dV7lNm  Next Class: Ray Tracing Lab Reference – ACM Ray Tracing News: http://bit.ly/fqyZNQ

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Kansas State University Introduction to Computer Graphics Kansas State University

3 4 Acknowledgements: Where We Are Inverse Kinematics, Ray Tracing

David C. Brogan Visiting Assistant Professor, Computer Science Department, University of Virginia http://www.cs.virginia.edu/~dbrogan/ Susquehanna International Group (SIG) http://www.sig.com

Renata Melamud Ph.D. Candidate Mechanical Engineering Department Stanford University http://micromachine.stanford.edu/~rmelamud/

Dave Shreiner & Brad Grantham Adjunct Professor & Adjunct Lecturer, Santa Clara University ARM Holdings, plc http://www.plunk.org/~shreiner/ http://www.plunk.org/~grantham/

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

5 Review [1]: 6 Review [2]: Kinematics & Degrees of Freedom Joint Types

Adapted from slides  2000 – 2005 D. Brogan, University of Virginia Adapted from slides  2002 R. Melamud, Stanford University CS 551, Advanced CG & Animation – http://bit.ly/hUXrqd Mirrored at CMU 16-311 Introduction to Robotics, http://generalrobotics.org

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 7 Forward Kinematics: 8 Review [3]: Joint Angles to Bone Coordinates Forward Kinematics

?

 3 2 End Effector 1

Base    θx )f(  f Φe  Choi Rotenberg

Adapted from slides  2004 – 2005 S. Rotenberg, UCSD Adapted from slides  2002 K. J. Choi, Seoul National University CSE169: , Winter 2005 – http://bit.ly/f0ViAN Graphics and Media Lab ( http://graphics.snu.ac.kr ) – mirrored at: http://bit.ly/hnzSAN

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

9 Review [4]: 10 Inverse Kinematics: Inverse Kinematics Issues

For more on characters & IK, see: Advanced Topics in CG Lecture 05

?  3 2 ? End Effector 1

Base    1 xθ )(f  f 1eΦ  Choi Rotenberg

Adapted from slides  2002 K. J. Choi, Seoul National University Adapted from slides  2004 – 2005 S. Rotenberg, UCSD Graphics and Media Lab ( http://graphics.snu.ac.kr) – mirrored at: http://bit.ly/hnzSAN CSE169: Computer Animation, Winter 2005 – http://bit.ly/f0ViAN

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

11 Review [5]: 12 Review [6]: Inverse Kinematics Demos  Type of  Automatically generates CGA directives (rotations)  Based on simulation  Rigid-body dynamics  Articulated Figure  Gravity

© 2008 M. Kinzelman © 2007 A. Brown  No autonomous movement http://youtu.be/l52yZ491kPo http://youtu.be/6JdLOLazJJ0 Falling Bodies © 1997 – 2001 Animats  Used for inert body http://www.animats.com  Usually: character death (car impact, falling body, etc.)  Less often: unconscious, paralyzed character  Collisions with Multiple Bodies  Inter-character  Character-object

© 2008 T. Komura, H. S. Lim, & R. W. H. Lau © 2011 K. Iyer http://youtu.be/FJTBMnP6oCM http://youtu.be/YvRBWIRAPsE

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 13 Review [7]: 14 Review [8}: Ragdoll Physics Demos Physically-Based Modeling (PBM)  Particle Dynamics  Emitters  0-D (points), 1-D (lines), 2-D (planes, discs, cross-sections)  e.g., fireworks (0-D); fountains (0/1/2-D); smokestacks, jets (2-D)  Simulation: birth-death process, functions of particle age/trajectory  Rigid-Body Dynamics © 2006 P. Pelt © 2007 N. Picouet  http://youtu.be/6JdLOLazJJ0 Constrained systems of connected parts http://youtu.be/ohNqCb--aSs See also: http://youtu.be/5_QIsI0fyaU  Examples: falling rocks, colliding vehicles, rag dolls  Articulated Figures: Primarily IK  Rocks fall  More References  Everyone dies  ACM, Intro to Physically-Based Modeling : http://bit.ly/hhQvXd  Wikipedia, : http://bit.ly/h4PIRt  Wikipedia, N-Body Problem: http://bit.ly/1ayWwe  PBM System: () PhysX: http://bit.ly/cp7bnA

© 2009 M. E. Cerquoni © 2010 M. Heinzen (Arkaein) http://youtu.be/uW_DK2qvKv8 http://bit.ly/gUj9Su / http://youtu.be/FJTBMnP6oCM

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

15 Ray Tracing [1]: 16 Ray Tracing [2]: Overview Why Use It?

 What is it?  Simulate rays of light  Why use it?  Produces natural lighting effects  Basics  Advanced topics  Reflection  Depth of Field  References  Refraction  Motion Blur

© 2006 – 2007 H. Kuijpers,  Soft Shadows  Caustics Capgemini Netherlands http://bit.ly/erkKrC  Hard to simulate effects with rasterization techniques (OpenGL)  Rasterizers require many passes  Ray-tracing easier to implement

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

17 Ray Tracing [3]: 18 Ray Tracing [4]: Who Uses It? Brief History

 Entertainment (Movies, Commercials)  Decartes, 1637 A.D. - analysis of rainbow  Games pre-production  Arthur Appel, 1968 - used for lighting 3D models  Simulation  Turner Whitted, 1980 - “An Improved Illumination Model for Shaded Display” really kicked everyone off.  1980-now - Lots of research

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 19 Ray Tracing [5]: 20 Ray Tracing [6]: Basic Operations Basic Idea

 Simulate light rays from light source to eye  Generating Rays  Intersecting Rays with Scene  Lighting Eye Light  Shadowing  Reflections

ay Inc ed r iden lect t ray Ref Surface

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

21 22 “Forward” Ray Tracing “Backward” Ray Tracing

 Trace rays from light  Trace rays from eye instead  Lots of work for little return  Do work where it matters

Light Light Image Image Light Rays Plane Plane

Eye Eye Object Object

This is what most people mean by “ray tracing”.

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

23 24 Ray: Parametric Form Generating Rays [1]

 Ray expressed as function of a single parameter ( “t”)  Trace one ray for each pixel (u, v) in image plane

tan(fovx) * 2 = + t *

= ro + trd Image t = 2.5 Plane

rd = t = 2.0 fovx

ro = t = 1.0 Eye Eye

t = 0.0 (Looking down from the top)

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 25 26 Generating Rays [2] Generating Rays [3]

 Trace one ray for each pixel (u, v) in image plane  Trace one ray for each pixel (u, v) in image plane

renderImage(){ (Looking from the side) for each pixel i, j in the image m ray.setStart(0, 0, 0); // ro ray.setDir ((.5 + i) * tan(fov )* 2 / m, (tan(fov )* 2) / m x x (.5 + j) * tan(fov )* 2 / n, Eye y 1.0); // rd (tan(fovy)* 2) / n n ray.normalize(); image[i][j] = rayTrace(ray); }

Adapted from slidesImage  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: ComputerPlane Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

27 Ray/Triangle Intersection [1]: 28 Ray/Triangle Intersection [2]: Intersection Test Revisited Ray/Plane Intersection Point p

 Want to know: at what point p does ray intersect triangle?  Step 1 : Intersect with plane  Compute lighting, reflected rays, shadowing from that point ( Ax + By + Cz + D = 0 )

Plane normal n = p p = tmin rd rd ro ro (t = ???) tmin = p = -(n  ro + D) / (n  rd )

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

29 Ray/Triangle Intersection [3]: 30 Triangle Normals Triangle Containment for Shading  Step 2 : Check against triangle edges  Could use plane normals (flat shading) n V 1  Better to interpolate from vertices

V0V1 E = V V x n (plane A, B, C) nV1 E p i i i+1 V1 Find areas 0 d = -A.N (plane D) V i 0 n n V0 c p a V 2 b V0 nV2 Plug p into (p  Ei + di ) for each edge if signs are all positive or negative, point is inside triangle! V2 Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D.n Shreiner = an & B. Grantham, + bn SCU + cn COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001V0 – http://bit.ly/hz1kfUV1 V2

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 31 32 Lighting [1]: Finding Intersections General Notation Review

 Check all triangles, keep closest intersection tmin  We’ll use triangles for lights  Can build complex shapes from triangles hitObject(ray) {  Some lighting terms for each triangle in scene does ray intersect triangle? if(intersected and was closer) Light Eye save that intersection N if(intersected) return intersection point and normal } I R

V

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

33 Lighting [2]: 34 Ambient Light Modified Phong Illumination

 Iambient – simulates indirect lighting in a scene  Use modified Phong lighting  similar to OpenGL  simulates rough and shiny surfaces Eye for each light

In = IambientKambient + . IdiffuseKdiffuse (L N) + . n IspecularKspecular (R V) Light

 May not need for RT!

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

35 36 Diffuse Light Specular Light

 Idiffuse – simulates direct lighting on rough surface  Ispecular simulates direct lighting on a smooth surface  Viewer-independent  Viewer dependent  Paper, rough wood, brick, etc...  Plastic, metal, polished wood, etc...

Eye Eye

Light Light

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 37 38 Shadow Test Reflection

 Check against other objects to see if point is shadowed  Angle of incidence = angle of reflection (I = R )  I, R, N lie in the same plane

Eye N

R = I - 2 (N  I) N I I R R

Shadowing object Light

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

39 Putting It All Together [1]: 40 Putting It All Together [2]: Recursive Calculation & Ray Tree Applying Lighting

 Recursive ray evaluation  Calculating surface color

lighting(point) { rayTrace(ray) { color = ambient color; hitObject(ray, p, n, triangle); for each light color = object color; if(hitObject(shadow ray)) if(object is light) color += lightcolor * return(color); dot(shadow ray, n); else color += rayTrace(reflection) * return(lighting(p, n, color)); Ray tree pow(dot(reflection, ray), shininess); © 2000 N. Patrikalakis, MIT } http://bit.ly/fjcGGk return(color); I = Incident ray } S = light Source vector ( aka L) R = reflected ray  Generates ray tree shown at right T = transmitted ray

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

41 Putting It All Together [3]: 42 Good Start: Main Program What next?

 Lighting, Shadows, Reflection are enough to make some compelling images main() {  Want better lighting and objects triangles = readTriangles();  Need more speed image = renderImage(triangles); writeImage(image); }

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 43 44 Refraction [1]: More Quality, More Speed Snell’s Law

 Better Lighting + Forward Tracing  Keep track of medium (air, glass, etc)   Need index of refraction ()  Modeling Techniques  Need solid objects  Distributed Ray Tracing: Techniques N  Motion Blur   Depth of Field I I Medium 1  Blurry Reflection/Refraction sin( )  (e.g., air) I = 1  Wikipedia, Distributed Ray Tracing: http://bit.ly/ihyVUs    Improving Image Quality sin( T) 2 Medium 2  Acceleration Techniques T (e.g., water) T

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

45 Refraction [2]: 46 Improved Light Model: Example Cook-Torrance

 Cook-Torrance model  Based on a microfacet model  Wikipedia: http://bit.ly/hX3U30  Metals have different color at angle  Oblique reflections leak around corners

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

47 Using “Forward” Ray Tracing [1]: 48 Using “Forward” Ray Tracing [2]: Lensed Caustics for Indirect Lighting Example

 Backward tracing doesn’t handle indirect lighting too well  To get caustics, trace forward, store results in texture map

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 49 Texture Mapping & Ray Tracing [1]: 50 Texture Mapping & Ray Tracing [2]: Applying Surface Detail Example

 Using texture maps  Add surface detail  Think of it like texturing in OpenGL  Diffuse, specular colors  Shininess value  Bump map  Transparency value

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

51 52 Parametric Surfaces Constructive Solid Geometry

 More expressive than triangle  Union, Subtraction, Intersection of solid objects  Intersection is probably slower  u and v on surface can be used as texture s, t  Have to keep track of intersections

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

53 54 Distributed Ray Tracing [1]: Hierarchical Transformation Basic Idea

 Scene made of parts  Average multiple rays instead of just one ray  Each part made of smaller parts  Use for both shadows, reflections, transmission (refraction)  Each smaller part has transformation linking it to larger part  Use for motion blur  Transformation can change over time: animation (CGA)  Use for depth of field

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 55 Distributed Ray Tracing [2]: 56 Distributed Ray Tracing [3]: Example Supersampling

 One ray is not enough (jaggies)  Can use multiple rays per pixel - supersampling  Can use a few samples, continue if they’re very different - adaptive supersampling  Texture interpolation & filtering

Ray Tracing © 2008 Wikipedia http://bit.ly/dV7lNm

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

57 58 Acceleration! Bounding Volumes

 1280x1024 image with 10 rays/pixel  1000 objects (triangle, CSG, NURBS)  Use simple shape for quick test, keep BV hierarchy  3 levels recursion

39321600000 intersection tests 100000 tests/second -> 109 days! Must use an acceleration method!

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

59 Spatial Partitioning: 60 Parallelism Subdivision

 Break your space into pieces  Can always throw more processors at it  Search the structure linearly  Parallel computing model  Multiple processes or threads  Data parallel: separate pixel for each

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University 61 62 Really Advanced Stuff References

 Error analysis  Introduction to Ray-Tracing, Glassner et al., 1989, 0-12-286160-4  Hybrid radiosity/ray-tracing  Advanced Animation and Rendering Techniques , Watt & Watt,  Metropolis Light Transport 1992, 0-201-54412-1  Memory-Coherent Ray-tracing  Computer Graphics: Image Synthesis, Joy et al., 1988, 0-8186- 8854-4  SIGGRAPH Proceedings (All)

Adapted from slides  2001 D. Shreiner & B. Grantham, SCU Adapted from slides  2001 D. Shreiner & B. Grantham, SCU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU COEN 290: Computer Graphics I, Winter 2001 – http://bit.ly/hz1kfU

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University

63 64 Summary Terminology

 Reading for Last Class: §5.3, Eberly 2e; CGA Handout  Joints: Parts of Robot / Articulated Figure That Turn, Slide  Reading for Today: Chapter 14, Eberly 2e  Effectors: Parts of Robot / Articulated Figure That Act ( e.g., Hand, Foot)  Reading for Next Class: Ray Tracing Handout  Bones: Effectors, Other Parts That Rotate about, Slide through Joints  Last Class: Particle Systems, Collisions, IK/CGA Concluded  Procedural Animation: Automatic Generation of Motion via Simulation  Dynamics vs. kinematics, forward vs. inverse revisited  Ray Tracing aka Ray Casting  IK: autonomous vs. hand-animated; solution approaches  Given: screen with pixels ( u, v)  Rag doll physics, rigid-body dynamics, physically-based models  Find intersection tmin(u, v) of rays through each (u, v) with scene  Today: Ray Tracing, Part 1 of 2  Calculate vectors emanating from world-space coordinate of tmin  Vectors  Light (L): to point light sources (or shadows)  Light (L): to point light sources (or shadows)  Reflected (R): from object surface  Reflected (R): from object surface  Transmitted or Transparency (T): through transparent object  Transmitted or Transparency (T): through transparent object  Recursive RT: call raytracer for each intersection found

 tmin: distance to intersection between ray and bounding volume  Builds ray tree rooted at intersection point

 Ways to find tmin  Base cases: unobstructed vector to light; depth limit  Basic recursive ray tracing: ray trees  Parallel RT: use multiple threads/processes for each ( u, v) or t

CIS 536/636 Computing & Information Sciences CIS 536/636 Computing & Information Sciences Lecture 31 of 41 Lecture 31 of 41 Introduction to Computer Graphics Kansas State University Introduction to Computer Graphics Kansas State University