VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

Similar documents
Motivation. Culling Don t draw what you can t see! What can t we see? Low-level Culling

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Clipping & Culling. Lecture 11 Spring Trivial Rejection Outcode Clipping Plane-at-a-time Clipping Backface Culling

CSE328 Fundamentals of Computer Graphics: Concepts, Theory, Algorithms, and Applications

Today. CS-184: Computer Graphics. Lecture #10: Clipping and Hidden Surfaces. Clipping. Hidden Surface Removal

CS4620/5620: Lecture 14 Pipeline

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Computer Graphics. - Clipping - Philipp Slusallek & Stefan Lemme

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

CS452/552; EE465/505. Clipping & Scan Conversion

CS 498 VR. Lecture 18-4/4/18. go.illinois.edu/vrlect18

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

CS Computer Graphics: Hidden Surface Removal

Visible Surface Detection. (Chapt. 15 in FVD, Chapt. 13 in Hearn & Baker)

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Hidden surface removal. Computer Graphics

Pipeline Operations. CS 4620 Lecture 10

Visibility and Occlusion Culling

Rasterization Overview

More Visible Surface Detection. CS116B Chris Pollett Mar. 16, 2005.

Computer Graphics. Bing-Yu Chen National Taiwan University

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Two-Dimensional Viewing. Chapter 6

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Visibility. Welcome!

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination (Total: 100 marks)

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

Culling. Computer Graphics CSE 167 Lecture 12

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

Examples. Clipping. The Rendering Pipeline. View Frustum. Normalization. How it is done. Types of operations. Removing what is not seen on the screen

Hidden Surface Removal

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

Computer Graphics II

Pipeline Operations. CS 4620 Lecture 14

Visible-Surface Detection Methods. Chapter? Intro. to Computer Graphics Spring 2008, Y. G. Shin

Sung-Eui Yoon ( 윤성의 )

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

3D Rendering Pipeline (for direct illumination)

Clipping. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

SAZ4C COMPUTER GRAPHICS. Unit : 1-5. SAZ4C Computer Graphics

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

Class of Algorithms. Visible Surface Determination. Back Face Culling Test. Back Face Culling: Object Space v. Back Face Culling: Object Space.

CSE 167: Introduction to Computer Graphics Lecture #5: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

Graphics and Interaction Rendering pipeline & object modelling

CSE 167: Introduction to Computer Graphics Lecture #11: Visibility Culling

CHAPTER 1 Graphics Systems and Models 3

Two basic types: image-precision and object-precision. Image-precision For each pixel, determine which object is visable Requires np operations

Topics. From vertices to fragments

CS488. Visible-Surface Determination. Luc RENAMBOT

Introduction to Visualization and Computer Graphics

Visibility: Z Buffering

The Traditional Graphics Pipeline

RASTERISED RENDERING

CS559: Computer Graphics. Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

From Vertices To Fragments-1

LOD and Occlusion Christian Miller CS Fall 2011

Image Precision Silhouette Edges

Topic #1: Rasterization (Scan Conversion)

Clipping and Scan Conversion

The Traditional Graphics Pipeline

Part IV. 2D Clipping

CEng 477 Introduction to Computer Graphics Fall 2007

Realtime 3D Computer Graphics Virtual Reality

Aptitude Test Question

Projection and viewing. Computer Graphics CSE 167 Lecture 4

8. Hidden Surface Elimination

Rendering If we have a precise computer representation of the 3D world, how realistic are the 2D images we can generate? What are the best way to mode

Many rendering scenarios, such as battle scenes or urban environments, require rendering of large numbers of autonomous characters.

Performance OpenGL Programming (for whatever reason)

The Traditional Graphics Pipeline

CSCI 4620/8626. Computer Graphics Clipping Algorithms (Chapter 8-5 )

Lecture 4. Viewing, Projection and Viewport Transformations

The Rendering Pipeline (1)

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Drawing the Visible Objects

Wed, October 12, 2011

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Identifying those parts of a scene that are visible from a chosen viewing position, and only process (scan convert) those parts

9. Visible-Surface Detection Methods

Computer Graphics Shadow Algorithms

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

What is Clipping? Why do we Clip? Lecture 9 Comp 236 Spring Clipping is an important optimization

Computer Graphics. Rendering. by Brian Wyvill University of Calgary. cpsc/enel P 1

PowerVR Hardware. Architecture Overview for Developers

CS 112 The Rendering Pipeline. Slide 1

1.2.3 The Graphics Hardware Pipeline

QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

Painter s HSR Algorithm

Lecture 7 of 41. Viewing 4 of 4: Culling and Clipping Lab 1b: Flash Intro

