CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.

Slides:



Advertisements
Similar presentations
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
Advertisements

8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
CSC418 Computer Graphics n Polygon normals n Back Faces n Visibility Algorithms.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Graphics Pipeline.
3D Graphics Rendering and Terrain Modeling
Lecture Fall 2001 Visibility Back-Face Culling Painter’s Algorithm.
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.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object.
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
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.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Object-Order vs. Screen-Order Rendering April 24, 2003.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
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.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
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
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
COMP 261 Lecture 16 3D Rendering. input: set of polygons viewing direction direction of light source(s) size of window. output: an image Actions rotate.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Week 2 - Friday.  What did we talk about last time?  Graphics rendering pipeline  Geometry Stage.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Visible-Surface Detection Jehee Lee Seoul National University.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
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.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Hidden Surface Removal
Implementation II.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
Computer Graphics I, Fall 2010 Implementation II.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Visible Surface Detection
- Introduction - Graphics Pipeline
Week 2 - Friday CS361.
Solid Area Scan Conversion or Visible Surface Detection
Hidden Surface Removal
CSC418 Computer Graphics Back Faces Visibility Algorithms.
Hidden Surfaces Dr. Scott Schaefer.
3D Graphics Rendering PPT By Ricardo Veguilla.
CS451Real-time Rendering Pipeline
CSCE 441: Computer Graphics Hidden Surface Removal
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Introduction to Computer Graphics with WebGL
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Visibility (hidden surface removal)
Presentation transcript:

CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu

Hidden surface Removal Drawing polygon faces on screen consumes CPU cycles We cannot see every surface in scene To save time, draw only surfaces we see Surfaces we cannot see and their elimination methods: Occluded surfaces: hidden surface removal (visibility) Back faces: back face culling Faces outside view volume: viewing frustrum culling Definitions: Object space: before vertices are mapped to pixels Image space: after vertices have been rasterized

Visibility (hidden surface removal) A correct rendering requires correct visibility calculations Correct visibility – when multiple opaque polygons cover the same screen space, only the front most one is visible (remove the hidden surfaces) wrong visibility Correct visibility

Visibility (hidden surface removal) Goal: determine which objects are visible to the eye Determine what colors to use to paint the pixels Active research subject - lots of algorithms have been proposed in the past (and is still a hot topic)

Visibility (hidden surface removal) Where is visiblity performed in the graphics pipeline? modeling and viewing v1, m1 v2, m2 v3, m3 per vertex lighting projection clipping interpolate vertex colors viewport mapping Rasterization texturing Shading visibility Display Note: Map (x,y) values to screen (draw) and use z value for depth testing

OpenGL - Image Space Approach  Determine which of the n objects is visible to each pixel on the image plane for (each pixel in the image) { determine the object closest to the pixel draw the pixel using the object’s color }

Image Space Approach – Z-buffer Method used in most of graphics hardware (and thus OpenGL): Z-buffer algorithm Requires lots of memory Basic idea: rasterize every input polygon Recall that we have z at polygon vertices For every pixel in the polygon interior, calculate its corresponding z value (by interpolation) Choose the color of the polygon whose z value is the closest to the eye to paint the pixel.

Image Space Approach – Z-buffer Recall: after projection transformation In viewport transformation x,y used to draw screen image z component is mapped to pseudo-depth with range [0,1] However, objects/polygons are made up of vertices Hence z is known at vertices Point in object seen through pixel may be between vertices Need to interpolate to find z

Z (depth) buffer algorithm How to choose the polygon that has the closet Z for a given pixel? Assumption for example: eye at z = 0, farther objects have increasingly negative values 1.Initialize (clear) every pixel in the z buffer to a very large negative value 2.Track polygon z’s. 3.As we rasterize polygons, check to see if polygon’s z through this pixel is less than current minimum z through this pixel 4.Run the following loop:

Z (depth) Buffer Algorithm For each polygon { for each pixel (x,y) inside the polygon projection area { if (z_polygon_pixel(x,y) > depth_buffer(x,y) ) { depth_buffer(x,y) = z_polygon_pixel(x,y); color_buffer(x,y) = polygon color at (x,y) } Note: we have depths at vertices. Interpolate for interior depths

Z buffer example eye Z = -.3 Z = -.5 Top View Final image

Z buffer example Step 1: Initialize the depth buffer

Z buffer example Step 2: Draw the blue polygon (assuming the OpenGL program draws blue polyon first – the order does not affect the final result any way). eye Z = -.3 Z =

Z buffer example Step 3: Draw the yellow polygon eye Z = -.3 Z = z-buffer drawback: wastes resources by rendering a face and then drawing over it

Combined z-buffer and Gouraud Shading (fig 8.31) For(int y = ybott; y <= ytop; y++) // for each scan line { find xleft and xright find dleft and dright, and dinc find colorleft and colorright, and colorinc for(int x = xleft, c = colorleft, d = dleft; x <= xright; x++, c+= colorinc, d+= dinc) if(d < d[x][y]) { put c into the pixel at (x, y) d[x][y] = d; // update the closest depth }

OpenGL HSR Commands Primarily three commands to do HSR glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB) instructs openGL to create depth buffer glEnable(GL_DEPTH_TEST) enables depth testing glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) initializes the depth buffer every time we draw a new picture

Back Face Culling Back faces: faces of opaque object which are “pointing away” from viewer Back face culling – remove back faces (supported by OpenGL) How to detect back faces? Back face

Back Face Culling If we find backface, do not draw, save rendering resources There must be other forward face(s) closer to eye F is face of object we want to test if backface P is a point on F Form view vector, V as (eye – P) N is normal to face F N V N Backface test: F is backface if N.V < 0 why??

Back Face Culling: Draw mesh front faces void Mesh::drawFrontFaces( ) { for(int f = 0;f < numFaces; f++) { if(isBackFace(f, ….) continue; glBegin(GL_POLYGON); { int in = face[f].vert[v].normIndex; int iv = face[v].vert[v].vertIndex; glNormal3f(norm[in].x, norm[in].y, norm[in].z; glVertex3f(pt[iv].x, pt[iv].y, pt[iv].z); glEnd( ); } Ref: case study 7.5, pg 406, Hill

View-Frustum Culling Remove objects that are outside the viewing frustum Done by 3D clipping algorithm (e.g. Liang-Barsky)

Ray Tracing Ray tracing is another example of image space method Ray tracing: Cast a ray from eye through each pixel to the world. Question: what does eye see in direction looking through a given pixel? Topic of graduate/advanced graphics class

Ray Tracing Formulate parametric equations of ray through each pixel objects in scene Calculate ray-object intersection. Topic of graduate/advanced graphics class

Painter’s Algorithm A depth sorting method Surfaces are sorted in the order of decreasing depth Surfaces are drawn in the sorted order, and overwrite the pixels in the frame buffer Subtle difference from depth buffer approach: entire face drawn Two problems: It can be nontrivial to sort the surfaces There can be no solution for the sorting order

References Hill, section 8.5, chapter 13