Culling. Computer Graphics CSE 167 Lecture 12

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

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

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

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

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

CSE 167: Introduction to Computer Graphics Lecture 11: Scene Graph 2. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

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

Sung-Eui Yoon ( 윤성의 )

Speeding up your game

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

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

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

Spatial Data Structures and Speed-Up Techniques. Ulf Assarsson Department of Computer Science and Engineering Chalmers University of Technology

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

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

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

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

Spatial Data Structures

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

Projection and viewing. Computer Graphics CSE 167 Lecture 4

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

CS4620/5620: Lecture 14 Pipeline

Computer Graphics Shadow Algorithms

Computer Graphics. Bing-Yu Chen National Taiwan University

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

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

Wed, October 12, 2011

Hidden surface removal. Computer Graphics

Spatial Data Structures

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

Spatial Data Structures

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

LOD and Occlusion Christian Miller CS Fall 2011

Spatial Data Structures

CS488. Visible-Surface Determination. Luc RENAMBOT

Universiteit Leiden Computer Science

Pipeline Operations. CS 4620 Lecture 14

CS 563 Advanced Topics in Computer Graphics Culling and Acceleration Techniques Part 1 by Mark Vessella

Procedural modeling and shadow mapping. Computer Graphics CSE 167 Lecture 15

Table of Contents. Questions or problems?

Hardware-driven visibility culling

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

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Robust Stencil Shadow Volumes. CEDEC 2001 Tokyo, Japan

CS 563 Advanced Topics in Computer Graphics QSplat. by Matt Maziarz

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

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

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

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

Problem Max. Points Total 80

Visibility and Occlusion Culling

Drawing Fast The Graphics Pipeline

From Vertices To Fragments-1

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

Shadows in the graphics pipeline

Visibility: Z Buffering

The Graphics Pipeline. Interactive Computer Graphics. The Graphics Pipeline. The Graphics Pipeline. The Graphics Pipeline: Clipping

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

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

Hidden Surface Removal

Rasterization Overview

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

Realtime 3D Computer Graphics Virtual Reality

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

CS 130 Exam I. Fall 2015

CSE328 Fundamentals of Computer Graphics

COMP 175: Computer Graphics April 11, 2018

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CS 4204 Computer Graphics

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

Point based Rendering

CMSC427 Transformations II: Viewing. Credit: some slides from Dr. Zwicker

Drawing in 3D (viewing, projection, and the rest of the pipeline)

CS451Real-time Rendering Pipeline

Frédo Durand, George Drettakis, Joëlle Thollot and Claude Puech

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

Particle systems, collision detection, and ray tracing. Computer Graphics CSE 167 Lecture 17

Comparison of hierarchies for occlusion culling based on occlusion queries

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Spatial Data Structures

Overview. A real-time shadow approach for an Augmented Reality application using shadow volumes. Augmented Reality.

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves

Lecture 4. Viewing, Projection and Viewport Transformations

Hidden Surfaces II. Week 9, Mon Mar 15

Triangle Rasterization

CSE452 Computer Graphics

Illumination and Geometry Techniques. Karljohan Lundin Palmerius

lecture 18 - ray tracing - environment mapping - refraction

3D Viewing. CS 4620 Lecture 8

Projection Matrix Tricks. Eric Lengyel

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

Computer Graphics. - Clipping - Philipp Slusallek & Stefan Lemme

9. Visible-Surface Detection Methods

Computer Graphics 7: Viewing in 3-D

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

Chapter 5. Projections and Rendering

3D Viewing. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 9

Transcription:

Culling Computer Graphics CSE 167 Lecture 12

CSE 167: Computer graphics Culling Definition: selecting from a large quantity In computer graphics: selecting primitives (or batches of primitives) that are visible If culling is performed early in the graphics pipeline, then rejected invisible objects are not fetched, transformed, rasterized, or shaded CSE 167, Winter 2018 2

Types of culling View frustum culling Backface culling Contribution (or small object) culling Degenerate culling Occlusion culling Based on slides courtesy of Jurgen Schulze CSE 167, Winter 2018 3

View frustum culling Triangles outside of view frustum are offscreen Performed on canonical view volume Images: SGI OpenGL Optimizer Programmer's Guide CSE 167, Winter 2018 4

View frustum culling Rendering Optimizations Frustum Culling https://www.youtube.com/watch?v=kvvhp9wma O8 View Frustum Culling Demo https://www.youtube.com/watch?v=bjrytbgpwic CSE 167, Winter 2018 5

Bounding volumes How to cull objects consisting of may polygons? Intersect bounding volume with view frustum instead of each primitive Simple shape that completely encloses an object CSE 167, Winter 2018 6

Bounding volumes Commonly, a sphere or cuboid Easier to calculate culling for spheres Easier to calculate tight fits for cuboids (boxes) Cull bounding box Box is smallest box containing the entire object Simple approach: rectangular box, parallel to object space coordinate planes May not be tightest fit CSE 167, Winter 2018 7

