Computer Vision Systems Viewing Systems Projections Illuminations Rendering Culling and Clipping Implementations
Viewing Systems Viewing Transformation Projective Transformation 2D Computer Graphics Devices
Viewing System Example view volume View (reference) point
Viewing System Example 2 vectors + 1 point 1 view plane distance (near plane) + 1 far plane distance A view volume A view window A (perspective) projection
View Volume The truncated pyramid in view space against which the polygons that make up the scene are clipped. x y z z v v v v hz ± d hz ± d d f v v 2h: view plane window dimension d: view plane distance & near plane distance f: far plane distance
Viewing Plane Projection Define a 3D screen space and a point: Requirements: [ xs, ys, zs,1] 1) Normalize z s maximize precision 2) Transform lines in view space into screen space. 3) Transform planes in view space into screen space.
Viewing Plane Projection (cont.) z s A + B/z v Constraints of choosing A and B B < : z v increases z s increases too depth Normalize z s : z v [d, f] [, 1] z s
Viewing Plane Projection (cont.) d f z d f z hz y d y hz x d x v s v v s v v s ) / (1 Note: h insures that xs and ys falls in the range of [-1, 1] over the square screen. v v v v z w d f df d f fz Z y h d Y x h d X ) /( ) /( pers v v v T z y x w Z Y X ] 1 [ ] [
Viewing Plane Projection (cont.) pers2 pers1 pers T T d) fd(f d) f(f d/h d/h d) fd(f d) f(f d/h d/h T 1 1 1 1 1 1
T pers1 T pers2
Illumination Model Reflection: the interaction of light with a surface, in terms of the properties of the surface and the nature of the incident light. Illumination: nature of the light emanating from a surface the geometry of its intensity distribution and so on.
Direct and Indirect Illumination
Point v.s. Ambient Light Source Point light source Ambient light source
World Coordinate Space Screen Space Reflection model: light intensity at a point Reflection model: shading a pixel
Light-Object Interaction Light incident at a surface light reflected + light scattered + light absorbed + light transmitted
Bidirectional Reflectivity Function (BDRF) R ( λ, φ, θ, φ, θ ) bd i i v v I v ( φi, θi, φv, θv ) E ( φ, θ ) i i i
Bidirectional Reflectivity Function (BDRF) cont. E ( φ, θ ) I i i i v ( φ, θ ) cosθ dω i i i i
Multiple Reflections Diffuse reflections
Three Components of BDRF Specular Directional Diffuse Perfect Diffuse
Material, Wavelength, Angle a. Roughed aluminum; θ i 1, 45, 75 ; λ2μm b. Roughed aluminum; θ i 1, 3, 45, 6, 75 ; λ.5μm b. Roughed magnesium oxide; θ i 1, 45, 6, 75 ; λ.5μm
Phong s Shading First order approximation of photorealism, i.e., a linear combination of the three illumination components diffuse, specular and ambient.
Diffuse component Phong s Shading I I d d I I i i k k d d cosθ ( L N ) θ 2π I i : intensity of a point light source Θ: angle between light direction (L) and surface normal (N) kd: wavelength-dependent (empirical) reflectance coefficient For more than one light source: Id k d Ii, n ( Ln N ) n
Specular component Phong s Shading I s I I i i k k s s cos n ( R V Ω ) n n: surface roughness index
Surface Roughness Index Large n (glossy surface) small n (rough surface)
Specular + Diffuse Phong s Shading
Specular + Diffuse (rendered version) Phong s Shading
Phong s Shading Specular + Diffuse + Ambient Ambient illumination a i g k I I ) ) ( ) ( ( n s d i a a k k k V R N L I I I + + ) ) /( ) ( ) ( ( k r k k k n s d i a a + + + V R N L I I I where (r+k) is the distance consideration.
Phong s Shading Geometric Considerations Let H (L+V)/2 I I k + I ( k ( L N ) + k ( N H ) ) /( r + k) a a i d s n
Phong s Shading Geometric Considerations Comparison of using (a) R.V and (b) N.H.
Summary of Phong Model 1. Point light sources. 2. No geometry except surface normal is considered (i.e., lights and viewers are located at infinity.) 3. Diffuse and specular terms are modeled as local components. 4. Surface roughness is modeled by the decrease of specular term around reflection vector. 5. Color of specular reflection is assumed to be of light source (i.e., highlights are always white regardless of the material.) 6. Assume constant global (ambient) light.
A Defect of Phong Model Inaccurate in the specular term for illumination at low incidence angles.
Cook and Torrance Model Based on incident energy instead of intensity. Using a physical microfacet model to determine the specular term. Using Fresnel s law and material characteristics to determine color changes within the highlights.
Cook and Torrance Model BDRF sr s + dr d where s + d 1 Global ambient term I a R a f Similar to Phong s Shading: + + n s a n i n n i a a s d d f ) ( ) (,, R R L N I R I I ω
Cook and Torrance Model (cont.) The reflection vector, R, is physically modeled based on the microfacet descript of the surface. N, average surface normal Microfacet model of a reflection surface.
Cook and Torrance Model (cont.) FDGsRF: NVNLπ ( )( ) the Fresnel term theoretical reflection coefficient (tangent plane approximation) D: distribution function for the microfacets G: attenuation factor caused by microfacet shadowing effect
Cook and Torrance Model (cont.) D: distribution function for microfacets k exp[ ( α / m) k: a constant α: angle of microfacet with respect to (mean) surface normal (i.e., angle between N and H) 2 ] Beckmann-Spizzichino distribution:d m: root mean square slope the microfacetd1 2 exp[ (tan α / 2 )] m cos m 2 4 α
Cook and Torrance Model (cont.) F, the Fresnel term, tangent plane approximation
Cook and Torrance Model (cont.) F, the Fresnel term 1 2 sin sin 2 2 2 ( φfθ ) tan ( φ θ ) + 2 ( φ + θ ) tan ( φ + θ ) φ: angle of incidence θ: angle of refraction sinθ sinψ/η and η: refractive index of material
Cook and Torrance Model (cont.) F, the Fresnel term (cont.) 2 2 1 1 1) ( 1) ( FF + + µ η η for φ 1 cos 1) ) ( ( 1) ) ( ( 1 ) ( ) ( 2 1 ) ( tan ) ( tan ) ( sin ) ( sin 2 1 2 2 2 2 2 2 2 2 2 2 2 + + + + + + + + c g c where c g c c g c c g c g η φ θ φ θ φ θ φ θ φhvffη so η is a function of wavelength from (measured) F.
(a) F as a function of wavelength and angle of incidence (b) F(ψ) at r, g, b wavelengths.
Cook and Torrance Model (cont.) (a) Microfacet orientation distributions (b) Gaussian distributions with m.2.8
Cook and Torrance Model (cont.) G: attenuation factor Shadowing: interference in the incident light Masking: interference in the reflected light s 1 l1 / l2 HG2( )( VHN H2( V)( H max(min{1, N Gshadowing Gm NNGmasking G s V, L) ) m G}, )
Interference of attenuation factor: (a) no interference; (b) masking; (c) shadowing.
The degree of masking and shadowing depends on the ratio l 1 /l 2 the proportions of the facets contributing to the reflection.
Cook and Torrance v.s. Phong Phong Model Cook-Torrance Model Note the large lobe in C-T model and the non-coincidence of the lobe center with the reflection vector.
Rendering the Collection of operations necessary to project a view of an object or a scene onto a view surface A computer calculation of the amount of light falling on each visible surface of the objects in the "scene," as seen from the point of view of the computer "camera" (the viewer's eye point). During the rendering process, surface properties of objects are taken into account as are the colors of both the objects and the "lights" shining on them.
A Typical 3D Rendering Pipeline Local coordinate space Object definition Modeling trans. World coordinate space Compose scene View Reference Lighting Cull View trans. View space Clip to 3D view volume 3D screen space Hidden surface removal Rasterization Shading Display space
3D Rendering Example
3D Rendering Example (cont.)
Culling Operations to remove polygons that cannot be seen backface elimination For a scene contains only a single convex object hidden surface removal visibility : N > N p N p : polygon normal N: line of sight vector
Culling Visibility test.
Clipping Test the objects against the viewing frustum: Case 1: completely outside discard Case 2: completely inside transform and render Case 3: intersect with clip then transform and render w X w w Y w Z w Clipping limits
Sutherland-Hodgman Clipper
Four possibilities Sutherland-Hodgman Clipper
Sutherland-Hodgman Clipper ) ) ( ( : ) ( ) ( 1 ) ( ) ( < > + X P N X F N X S N S F S P t and t t t c c c S is outside F is inside Inside/Outside test
Gouraud Shading Restricted to the diffuse component of the reflection model Suffers from Mach banding k ( ) /( r + k) i d light IAssume is at infinity L.N is constant. NLNow calculate intensities at vertices and use bilinear interpolation to get all intensities.
The Vertex Normal -- N A N 1 N A N 4 N 2 N 3
Vertex Normals and Clipping N 1 Clip boundary N 2 Inside Outside N 1 N' 2 N' 2 is interpolated from N 1 and N 2.
Scan Line Interpolations Scan line y s (x a, y s ) I a I 1 I s (x 1, y 1 ) I b (x b, y s ) I 4 (x 4, y 4 ) I 2 (x 2, y 2 ) I 3 (x 3, y 3 )
Scan Line Interpolations (cont.) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) intensity change to - pixel - : pixel along scan line dist. :incremental 1 1 1 1,, 2 1 1 2 4 1 4 1 1 2 2 1 2 1 I x x x x x x I x x x x y y I y y y y y y I y y y y s n s n s a b a b s a s s b a b s s s b s s a + + + + IIIIIIIIIIII
Rasterization (a) Line drawing and (b) polygon filling rasterization.
Rasterization: Polygon Generate pairs of segment points edge list (xs,ys) (xe,ye): start and end points of an edge x xs m (xe xs)/(ye ys) for (y ys; y < ye; y+dy) { output(round(x), y) x + m }
Rasterization: Polygon (cont.)
Hidden Surface Removal Depth of an object (in screen space): z z s v f (1 d / zv ) f d z s f f d ( f fd d) z v Compare depths (in screen space) of all points with the same (x s,y s ) and determine which (parts of) surfaces are invisible (hidden).
Hidden Surface Removal Depth of an object (in screen space): z z s v f (1 d / zv ) f d z s f f d ( fd f d) z v
Z-Buffer Algorithm 1. Store z s values of vertices. 2. For pixels inside a polygon, get the depth of current point, z c, by interpolation. 3. Compare z c with the current z min, if z c is less than z min, write the (interpolated) intensity of current pixel to the frame buffer. Advantages: independent of object representation form; simple, easy to implement Disadvantages: memory hog
Volume Rendering For surfaces: color-opacity model c f : surface color o: surface opacity c b : background colors Total color: c c f o + c b (1 o) For volumes: dense emitter model c c( z)exp ( ) o( ζ ) dζ dz c( z), o( ζ ) :color and opacity of the object at z
Volume Rendering Surfaces Volumes
Volume Rendering
(False) Volume Rendering