CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
03/12/02 (c) 2002 University of Wisconsin, CS559 Last Time Some Visibility (Hidden Surface Removal) algorithms –Painter’s Draw in some order Things drawn.
Hidden Surface Removal CSE 581. Visibility Assumption: All polygons are opaque What polygons are visible with respect to your view frustum?  Outside:
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
CECS461 Computer Graphics II University of Missouri at Columbia Hidden Surface Removal.
Hidden Surface Removal Why make the effort?  Realistic models.  Wasted time drawing. OpenGL and HSR  OpenGL does handle HSR using the depth buffer.
Visibility in Computer Graphics Toni Sellarès Unversitat de Girona
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Hidden Surface Removal 고려대학교 컴퓨터 그래픽스 연구실.
Part I: Basics of Computer Graphics
UBI 516 Advanced Computer Graphics
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.
Visible-surface Detection Computer Graphics Seminar MUM
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Hidden Surface Removal
Graphics Pipeline Hidden Surfaces CMSC 435/634. Visibility We can convert simple primitives to pixels Which primitives (or parts of primitives) should.
Graphics Pipeline Hidden Surface CMSC 435/634. Visibility We can convert simple primitives to pixels/fragments How do we know which primitives (or which.
CS 450: COMPUTER GRAPHICS VISIBLE SURFACE DETECTION SPRING 2015 DR. MICHAEL J. REALE.
Visible-Surface Detection Jehee Lee Seoul National University.
Hidden Surface Removal 1.  Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially.
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.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Binary Space Partitioning Trees Ray Casting Depth Buffering
CS 376 Introduction to Computer Graphics 03 / 21 / 2007 Instructor: Michael Eckmann.
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.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.
Visible Surface Detection
Computer Graphics I, Fall 2010 Implementation II.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
Visible surface determination. Problem outline Given a set of 3D objects and a viewing specification, we wish to determine which lines or surfaces are.
1 Computer Graphics Week11 : Hidden Surface Removal.
Learning Objectives Classification of Visible Surface Detection Algorithms Classification of Visible Surface Detection Algorithms Back-Face Detection Back-Face.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Lecture 30: Visible Surface Detection
Visible surface determination

Visible Surface Detection
Computer Graphics Implementation II
Photorealistic Rendering vs. Interactive 3D Graphics
Week 2 - Friday CS361.
Solid Area Scan Conversion or Visible Surface Detection
Hidden Surface Removal
CSC418 Computer Graphics Back Faces Visibility Algorithms.
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Visible-Surface Detection Methods
Hidden Surfaces Dr. Scott Schaefer.
3D Graphics Rendering PPT By Ricardo Veguilla.
Graphics Pipeline Hidden Surfaces
CSCE 441: Computer Graphics Hidden Surface Removal
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Implementation II Ed Angel Professor Emeritus of Computer Science
Visibility: Z Buffering Week 10, Mon 3 Nov 2003
Visibility (hidden surface removal)
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Hidden Surface Removal
Introduction to Computer Graphics with WebGL
CSCE 441: Computer Graphics Ray Tracing
The Framebuffer 1 Lecture 37 Fri, Nov 30, 2007.
Hidden Surface Removal
Implementation II Ed Angel Professor Emeritus of Computer Science
Visible-Surface Determination
Presentation transcript:

CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai

Outline Backface Culling Painter’s algorithm BSP Z-buffer Ray casting Reading: section 16-1 to 16-11, 16-14,16-15

Review: Backface Culling , draw polygon view direction

Review: Painter’s Example z = 0.7 z = 0.3 z = 0.1 Sort by depth: Green rect Red circle Blue tri z = 0

Review: Painter’s Algorithm Sort all objects’ zmin and zmax If an object is uninterrupted (its zmin and zmax are adjacent in the sorted list), it is fine If 2 objects DO overlap 3.1 Check if they overlap in x - If not, they are fine 3.2 Check if they overlap in y - If yes, need to split one

Review: Building a BSP Tree 6 7-2 5-2 3 7-1 5-1 1 2 4 1 b 3 7-1 f b 7-2 f b b 4 6 2 b f 5-1 5-2

Rendering with a BSP Tree How to traverse the tree Draw “back” polygons Draw “on” polygons Draw “front” polygons 1 b 3 7-1 f b 7-2 f b b 4 6 2 b f 5-1 5-2

Different View Points? 6 7-2 5-2 3 7-1 5-1 1 2 4 1 1 V0 3 b 3 f b Do we need to build a new tree? 7-1 7-2 f b b 4 6 2 b f 5-1 5-2

Different View Points? 6 7-2 5-2 3 7-1 5-1 1 2 4 1 1 3 7-1 b 3 7-1 f b Do we need to build a new tree? - No, we use the same tree if objects are static 7-2 f b b 4 6 2 b f 5-1 5-2

Different View Points? 6 7-2 5-2 3 7-1 5-1 1 2 4 1 1 V0 3 b 3 f b Do we need to build a new tree? - No, we use the same tree if objects are static How can we traverse the tree? 7-1 7-2 f b b 4 6 2 b f 5-1 5-2

Rendering with a BSP Tree If eye is in front of plane Draw “back” polygons Draw “on” polygons Draw “front” polygons If eye is behind plane Else eye is on plane - 6 + 4 5 7 1 3 2 Vnew V0 5 f b 1,2,3,4 6,7

Rendering with a BSP Tree If eye is in front of plane Draw “back” polygons Draw “on” polygons Draw “front” polygons If eye is behind plane Else eye is on plane - 6 + 4 5 7 1 3 2 Vnew V0 5 f b 1,2,3,4 6,7

Different View Points? - + Vnew 6 7-2 5-2 3 7-1 5-1 1 1 2 4 1 V0 3 7-1 b 3 + 7-1 f b 7-2 f b b 4 6 Traversal order: 2 b f 5-1 5-2

Different View Points? Vnew 6 7-2 5-2 3 7-1 5-1 1 1 2 4 1 V0 3 7-1 7-2 b 3 7-1 f b 7-2 f b b 4 6 Traversal order: 1 2 b f 5-1 5-2

Different View Points? - + Vnew 6 7-2 5-2 3 7-1 5-1 1 1 2 4 1 V0 3 7-1 b 3 7-1 f b 7-2 f b b 4 6 Traversal order: 1 2 b f 5-1 5-2

Different View Points? - + Vnew 6 7-2 5-2 3 7-1 5-1 1 1 2 4 1 V0 3 7-1 b 3 7-1 f b 7-2 f b b 4 6 Traversal order: 1 2 b f 5-1 5-2

Different View Points? - + Vnew 6 7-2 5-2 3 7-1 5-1 1 1 2 4 1 V0 3 7-1 b 3 7-1 f b 7-2 f b b 4 6 Traversal order: 1->2 2 b f 5-1 5-2

Different View Points? - + Vnew 6 7-2 5-2 3 7-1 5-1 1 1 2 4 1 V0 3 7-1 b 3 7-1 f b 7-2 f b b 4 6 Traversal order: 1->2->(7-1) 2 b f 5-1 5-2

Different View Points? - + Vnew 6 7-2 5-2 3 7-1 5-1 1 1 2 4 1 V0 3 7-1 b 3 7-1 f b 7-2 f b b 4 6 Traversal order: 1->2->(7-1)->4 2 b f 5-1 5-2

Different View Points? Vnew 6 7-2 5-2 3 7-1 5-1 1 1 2 4 1 V0 3 7-1 7-2 b 3 7-1 f b 7-2 f b b 4 6 Traversal order: 1->2->(7-1)->4->(5-1)->3->(7-2)->(5-2)->6 2 b f 5-1 5-2

Summary: BSP Trees Pros: Simple, elegant scheme No depth comparisons needed Polygons split and ordered automatically Works for moving cameras Only writes to framebuffer (i.e., painters algorithm)

Summary: BSP Trees Cons: Computationally intense preprocess stage restricts algorithm to static scenes Splitting increases polygon count Redraws same pixel many times Choosing splitting plane not an exact science Not suitable for moving objects

Outline Backface Culling Painter’s algorithm BSP Z-buffer Ray casting Reading: section 9-1 to 9-11, 9-14,9-15

Depth (“Z”) Buffer Simple modification to scan-conversion Maintain a separate buffer storing the closest “z” value for each pixel—depth buffer Only draw pixel if depth value is closer than stored “z” value Update buffer with closest depth value Work in normalized coordinate space [0.0…1.0]

NOTE: Can draw these shapes in any order Z-Buffering Example z = 1.0 z = 1.0 z = 0.3 z = 0.7 z = 0.3 z = 0.1 z = 1.0 z = 0.3 z = 0.1 z = 1.0 z = 0.7 z = 0.3 z = 0.1 NOTE: Can draw these shapes in any order

Depth Buffer Algorithm Initialize the depth buffer and frame buffer for every pixel - depthBuff(x,y)=1.0; - frameBuff(x,y)=backgndColor; Process each polygon in a scene, one at a time. - for each pixel (x,y), calculate the depth z (if not already known). - if z <depthBuff(x,y), compute the surface color at (x,y) and set depthBuff(x,y)=z; frameBuff(x,y)=surfColor(x,y);

How to Calculate “z”? This is easy to implement for polygon surfaces v0 p=[x,y,z] v1 v2 Given the pixel coordinates (x,y), how to calculate the z value? use plane normal

How to Calculate “z”? This is easy to implement for polygon surfaces v0 p=[x,y,z] v1 v2 Plane normal (p-v0)∙((v2-v0)x(v1-v0))=0 Plane equation: Ax+By+Cz+D=0 P=[x,y,z]

How to Calculate “z”? This is easy to implement for polygon surfaces How can we speed up the calculation? Plane equation: Ax+By+Cz+D=0 p=[x,y,z]

How to Calculate “z”? This is easy to implement for polygon surfaces How can we speed up the calculation? - scan line conversion Plane equation: Ax+By+Cz+D=0 p=[x,y,z]

How to Calculate “z”? Update “z” values using scan line conversion algorithm

How to Calculate “z”? Update “z” values using scan line conversion algorithm Plane equation: Ax+By+Cz+D=0

How to Calculate “z”? Update “z” values using scan line conversion algorithm Plane equation: Ax+By+Cz+D=0

How to Calculate “z”? Update “z” values using scan line conversion algorithm Plane equation: Ax+By+Cz+D=0

How to Calculate “z”? Update “z” values using scan line conversion algorithm Plane equation: Ax+By+Cz+D=0

How to Calculate “z”? Update “z” values using scan line conversion algorithm Plane equation: Ax+By+Cz+D=0

How to Calculate “z”? Update “z” values using scan line conversion algorithm Plane equation: Ax+By+Cz+D=0 What’s the x,y,z value for this pixel?

How to Calculate “z”? Update “z” values using scan line conversion algorithm Plane equation: Ax+By+Cz+D=0 What’s the xk+1,yk+1,zk+1 values for the next horizontal pixel?

Depth (“Z”) Buffer Advantages Disadvantages Always works. The nearest object always determines the color of a pixel Polygon drawn in any order Commonly in hardware Disadvantages Needs a whole extra buffer (depth buffer) Requires extra storage space (How big?) Still lots of overdraw

Depth (“Z”) Buffer Advantages Disadvantages Always works. The nearest object always determines the color of a pixel Polygon drawn in any order Commonly in hardware Disadvantages Needs a whole extra buffer Requires extra storage space (How big?) (1k*1k*24bits) Still lots of overdraw

Outline Backface Culling Painter’s algorithm BSP Z-buffer Ray casting Reading: section 9-1 to 9-11, 9-14,9-15

Ray Casting Key idea: for every pixel, cast a ray, find the closest point on the object and draw the point

Ray Casting For each pixel enter Pij - Send a ray from eye point, c, through pij into scene - Intersect ray with each object - Select the nearest intersection Effective for scenes with curved surfaces, particularly sphere

Ray Casting Implementation - Might parameterize each ray as - Each object Ok returns tk>0 such that first intersection with ok occurs at r(tk)

Ray Casting Implementation - Might parameterize each ray as - Each object Ok returns tk>0 such that first intersection with ok occurs at r(tk) Intersection with polygons?

Ray Casting Implementation - Might parameterize each ray as - Each object Ok returns tk>0 such that first intersection with ok occurs at r(tk) Intersection with polygons? Ray equation: Plane equation: Ax+By+Cz+D=0 Plug in and calculate the parameter value t!

Ray Casting Implementation - Might parameterize each ray as - Each object Ok returns tk>0 such that first intersection with ok occurs at r(tk) Intersection with spheres? Plug in and calculate the parameter value t!

Ray Casting Implementation - Might parameterize each ray as - Each object Ok returns tk>0 such that first intersection with ok occurs at r(tk) Intersection with spheres? Ray equation: Sphere equation: (x-x0)2+(y-y0)2+(z-z0)2=r2 Plug in and calculate the parameter value t!

Ray Casting Implementation - Might parameterize each ray as - Each object Ok returns tk>0 such that first intersection with ok occurs at r(tk) Intersection with curved surfaces? Ray equation: Curved surface equation: f(x,y,z)=0 Plug in and calculate the parameter value t!

Ray Casting Implementation - Might parameterize each ray as - Each object Ok returns tk>0 such that first intersection with ok occurs at r(tk) - Q: given the set {tk}, what is the first intersection point?

Ray Casting Implementation - Might parameterize each ray as - Each object Ok returns tk>0 such that first intersection with ok occurs at r(tk) - Q: given the set {tk}, what is the first intersection point?

Ray Casting Ray casting properties: - process pixels one at a time - draw each visible pixel once - efficient algorithm needed for ray-object intersection - may (not) use pixel coherence - simple but generally not used

Hidden Surface Removal: opengl Backface culling - glEnable(GL_CULL_FACE), glDisable(GL_CULL_FACE) - glCullFace(GL_BACK) , cull polygon view direction

Z-buffer: opengl In opengl, depth values are normalized to [0.0,1.0] - Specify depth-buffer operations glutInitDisplayMode // with argument GLUT_DEPTH - Specify initial depth-buffer value glClear(GL_DEPTH_BUFFER_BIT) // initialize depth-buffer values to 1.0 glClearDepth (depth) // specify an initial depth-buffer value - Activate depth-testing operations glEnable (GL_DEPTH_TEST)

Summary Backface Culling Painter’s algorithm BSP Z-buffer Ray casting