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

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

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: Introduction to Computer Graphics Lecture #10: View Frustum Culling

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

Culling. Computer Graphics CSE 167 Lecture 12

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

CS4620/5620: Lecture 14 Pipeline

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

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

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Hidden surface removal. Computer Graphics

Rasterization. MIT EECS Frédo Durand and Barb Cutler. MIT EECS 6.837, Cutler and Durand 1

CSE 167: Introduction to Computer Graphics Lecture #5: Visibility, OpenGL

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

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Final projects. Rasterization. The Graphics Pipeline. Illumination (Shading) (Lighting) Viewing Transformation. Rest of semester. This week, with TAs

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

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

Computer Graphics. Bing-Yu Chen National Taiwan University

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

Fondamenti di Grafica 3D The Rasterization Pipeline.

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Drawing Fast The Graphics Pipeline

Drawing Fast The Graphics Pipeline

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

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

Lecture 4. Viewing, Projection and Viewport Transformations

CS 130 Exam I. Fall 2015

Triangle Rasterization

CSE 167: Lecture #8: Lighting. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

Pipeline Operations. CS 4620 Lecture 14

Visibility: Z Buffering

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

Drawing Fast The Graphics Pipeline

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

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

Sung-Eui Yoon ( 윤성의 )

Pipeline Operations. CS 4620 Lecture 10

The Rasterization Pipeline

CS 130 Final. Fall 2015

CS 130 Exam I. Fall 2015

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

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

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

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Visibility and Occlusion Culling

Last time? Rasterization. Scan Conversion (Rasterization) High-level concepts for Visibility / Display. Today

CSE 167: Lecture #17: Procedural Modeling. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

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

Real-Time Graphics Architecture

Hidden Surface Removal

Scanline Rendering 2 1/42

Lecture 2. Shaders, GLSL and GPGPU

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

Rasterization Overview

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

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

CS 381 Computer Graphics, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Tuesday, October 16, 2012.

Rasterization. COMP 575/770 Spring 2013

Realtime 3D Computer Graphics Virtual Reality

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

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

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

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

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

CSE 167: Introduction to Computer Graphics Lecture #18: More Effects. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

The Rendering Pipeline (1)

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

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

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. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

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

CSE 167: Introduction to Computer Graphics Lecture #4: Coordinate Systems

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

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

CS Computer Graphics: Hidden Surface Removal

Spring 2011 Prof. Hyesoon Kim

RASTERISED RENDERING

LOD and Occlusion Christian Miller CS Fall 2011

Software Engineering. ò Look up Design Patterns. ò Code Refactoring. ò Code Documentation? ò One of the lessons to learn for good design:

White Paper. Solid Wireframe. February 2007 WP _v01

Rendering approaches. 1.image-oriented. 2.object-oriented. foreach pixel... 3D rendering pipeline. foreach object...

PowerVR Hardware. Architecture Overview for Developers

Real-Time Graphics Architecture

Could you make the XNA functions yourself?

CS 112 The Rendering Pipeline. Slide 1

Computer Graphics Shadow Algorithms

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

Last class. A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization

Transcription:

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

Announcements Homework project #2 due this Friday, October 12 To be presented starting 1:30pm in lab 260 Also present late submissions for project #1 2

Lecture Overview Culling Rasterization Visibility Barycentric Coordinates 3

Culling Goal: Discard geometry that does not need to be drawn to speed up rendering Types of culling: View frustum culling Occlusion culling Small object culling Backface culling Degenerate culling 4

View Frustum Culling Triangles outside of view frustum are off-screen Done on canonical view volume Images: SGI OpenGL Optimizer Programmer's Guide 5

Videos Rendering Optimisations - Frustum Culling http://www.youtube.com/watch?v=kvvhp9wmao8&feature=r elated View Frustum Culling Demo http://www.youtube.com/watch?v=bjrytbgpwic 6

Bounding Box How to cull objects consisting of may polygons? Cull bounding box Rectangular box, parallel to object space coordinate planes Box is smallest box containing the entire object 7 Image: SGI OpenGL Optimizer Programmer's Guide

Occlusion Culling Geometry hidden behind occluder cannot be seen Many complex algorithms exist to identify occluded geometry Images: SGI OpenGL Optimizer Programmer's Guide 8

Video Umbra 3 Occlusion Culling explained http://www.youtube.com/watch?v=5h4qgdbwqhc 9

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 10

Backface Culling Consider triangles as one-sided, i.e., only visible from the front Closed objects If the back of the triangle is facing the camera, it is not visible Gain efficiency by not drawing it (culling) Roughly 50% of triangles in a scene are back facing 11

Backface Culling Convention: Triangle is front facing if vertices are ordered counterclockwise p2 p1 p0 p0 Front-facing 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) p1 Back-facing p2 12

Backface Culling Compute triangle normal after projection (homogeneous division) Third component of n negative: front-facing, otherwise back-facing Remember: projection matrix is such that homogeneous division flips sign of third component 13

Degenerate Culling Degenerate triangle has no area Vertices lie in a straight line Vertices at the exact same place Normal n=0 Source: Computer Methods in Applied Mechanics and Engineering, Volume 194, Issues 48 49 14

Rendering Pipeline Primitives Modeling and Viewing Transformation Shading Projection Scan conversion, visibility Culling, Clipping Discard geometry that will not be visible 15 Image