Transcription:

VISIBILITY & CULLING Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

Visibility

Visibility Given a set of 3D objects, which surfaces are visible from a specific point of view? 3

What can t we see? Anything outside the view volume Anything occluded by another object Anything smaller than a pixel Anything in complete shadow 4

OPAQUE 5

Visibility What polygons are visible with respect to view frustum? Outside Frustum: View Frustum Culling, Clipping Inside Frustum: Hidden Surface Removal Backface culling Occlusion These are needed to avoid later expensive computations 6

Backface Culling 7

Backface Culling Do not draw polygons facing away from the viewer Front facing polygons will occlude these If the object is opaque And a closed polygon mesh 8

Where in the pipeline this test fits best? Find Backface Polygons Front facing polygons point towards the viewer Backface polygons point away from viewer If v is the vector to viewer then: n v 0 means that the primitive is backface 9

Find Backface Polygons In normalized device coordinates the test becomes very efficient since v = (0, 0, 1) So any normal with n z < 0 is a backface. Do not forget, this requires correct surface normal, and not the normal often used for special lighting effects. 10

OpenGL Backface Culling Does not use the above algorithm Works on the signed area of the projected primitive in screen space. This means that if vertices are organized in clockwise fashion then they are backfacing. 2 1 0 0 Front facing 1 Back facing 2 11

OpenGL Backface Culling Enable/Disable back-face removal with glenable(gl_cull_face)/gldisable(gl_cull_face) Select which polygons to remove with one of the following functions: glcullface(gl_back) glcullface(gl_front) glcullface(gl_front_and_back) The convention is to specify the faces so that the outward face is the front face. What if the camera happens to be inside the model. How would you set up the back-face removal? 12

Clipping 13

Clipping What about polygons piercing one or more frustum planes? Clipping is designed for them. Pixel-wise clipping is not a good idea, specially for large triangles Clipping happens just before rasterization Almost always we rely on the graphics system for that. 14

Polygon Clipping Given a polygon, find area of it within viewport. Usualy the viewport is axis-aligned rectangle. Number of vertices may be increased. Can result one or more polygons. 15

Sutherland-Hodgeman Clipping This is a divide-and-conquer algorithm Repeated clipping against half-space Walk around boundary of polygon Four cases for edge transition 16

Sutherland-Hodgeman Clipping This is a divide-and-conquer algorithm Repeated clipping against half-space Walk around boundary of polygon Four cases for edge transition in in: output next vertex in out: output intersection out out: output nothing out in: output intersection + next vertex 17

Clipping The method can be used for any convex clipping region Implementation issues: Care is needed to get it right We might need to create several separate polygons We might get very small areas along the edges Other algorithms: Cyrus-Beck Liang-Barsky & Weiler 18

Painter s Algorithm 19

Painter s Algorithm Assumption: Later projected polygons overwrite earlier ones. Idea: A painter creates a drawing by drawing background elements first. We can do the same and draw further objects first Need to sort polygons by depth. from Shirley 20

Visibility How to correctly preserve the 3D order of the objects in the rendering? 21

Painter s Algorithm Sort polygons by Z min and project those with higher Z min first z min z min z min z min 22

Painter s Algorithm Fails in cases of overlaps Might need to split polygons in order to work z min z min 23

Z-Buffer Algorithm 24

Visibility How to correctly preserve the 3D order of the objects in the rendering? 25

Z-Buffer Algorithm Draw every polygon the we can t reject (i.e. outside the view) If we find a pixel of a polygon that is closer to viewer than what we had drawn before, then overwrite it. It is an image-based (pixel-wise) hidden surface removal Upon rasterizing we need to store the z-value for each pixel as well and not only the color. Requires another buffer (memory) This buffer must have same pixel resolution as image buffer 26

DAM Entertainment Z-Buffer Color buffer Depth buffer 27

Z-Buffer Advantages Simple to implement in hardware It is natural part of primitive rasterization Requires no pre-processing, we can send the primitives to the pipeline in any order 28

Z-Buffer Disadvantages Memory requirements Imagine 32bits per depth value and HD resolution How much memory just for Z-Buffer? Accuracy problems Only considers visibility at discrete pixels => aliasing Depth buffer precision issue => Z-Fighting Potential inefficiency High depth-complexity scenes Might get many overdraws 29

Z-Buffer in OpenGL Tell GLUT that we need one glutinitdisplaymode(glut_double GLUT_RGB GLUT_DEPTH) Enable depth testing glenable(gl_depth_test) We need to reset it at every frame before drawing anything glclear(gl_depth_buffer_bit) Might need to change the comparison method gldepthfunc(gl_less) 30