3D Rendering Pipeline Hidden Surface Removal 3D Primitives

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Visible-Surface Detection(identification)
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Graphics Pipeline.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Hidden Surface Removal 고려대학교 컴퓨터 그래픽스 연구실.
2 D viewing Prepared by Elizabeth Isaac DCS, RSET.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Spatial Data Structure: Quadtree, Octree,and BSP tree Mengxia Zhu Fall 2007.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Hidden Surface Removal
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Two-Dimensional Viewing
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Visible-Surface Detection Jehee Lee Seoul National University.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Hidden Surface Removal
Implementation II.
1 3D Hidden Surface Removal 김 성 남. 2 Contents Goal Motivation Approaches - back face detection - depth buffer - A-buffer - Scan line - Depth.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Computer Graphics I, Fall 2010 Implementation II.
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Perspective View Volume View Volume Far Near Window Far Near Window Center of Projection Center of Projection (a) Original Orientation (b) After Transformation.
Three-Dimensional Viewing Clipping Computer Graphics C Version (456p - 462p)
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Chapter 71 Computer Graphics - Chapter 7 From Vertices to Fragments Objectives are: How your program are processed by the system that you are using, Learning.
Visible surface determination
3D Rendering 2016, Fall.
Three Dimensional Viewing
Visible Surface Detection
Rendering Pipeline Fall, 2015.
Computer Graphics Implementation II
Solid Area Scan Conversion or Visible Surface Detection
Hidden Surface Removal
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
Computer Graphics Shading in OpenGL
BACK FACE DETECTION back-face detection Determination of whether a face of an object is facing backward and therefore invisible. The usual test is whether.
Computer Graphics Viewing
2D Viewing & Clipping 한신대 류승택
Visible-Surface Detection Methods
3D Graphics Rendering PPT By Ricardo Veguilla.
3D Clipping.
Models and Architectures
Implementation I Ed Angel
Graphics Pipeline Clipping
Models and Architectures
CSCE 441: Computer Graphics Hidden Surface Removal
Models and Architectures
Introduction to Computer Graphics with WebGL
WINDOWING AND CLIPPING
Implementation II Ed Angel Professor Emeritus of Computer Science
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
Visibility (hidden surface removal)
Models and Architectures
Hidden Surface Removal
Models and Architectures
Introduction to Computer Graphics with WebGL
Clipping Clipping Sutherland-Hodgman Clipping
Clipping University of British Columbia CPSC 314 Computer Graphics
Implementation I Ed Angel Professor Emeritus of Computer Science
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

3D Rendering Pipeline Hidden Surface Removal 3D Primitives 3D Modeling Coordinates Model Transformation 3D World Coordinates Lighting 3D World Coordinates Viewing Transformation 3D Viewing Coordinates Projection Transformation 2D Projection Coordinates Clipping Hidden Surface Removal 2D Projection Coordinates Viewport Transformation 2D Device Coordinates Scan Conversion 2D Device Coordinates Image cgvr.korea.ac.kr

Mapping to viewport Mapping positions within a rectangular view volume to a 3D rectangular viewport is done with combination of scaling & translation as: Where Dx, Dy, Dz are ratios of the dimensions of the viewport and rectangular parallelopiped view volume in the x, y and z directions. cgvr.korea.ac.kr

Viewport Clipping 6-bit region codes are assigned that identifies the relative position of the point w.r.t. the viewport. For a line endpoint at position (x,y,z), we assign the bit positions in the region code from right to left as, bit 1 = 1, if x<xvmin (left) bit 2 = 1, if x>xvmax (right) bit 3 = 1, if y<yvmin (below) bit 4 = 1, if y>yvmax (above) bit 5 = 1, if z<zvmin (front) bit 6 = 1, if z>zvmax (back) cgvr.korea.ac.kr

If result is non-zero then both endpoints lie outside the viewport. If either endpoint doesnot have a region code 000000, we perform logical AND operation on both endpoints. If result is non-zero then both endpoints lie outside the viewport. Else Calculate intersections with bounding planes. cgvr.korea.ac.kr

If P1 = (x1, y1, z1) and P2 = (x2, y2, z2), parametric line equation is x = x1 + (x2 – x1)u, y = y1 + (y2 – y1)u, z = z1 + (z2 – z1)u, 0<=u<=1 (x, y, z) represent any point on the line between the two endpoints. At u = 0, we have the point P1 and u =1 puts us at P2. To find intersection of line with a plane of the viewport, we substitute the coordinate value for that plane into the appropriate parametric expression above and solve for u. eg. Suppose we test for a line against the zvmin plane of the viewport. cgvr.korea.ac.kr

When calculated value of u is not in range 0 to 1, line segment does not intersect the plane under consideration at any point between endpoints P1 & P2. If calculated value is within the range, calculate intersections x and y coordinates as: If either xI or yI is not in the range of the boundaries of the viewport, then this line intersects the front plane beyond the boundaries of the volume. cgvr.korea.ac.kr

Hidden Surface Removal

Hidden Surface Removal Motivation Algorithms for HSR Back-face detection Painter’s algorithm Ray casting Scan-line Z-buffer Area subdivision Tradeoffs cgvr.korea.ac.kr

Motivation Surfaces may be Back-Facing: Surfaces may be Occluding: Polygon Viewer Viewer Occluding Polygon Occluded Polygon cgvr.korea.ac.kr