View frustum culling Frustum is defined by 6 planes Each plane divides space into outside, inside Check each object against each plane Outside, inside, intersecting If outside all planes Outside the frustum If inside all planes Inside the frustum Else, partially inside frustum Intersecting the frustum View frustum CSE 167, Winter 2018 8

Distance to plane A plane is described by a point p on the plane and a unit normal n Find the (perpendicular) distance from point x to the plane r n x p CSE 167, Winter 2018 9

Distance to plane The distance is the length of the projection of (x p) onto n uuuuuuu r r n dist x p r n uuuuu r x p x p CSE 167, Winter 2018 10

Distance to plane The distance has a sign (oriented plane) Positive on the side of the plane the normal points to Negative on the opposite side Zero exactly on the plane Divides 3D space into two infinite half spaces x dist(x) x p uuuuuuu r r r n n Positive p CSE 167, Winter 2018 11 Negative

Distance to plane Simplification Where d is distance from the origin to the plane d is independent of x We can represent a plane with just d and n CSE 167, Winter 2018 12

Frustum with oriented planes Normal of each plane points outside of frustum Outside is positive distance Inside is negative distance CSE 167, Winter 2018 13

Sphere plane test For sphere with radius r and origin x, test the distance to the origin, and see if it is beyond the radius Three cases: dist(x) > r Completely above dist(x) < r Completely below r < dist(x) < r Intersects r n Positive Negative CSE 167, Winter 2018 14

View frustum culling using spheres Pre compute the normal n and value d for each of the six planes. Given a sphere with center x and radius r For each of the six clipping planes If dist(x) > r, then sphere is outside (terminate loop) Else if dist(x) < r, then add 1 to count (Alternatively, set a flag if dist(x) r) If we did not terminate the loop early, check the count If the count is 6 (or flag was not set), then the sphere is completely inside Otherwise, the sphere intersects the frustum CSE 167, Winter 2018 15

View frustum culling using spheres Math for Game Developers Frustum Culling https://www.youtube.com/watch?v=4p E_31XOPM CSE 167, Winter 2018 16

View frustum culling groups of objects Able to cull a whole group quickly But, if the group is partly in and partly out, able to cull individual objects CSE 167, Winter 2018 17

View frustum culling using hierarchical bounding volumes Given hierarchy of objects Bounding volume of each node encloses the bounding volumes of all its children Start by testing the outermost bounding volume If it is entirely outside, do not draw the group at all If it is entirely inside, draw the whole group CSE 167, Winter 2018 18

View frustum culling using hierarchical bounding volumes If the bounding volume is partly inside and partly outside Test each child s bounding volume individually If the child is in, then draw it; if it is out, then cull it; if it is partly in and partly out, then recurse If recursion reaches a leaf node, then draw it normally CSE 167, Winter 2018 19

Backface culling Consider triangles as one sided (oriented triangle) and only visible from the front Closed objects If the back of the triangle is facing away from the camera, it is not visible Gain efficiency by not drawing it (culling) Roughly 50% of triangles in a scene are back facing CSE 167, Winter 2018 20

Backface culling Convention: triangle is front facing if vertices are ordered counterclockwise p2 p1 p0 p0 Front-facing p1 Back-facing p2 CSE 167, Winter 2018 21

Backface culling Compute triangle normal after projection (homogeneous division) If the third component of n negative, then front facing; otherwise, back facing Remember: projection matrix is such that homogeneous division flips sign of third component CSE 167, Winter 2018 22

Backface culling Without backface culling With backface culling CSE 167, Winter 2018 23

Backface culling OpenGL allows one or two sided triangles One sided triangles glenable(gl_cull_face); glcullface(gl_back) Two sided triangles (no backface culling) gldisable(gl_cull_face) gldisable(gl_cull_face); glenable(gl_cull_face); CSE 167, Winter 2018 24

Contribution (or small object) culling Object projects to less than a specified size Cull objects whose screen space bounding box is less than a threshold number of pixels, as these objects do not contribute significantly to the final image CSE 167, Winter 2018 25

Degenerate culling Projected triangle is degenerate Normal n = 0 (plane at infinity, not really degenerate) All vertices in a straight line All vertices in the same place Source: Computer Methods in Applied Mechanics and Engineering, Volume 194, Issues 48 49 CSE 167, Winter 2018 26

Occlusion culling Geometry hidden behind occluder cannot be seen Many complex algorithms exist to identify occluded geometry Images: SGI OpenGL Optimizer Programmer's Guide CSE 167, Winter 2018 27

Occlusion culling Umbra 3 Occlusion Culling explained https://www.youtube.com/watch?v=5h4qgdbwq hc CSE 167, Winter 2018 28