Lecture Overview Culling Rasterization Visibility Barycentric Coordinates 16

Rendering Pipeline Primitives 17 Modeling and Viewing Transformation Shading Projection Rasteriztion, Visibility Image Scan conversion and rasterization are synonyms One of the main operations performed by GPU Draw triangles, lines, points (squares) Focus on triangles in this lecture

Rasterization 18

Rasterization How many pixels can a modern graphics processor draw per second? 19

Rasterization How many pixels can a modern graphics processor draw per second? NVidia GeForce GTX 690 234 billion pixels per second Multiple of what the fastest CPU could do 20

Rasterization Many different algorithms Old style Rasterize edges first 21

Rasterization Many different algorithms Example: Rasterize edges first Fill the spans (scan lines) Disadvantage: Requires clipping 22 Source: http://www.arcsynthesis.org

Rasterization GPU rasteriazation today based on Homogeneous Rasterization http://www.ece.unm.edu/course/ece595/docs/olano.pdf Olano, Marc and Trey Greer, "Triangle Scan Conversion Using 2D Homogeneous Coordinates", Proceedings of the 1997 SIGGRAPH/EurographicsWorkshop on Graphics Hardware (Los Angeles, CA, August 2-4, 1997), ACM SIGGRAPH, New York, 1995. 23

Rasterization Given vertices in pixel coordinates World space Camera space Clip space Image space Pixel coordinates 24

Rasterization Simple algorithm compute bbox clip bbox to screen limits for all pixels [x,y] in bbox compute barycentric coordinates alpha, beta, gamma if 0<alpha,beta,gamma<1 //pixel in triangle image[x,y]=trianglecolor Bounding box clipping trivial 25

Rasterization So far, we compute barycentric coordinates of many useless pixels How can this be improved? 26

Rasterization Hierarchy If block of pixels is outside triangle, no need to test individual pixels Can have several levels, usually two-level Find right granularity and size of blocks for optimal performance 27

2D Triangle-Rectangle Intersection If one of the following tests returns true, the triangle intersects the rectangle: Test if any of the triangle s vertices are inside the rectangle (e.g., by comparing the x/y coordinates to the min/max x/y coordinates of the rectangle) Test if one of the quad s vertices is inside the triangle (e.g., using barycentric coordinates) Intersect all edges of the triangle with all edges of the rectangle 28

Rasterization Where is the center of a pixel? Depends on conventions With our viewport transformation: 800 x 600 pixels viewport coordinates are in [0 800]x[0 600] Center of lower left pixel is 0.5, 0.5 Center of upper right pixel is 799.5, 599.5 4.0, 3.0. 0.0, 0.0 2.5, 0.5 29

Rasterization Shared Edges Each pixel needs to be rasterized exactly once Resulting image is independent of drawing order Rule: If pixel center exactly touches an edge or vertex Fill pixel only if triangle extends to the right or down 30

Lecture Overview Culling Rasterization Visibility Barycentric Coordinates 31

Visibility At each pixel, we need to determine which triangle is visible 32

Painter s Algorithm Paint from back to front Every new pixel always paints over previous pixel in frame buffer Need to sort geometry according to depth May need to split triangles if they intersect Outdated algorithm, created when memory was expensive 33

Z-Buffering Store z-value for each pixel Depth test During rasterization, compare stored value to new value Update pixel only if new value is smaller setpixel(int x, int y, color c, float z) if(z<zbuffer(x,y)) then zbuffer(x,y) = z color(x,y) = c z-buffer is dedicated memory reserved for GPU (graphics memory) Depth test is performed by GPU 34

Z-Buffering Problem: translucent geometry Storage of multiple depth and color values per pixel (not practical in real-time graphics) Or back to front rendering of translucent geometry, after rendering opaque geometry 35

Lecture Overview Culling Rasterization Visibility Barycentric Coordinates 36

Color Interpolation What if a triangle s vertex colors are different? Need to interpolate across triangle How to calculate interpolation weights? Source: efg s computer lab 37

Implicit 2D Lines Given two 2D points a, b Define function such that if p lies on the line defined by a, b 38

Implicit 2D Lines Point p lies on the line, if p-a is perpendicular to the normal of the line Use dot product to determine on which side of the line p lies. If f(p)>0, p is on same side as normal, if f(p)<0 p is on opposite side. If dot product is 0, p lies on the line. 39

Barycentric Coordinates Coordinates for 2D plane defined by triangle vertices a, b, c Any point p in the plane defined by a, b, c is p = a + β (b - a) + γ (c - a) = (1 β γ ) a + β b + γ c We define α = 1 β γ => p = α a + β b + γ c α, β, γ are called barycentric coordinates Works in 2D and in 3D If we imagine masses equal to α, β, γ attached to the vertices of the triangle, the center of mass (the barycenter) is then p. This is the origin of the term barycentric (introduced 1827 by Möbius) 40

Barycentric Coordinates p is inside the triangle if 0 < α, β, γ < 1 41

Barycentric Coordinates Problem: Given point p, find its barycentric coordinates Use equation for implicit lines Division by zero if triangle is degenerate 42

Barycentric Interpolation Interpolate values across triangles, e.g., colors Linear interpolation on triangles 43

Barycentric Coordinates Demo Applet: http://www.ccs.neu.edu/home/suhail/barytriangles/applet.htm 44