Motivation Surfaces may be Overlapping: Surfaces may be Intersecting: Viewer Viewer cgvr.korea.ac.kr

Visible surface detection algorithms are of 2 types: Whether they deal with object definitions directly (object space methods): compares objects & parts of objects to each other within the scene definition to determine which surfaces as a whole we should label as visible. Whether they deal with their projected images (image-space methods): visibility is decided point by point at each pixel position on the projection plane. cgvr.korea.ac.kr

Algorithms Back-Face Detection Z-Buffer Painter’s Algorithm Ray Casting Scan-Line Area Subdivision cgvr.korea.ac.kr

Viewing Transformation Back-Face Detection Do not Render any Surface Oriented Away from Viewer yv xv zv V N=(A,B,C) Back-Facing Polygon V N Model Transformation Lighting Viewing Transformation 3D Primitives Viewer Polygon is back-facing to the viewer if V•N > 0 cgvr.korea.ac.kr

Back-Face Detection xv yv zv V Uses inside outside test for identifying the back faces of a polyhedron. A point (x,y,z) is inside a polygon surface with plane parameters A, B, C, D if Ax + By + Cz + D < 0 When an inside point is along the line of sight to the surface, the polygon must be a back face Consider the normal vector N to a polygon surface, which has Cartesian components (A, B, C). In general if V is a vector in the viewing direction from the eye (or camera) position then this polygon is a back face if V.N >0 yv xv zv V N=(A,B,C) cgvr.korea.ac.kr

Back-Face Detection xv yv zv V If object descriptions have been converted to projection coordinates and our viewing direction is parallel to the viewing zv axis, then V=(0, 0, Vz) & V.N = VzC Thus we need to consider the sign of C, the z component of the normal vector N. In a right handed viewing system with viewing direction along the negative zv axis the polygon is a back face if C<0. also we cannot see any face whose normal has z component C = 0, since our viewing direction is grazing that polygon. Therefore any polygon is a back face if its normal vector has a z-component value C<=0 yv xv zv V N=(A,B,C) cgvr.korea.ac.kr

Z-Buffer or Depth-Buffer Method Algorithm: Store color and depth of closest surface for each pixel in frame buffer As scan convert, update only pixels whose (interpolated) depth is closer than the depth stored in the frame buffer z=3 z=1 Viewport Transformation Scan Conversion Image z=5 z=4 z=2 z=5 z=5 cgvr.korea.ac.kr

Z-Buffer Initialize the depth buffer and refresh buffer so that for all buffer positions (x, y) depth(x,y) =0, refresh(x,y) = Ibackground For each position on each polygon surface, compare depth values to previously stored values in the depth buffer to determine visibility. Calculate the depth z for each (x,y) position on the polygon If z>depth(x,y) then set depth(x,y) =z, refresh(x,y) = Isurf(x,y) Where Ibackground is the value of background intensity and Isurf(x,y) is the projected intensity value for the surface at pixel position (x,y). After all surfaces have been processed, the depth buffer contains depth values for the visible surfaces and the refresh buffer contains the corresponding intensity values for those surfaces. cgvr.korea.ac.kr

Depth value for a surface position (x,y) are calculated from the plane equation for each surface: z=(-Ax-By-D)/C For any scan line adjacent horizontal positions across line differ by 1 & vertical y value on adjacent scan line differs by 1. If depth of position (x,y) is z, then depth z’ of the next position (x+1,y) is z’= (-A(x+1)-By-D)/C=z-A/C Ratio -A/C is constant for each surface, so successive depth values across a scan line are obtained from preceding values with a single addition On each scan line we start by calculating the depth on a left edge of the polygon that intersects that scan line. Depth values at each successive position across the scan are then calculated cgvr.korea.ac.kr

Depth values are then obtained recursively as z’=z+(A/m + B)/C First determine the y-coordinate extents of each polygon and process the surface from the topmost scan line to the bottom scan line. Starting at a top vertex, recursively calculate x positions down a left edge of the polygon as x’=x-1/m, Depth values are then obtained recursively as z’=z+(A/m + B)/C If the processing is down a vertical edge, the slope is infinite & the recursive calculations reduce to z’=z+B/C cgvr.korea.ac.kr

Z-Buffer Comments Polygons can be rasterized in any order Requires lots of memory Requires per pixel processing, Commonly implemented in hardware cgvr.korea.ac.kr

Viewing Transformation Ray Casting Algorithm: Cast ray from viewpoint through each pixel to find front-most surface Model Transformation Lighting Viewing Transformation 3D Primitives A D E Viewer C View Plane B cgvr.korea.ac.kr

Ray Casting Comments O(plogn) for p pixels May (or may not) utilize pixel-to-pixel coherence Conceptually simple, but not generally used cgvr.korea.ac.kr

Viewport Transformation Scan-Line Algorithm: For each scan line, construct spans and sort by depth z=3 z=1 z=5 Scan Line z=4 z=2 Viewport Transformation Scan Conversion Image z=5 z=5 z=1.8 z=3.8 Example: Spans z=5 z=5 cgvr.korea.ac.kr

Scan-Line Comments Fully compute only front-most pixels Coherence along scan lines Commonly implemented in software cgvr.korea.ac.kr

Conclusion Hidden surface algorithms Hardware Software Back-face detection Depth sort Ray casting Z-buffer Scan-line Area subdivision Hardware Software cgvr.korea.ac.kr