
Last Time? • Planar Shadows frame buffer • Projective Texture Shadows depth buffer The Traditional • Shadow Maps Graphics Pipeline • Shadow Volumes stencil buffer – Stencil Buffer Skipped Last Time: Today • “Rendering Fake Soft Shadows with • Ray Casting / Tracing vs. Scan Conversion Smoothies”, Chan & Durand, 2003. • Traditional Graphics Pipeline shadow shadow volumes • Clipping volumes w/ “smoothies” • Rasterization/Scan Conversion Ray Casting / Tracing How Do We Render Interactively? • Advantages? • Use graphics hardware (the graphics pipeline), via – Smooth variation of normal, silhouettes OpenGL, MesaGL, or DirectX – Generality: can render anything that can be intersected with a ray – Atomic operation, allows recursion • Disadvantages? – Time complexity (N objects, R pixels) – Usually too slow for interactive applications – Hard to implement in hardware (lacks computation coherence, must fit entire scene in memory) Graphics Pipeline (OpenGL) Ray Tracing • Most global effects available in ray tracing will be sacrificed, but some can be approximated 1 Scan Conversion Limitations of Scan Conversion • Given a primitive's vertices & • Restricted to scan-convertible primitives glBegin(GL_TRIANGLES) the illumination at each vertex: glNormal3f(...) – Object polygonization glVertex3f(...) • Faceting, shading artifacts • Figure out which glVertex3f(...) pixels to "turn on" glVertex3f(...) • Effective resolution is to render the primitive glEnd(); hardware dependent • Interpolate the • No handling of shadows, ray tracing reflection, transparency illumination values to "fill in" the primitive • Problem of overdraw (high depth complexity) • At each pixel, keep track of • What if there are the closest primitive (z-buffer) many more triangles scan conversion scan conversion than pixels? flat shading gouraud shading Ray Casting vs. Rendering Pipeline Ray Casting vs. Rendering Pipeline Ray Casting Rendering Pipeline Ray Casting Rendering Pipeline For each pixel For each triangle For each pixel For each triangle For each object For each pixel For each object For each pixel • Whole scene must be in • Primitives processed one at a Send pixels into the scene Project scene to the pixels memory time Discretize first Discretize last • Depth complexity: no • Coherence: geometric computation for hidden parts transforms for vertices only • Atomic computation • Early stages involve analytic • More general, more flexible processing – Primitives, lighting effects, • Computation increases with adaptive antialiasing depth of the pipeline – Good bandwidth/computation ratio • Sampling occurs late in the pipeline • Minimal state required Questions? Today • Ray Casting / Tracing vs. Scan Conversion • Traditional Graphics Pipeline • Clipping • Rasterization/Scan Conversion 2 The Graphics Pipeline The Graphics Pipeline Modeling Modeling • Primitives are processed in a series Transformations Transformations of stages Illumination Illumination (Shading) (Shading) • Each stage forwards its result on to Viewing Transformation Viewing Transformation the next stage (Perspective / Orthographic) (Perspective / Orthographic) • The pipeline can be drawn and Clipping Clipping implemented in different ways Projection Projection • Some stages may be in hardware, (to Screen Space) (to Screen Space) others in software Scan Conversion Scan Conversion • Optimizations & additional (Rasterization) (Rasterization) programmability are available at Visibility / Display Visibility / Display some stages Modeling Transformations Illumination (Shading) (Lighting) Modeling Modeling • Vertices lit (shaded) according to Transformations • 3D models defined in their own Transformations coordinate system (object space) material properties, surface Illumination Illumination properties (normal) and light sources (Shading) • Modeling transforms orient the (Shading) • Local lighting model Viewing Transformation models within a common Viewing Transformation (Perspective / Orthographic) (Perspective / Orthographic) (Diffuse, Ambient, Phong, etc.) coordinate frame (world space) Clipping Clipping Projection Projection (to Screen Space) (to Screen Space) Scan Conversion Scan Conversion (Rasterization) (Rasterization) Object space World space Visibility / Display Visibility / Display Viewing Transformation Clipping Modeling • Maps world space to eye space Modeling • Transform to Normalized Device Transformations Transformations Coordinates (NDC) Illumination • Viewing position is transformed Illumination (Shading) to origin & direction is oriented (Shading) Viewing Transformation Viewing Transformation (Perspective / Orthographic) along some axis (usually z) (Perspective / Orthographic) Clipping Clipping Eye space NDC Eye space • Portions of the object Projection Projection (to Screen Space) (to Screen Space) outside the view volume Scan Conversion Scan Conversion (Rasterization) (Rasterization) (view frustum) are removed Visibility / Display World space Visibility / Display 3 Projection Scan Conversion (Rasterization) Modeling Modeling Transformations • The objects are projected to the Transformations • Rasterizes objects into pixels Illumination 2D image place (screen space) Illumination • Interpolate values as we go (Shading) (Shading) (color, depth, etc.) Viewing Transformation Viewing Transformation (Perspective / Orthographic) (Perspective / Orthographic) Clipping NDC Screen Space Clipping Projection Projection (to Screen Space) (to Screen Space) Scan Conversion Scan Conversion (Rasterization) (Rasterization) Visibility / Display Visibility / Display Visibility / Display Questions? Modeling Transformations • Each pixel remembers the Illumination closest object (depth buffer) (Shading) Viewing Transformation (Perspective / Orthographic) Clipping • Almost every step in the graphics pipeline involves a Projection (to Screen Space) change of coordinate system. Scan Conversion Transformations are central to (Rasterization) understanding 3D computer Visibility / Display graphics. Today Common Coordinate Systems • Ray Casting / Tracing vs. Scan Conversion • Object space – local to each object • Traditional Graphics Pipeline • World space • Clipping – common to all objects – Coordinate Systems • Eye space / Camera space • Rasterization/Scan Conversion – derived from view frustum • Clip space / Normalized Device Coordinates (NDC) – [-1,-1,-1] → [1,1,1] • Screen space – indexed according to hardware attributes 4 Coordinate Systems in the Pipeline Normalized Device Coordinates Modeling Object space • Clipping is more efficient in a rectangular, axis-aligned Transformations volume: (-1,-1,-1) → (1,1,1) OR (0,0,0) → (1,1,1) Illumination (Shading) World space Viewing Transformation (Perspective / Orthographic) Eye Space / Clipping Camera Space Projection (to Screen Space) Clip Space (NDC) Scan Conversion (Rasterization) Screen Space Visibility / Display What if the pz is > eyez? What if the pz is < eyez? z axis +→ z axis +→ (eyex, eyey, eyez) (eyex, eyey, eyez) image plane image plane What if the pz ≈ eyez? Clipping • Eliminate portions of objects outside the viewing frustum far • View Frustum – boundaries of the image top plane projected in 3D left z axis +→ (eye , eye , eye ) – a near & far x y z clipping plane • User may define additional clipping right ??? near image plane planes bottom 5 Why Clip? Clipping Strategies • Avoid degeneracies • Don’t clip (and hope for the best) – Don’t draw stuff • Clip on-the-fly during rasterization behind the eye – Avoid division • Analytical clipping: alter input geometry by 0 and overflow • Efficiency – Don’t waste time on objects outside the image boundary • Other graphics applications (often non-convex) – Hidden-surface removal, Shadows, Picking, Binning, CSG (Boolean) operations (2D & 3D) The Graphics Pipeline Questions? Modeling Transformations • Former hardware relied on Illumination full clipping (Shading) • Modern hardware mostly Viewing Transformation (Perspective / Orthographic) avoids clipping – Only with respect to Clipping plane z=0 Projection (to Screen Space) • In general, it is useful to learn Scan Conversion clipping because it is similar (Rasterization) to many geometric algorithms Visibility / Display Today 2D Scan Conversion • Ray Casting / Tracing vs. Scan Conversion • Geometric primitives • Traditional Graphics Pipeline (point, line, polygon, circle, polyhedron, sphere... ) • Primitives are continuous; screen is discrete • Clipping • Scan Conversion: algorithms for efficient generation of • Rasterization/Scan Conversion the samples comprising this approximation – Line Rasterization – Triangle Rasterization 6 Scan Converting 2D Line Segments Line Rasterization Requirements • Given: • Transform continuous primitive into – Segment endpoints (integers x1, y1; x2, y2) discrete samples • Identify: • Uniform thickness & brightness – Set of pixels (x, y) to display for segment • Continuous appearance • No gaps • Accuracy • Speed Algorithm Design Choices Naive Line Rasterization Algorithm • Assume: • Simply compute y as a function of x – m = dy/dx, 0 < m < 1 – Conceptually: move vertical scan line from x1 to x2 • Exactly one pixel per column – What is the expression of y as function of x? – fewer → disconnected, more → too thick – Set pixel (x, round (y(x))) Efficiency Bresenham's Algorithm (DDA) • Computing y value is expensive • Select pixel vertically closest to line segment – intuitive, efficient, pixel center always within 0.5 vertically • Generalize to handle all eight octants using symmetry • Observe: y += m at each x step (m = dy/dx) • Can
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages9 Page
-
File Size-