Implementation Issues More from Interface point of view Y V U Eye N X Z World Coordinate System (WCS) Viewing Coordinate System (VCS)
View Coordinate System (VCS) Viewing coordinate system Position and orientation of the view plane Extent of the view plane (window) Position of the eye View Plane View Reference Point (VRP): the origin of VCS specified as (r x, r y, r z ) in WCS: center of the scene Normal to the view plane (n x, n y, n z )
View Coordinate System (VCS) View Plane Normal Direction (View Plane Normal VPN) n (n x,n y,n z ) User may provide normalized vector e.g. n x sin φ cos θ n y sin φ sin θ n z cos φ X Z φ r θ Y
View Coordinate System (VCS) View Plane Direction v v is a unit vector intuitively corresponding to up vector up vector is specified by the user in WCS up up (up.n)n v up / up Direction u n v up up u n x v ( Left Handed)
View Coordinate System (VCS) Window and Eye Window : left, right, bottom,top (w l,w r,w b,w t ) generally is centered at VRP (origin) w r w t Eye : e (e u,e v,e n ) Typically e (0,0,-E) n v u e w l w b
Transformation from WCS to VCS Y v r O (x, y) u ( x y ) ( a ( a u b) + r v b) M + r O X
Transformation from WCS to VCS Point object is represented as (a,b,c) in VCS (x,y,z) in WCS z y x z y x z y x n n n v v v u u u n v u M
[ ] [ ] [ ] T M r p M r p c b a r M c b a z y x p ) ( ) ( 1 + Transformation from WCS to VCS Conversion from one coordinate system to another Therefore a(p-r).u, b(p-r).v, c(p-r).n
[ ] [ ] [ ] T M r p M r p c b a r M c b a z y x p ) ( ) ( 1 + Conversion from one coordinate system to another z y x z y x z y x n n n v v v u u u n v u M (a,b,c) in VCS (x,y,z) in WCS Where 3D Viewing Interface (Revisit) Set up
Set up Steps 1. Define the view reference point (VRP) r 2. Obtain M defining u, v, n 3. Define the position of eye (in VCS) e ( e u, e v, e n ) typically ( 0, 0, -E ) corresponding point in WCS will be eye ( 0, 0, -E ) M + r 4. Define the window and the pixel location.
Set up W t v rows : 0 to MAXROW cols : 0 to MAXCOL (i,j) th pixel : (u i, v j, 0) W b n u i W l + i Δu v j W t j Δv e ( 0,0, -E) W l W r u Δu ( W r W l ) / MAXCOL Δv ( W t W b ) / MAXROW
Set up 5. Parametric equation of ray P i,j (t) eye + dir ij t eye ( 0, 0, -E ) M + r dir ij ( ( u i, v j, 0 ) e) M ( u i, v j, E ) M P ij (t) eye + dir ij t R(t) R o + R d t
Set up Find intersection with object (r i ) Find the normal at r i as r n Find intensity at I at the point (Illumination model) Find the pixel-color
Review Basic ray tracing (one level): ray casting Algorithm: For each pixel shoot a ray from eye (COP) Compute ray-object(s) intersection Obtain the closest intersection point (p) Compute normal at p Compute illumination (intensity) Set up: Obtain ray in WCS for intersection using transformations Transformation of objects: Equivalent transformation for the ray
D T 2 R 2 Eye B eye-ray A View Plane R 1 T 1 C F E
Eye C D R 1 T 1 R 2 T 2
Different Rays Eye ray (primary ray) Reflected ray Transmitted ray Shadow ray (secondary rays)
Reflected Ray Recall Reflection Vector N L θ i N θ r R L R 2 (L N) N -L R 2( L N) N L
Refracted Ray Snell s Law N I θ i sin sinθ θ i t η η t i θ t T
Refracted Ray Snell s Law I θ i N (cosθ i )N θ t M T I + (cosθi ) N M sinθi T (sinθt ) M (cos θt ) N sinθt ( I + (cos θi ) N) T (cosθt sinθi ηi T ( I + (cos θi ) N) (cos θt ) N η t ) N
L1 Eye Obj 3 Obj 1 L2 Obj 1 Obj 2
Eye Obj 3 L2 L1 Obj 1 Eye L1 L2 Obj 1 T R Obj 2 Obj 3 Obj 2
Eye Obj 3 L2 L1 Obj 1 Obj 2 L1 L2 Eye L1 L2 Obj 1 L1 T R L2 Obj 2 Obj 3 R T R
When to stop? When ray leaves the scene When the contribution to the overall intensity is small
Phong Illumination Model + + + + + + + + m i n i i s i i d a a n l s l d a a n l s l d a a total V R I k N L I k I k V R I k N L I k I k α I k θ I k I k reflection specular diffuse reflection reflection ambient I 1 ) ( ) ( ) ( ) ( cos cos Recursive Ray Tracing
Illumination When in shadow (single light source) I total ambient k I a a reflection
Illumination With reflection and transmission rays Itotal ( P) Ilocal (P) + krgi(pr ) + k tg (P ) t Global Illumination
T Whitted 1980
Other Example
Other features Ray tracing is an image based method (pixelization) Sampling aliasing Jagginess Moire patterns Anti-aliasing
Anti-alising Supersampling More number of rays per pixel Average the result