graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Similar documents
graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Pipeline Operations. CS 4620 Lecture 10

Pipeline Operations. CS 4620 Lecture 14

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

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

CS4620/5620: Lecture 14 Pipeline

The Traditional Graphics Pipeline

Rasterization. COMP 575/770 Spring 2013

Rasterization. CS4620/5620: Lecture 12. Announcements. Turn in HW 1. PPA 1 out. Friday lecture. History of graphics PPA 1 in 4621.

Rasterization. CS4620 Lecture 13

CS427 Multicore Architecture and Parallel Computing

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

Einführung in Visual Computing

Pipeline and Rasterization. COMP770 Fall 2011

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16

Introduction to Visualization and Computer Graphics

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

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

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

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

3D Rasterization II COS 426

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

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

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Computer Graphics. Bing-Yu Chen National Taiwan University

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

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

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

CS 130 Exam I. Fall 2015

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

Triangle Rasterization

Painter s HSR Algorithm

CHAPTER 1 Graphics Systems and Models 3

CS 130 Exam I. Fall 2015

Topics. From vertices to fragments

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

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

CEng 477 Introduction to Computer Graphics Fall 2007

Rasterization Overview

Hidden surface removal. Computer Graphics

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

CS 130 Final. Fall 2015

Visibility: Z Buffering

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

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

Scanline Rendering 2 1/42

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Line Drawing. Foundations of Computer Graphics Torsten Möller

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

Drawing Fast The Graphics Pipeline

Topic #1: Rasterization (Scan Conversion)

Rasterization and Graphics Hardware. Not just about fancy 3D! Rendering/Rasterization. The simplest case: Points. When do we care?

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

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

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

Rasterizing triangles

Graphics and Interaction Rendering pipeline & object modelling

Graphics Hardware and Display Devices

Realtime 3D Computer Graphics Virtual Reality

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

Computer Graphics Shadow Algorithms

Institutionen för systemteknik

Pipeline implementation II

CS Rasterization. Junqiao Zhao 赵君峤

Shadows in the graphics pipeline

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

Reading. 18. Projections and Z-buffers. Required: Watt, Section , 6.3, 6.6 (esp. intro and subsections 1, 4, and 8 10), Further reading:

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

Drawing Fast The Graphics Pipeline

Chapter 8: Implementation- Clipping and Rasterization

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

Rasterization. Computer Graphics Fabio Pellacini and Steve Marschner

Computer Graphics. Shadows

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

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

Fondamenti di Grafica 3D The Rasterization Pipeline.

The Rasterization Pipeline

Soft shadows. Steve Marschner Cornell University CS 569 Spring 2008, 21 February

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality.

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

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

The Rasterization Pipeline

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

COMP3421. Particle Systems, Rasterisation

CS130 : Computer Graphics Lecture 2: Graphics Pipeline. Tamar Shinar Computer Science & Engineering UC Riverside

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

Robust Stencil Shadow Volumes. CEDEC 2001 Tokyo, Japan

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

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Hidden Surfaces II. Week 9, Mon Mar 15

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

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

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

Clipping and Scan Conversion

Acknowledgement: Images and many slides from presentations by Mark J. Kilgard and other Nvidia folks, from slides on developer.nvidia.

Computer Graphics. - Rasterization - Philipp Slusallek

OXFORD ENGINEERING COLLEGE (NAAC Accredited with B Grade) DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING LIST OF QUESTIONS

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Transcription:

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1 graphics pipeline sequence of operations to generate an image using object-order processing primitives processed one-at-a-time software pipeline: e.g. Renderman high-quality and efficiency for large scenes hardware pipeline: e.g. graphics accelerators lower-quality solution for interactive applications will cover algorithms of modern hardware pipeline but evolve drastically every few years we will only look at triangles computer graphics graphics pipeline 2009 fabio pellacini 2

graphics pipeline handles only simple primitives by design points, lines, triangles, quads (as two triangles) efficient algorithm complex primitives by tessellation complex curves: tessellate into line strips curves surfaces: tessellate into triangle meshes pipeline name derives from architecture design sequences of stages with defined input/output easy-to-optimize, modular design computer graphics graphics pipeline 2009 fabio pellacini 3 graphics pipeline object-local algorithm processes only one-surface-at-a-time various effects have to be approximated shadows: shadow volume and shadow maps reflections: environment mapping hard to implement advanced effects cannot be implemented soft shadows blurry reflections and diffuse-indirect illumination computer graphics graphics pipeline 2009 fabio pellacini 4

graphics pipeline stages vertex data transformations vertex processing transformed vertex data convert to pixels compute final colors blending hidden-surface clipping and rasterization fragments w/interpolated data fragment processing fragments color and depth framebuffer processing framebuffer computer graphics graphics pipeline 2009 fabio pellacini 5 graphics pipeline stages vertex processing input: vertex data (position, normal, color, etc.) output: transformed vertices in homogeneous canonical view-volume, colors, etc. applies transformation from object-space to clip-space passes along material and shading data clipping and rasterization turns sets of vertices into primitives and fills them in output: set of fragments with interpolated data computer graphics graphics pipeline 2009 fabio pellacini 6

graphics pipeline stages fragment processing output: final color and depth traditionally mostly for texture lookups lighting was computed for each vertex today, computes lighting per-pixel framebuffer processing output: final picture hidden surface elimination compositing via alpha-blending computer graphics graphics pipeline 2009 fabio pellacini 7 vertex processing vertex data vertex processing transformed vertex data clipping and rasterization fragments w/interpolated data fragment processing fragments color and depth framebuffer processing framebuffer computer graphics graphics pipeline 2009 fabio pellacini 8

vertex processing transform vertices from model to clip space [Marschner 2004] computer graphics graphics pipeline 2009 fabio pellacini 9 vertex processing other geometry tasks deformation: skinning, mesh blending low-quality lighting pass other properties to next stages of pipeline the only place to algorithmically alter shape programmable hardware unit algorithm can be changed at run-time by application only recent change computer graphics graphics pipeline 2009 fabio pellacini 10

clipping and rasterization vertex data vertex processing transformed vertex data clipping and rasterization fragments w/interpolated data fragment processing fragments color and depth framebuffer processing framebuffer computer graphics graphics pipeline 2009 fabio pellacini 11 clipping remove (partial) objects not in the view frustum efficiency: cull later stages of the pipeline correctness: perspective transform can cause trouble often referred as culling when full objects removed computer graphics graphics pipeline 2009 fabio pellacini 12

clipping to ensure correctness in front of eye behind eye computer graphics graphics pipeline 2009 fabio pellacini 13 point clipping point-plane clipping test if the point is on the right side of the plane by taking dot-product with the plane normal can be performed in homogeneous coordinates point-frustum clipping point-plane clipping for each frustum plane computer graphics graphics pipeline 2009 fabio pellacini 14

line clipping segment-plane clipping test point-plane clipping for endpoints if endpoints are clipped, clip whole segment if endpoints are not clipped, accept whole segment if one endpoint is clipped, clip segment compute segment-plane intersection create shorter segment computer graphics graphics pipeline 2009 fabio pellacini 15 line clipping segment-frustum clipping clip against each plane incrementally guarantee to create the correct segment more efficient algorithms available previous incremental approach might try too hard provide early rejection for common cases so, only clip when necessary computer graphics graphics pipeline 2009 fabio pellacini 16

polygon clipping convex polygons similar to line clipping clip each point in sequence remove outside points create new points on boundary clipped triangles are not necessarily triangles computer graphics graphics pipeline 2009 fabio pellacini 17 culling further optimize by rejecting useless triangles backface culling if triangle face is oriented away from camera, cull it only ok for closed surfaces early z-culling if triangle is behind existing scene, cull it uses z-buffer introduced later on computer graphics graphics pipeline 2009 fabio pellacini 18

viewport transformation transform the canonical view volume to the pixel coordinates of the screen also rescale z in the [0..1] range we will see later why perspective divide is often performed here [Marschner 2004] computer graphics graphics pipeline 2009 fabio pellacini 19 rasterization approximate primitives into pixels pixel centered at integer coordinates determine which pixels to turn on no antialiasing (jaggies): pixel in the primitive consider antialiasing for some primitives input: vertex position in homogenous coordinates interpolate values across primitive colors, normals, position at vertices input: any vertex property computer graphics graphics pipeline 2009 fabio pellacini 20

line rasterization approximate line with a collection of pixels desirable properties uniform thickness and brightness continuous appearance (no holes) efficiency simplicity (for hardware implementation) line equation: y = mx + b in this lecture, for simplicity, assume m in [0,1) computer graphics graphics pipeline 2009 fabio pellacini 21 point-sampled line rasterization represent line as rectangle approximated by all pixel within the line for each pixel center, test if inside the rectangle inefficient many inside tests inaccurate thickness not constant computer graphics graphics pipeline 2009 fabio pellacini 22

midpoint line rasterization for each column only turn on closest pixel simple algorithm given line equation eval. eq. for each column between endpoints for x = ceil(x0) to floor(x1) { y = m*x + b write(x, round(y)) } computer graphics graphics pipeline 2009 fabio pellacini 23 optimizing midpoint line rasterization evaluating y is slow use incremental difference, DDA m = Δy / Δx y( x + 1) = y( x) + m x = ceil(x0) y = m*x + b while x < floor(x1) write(x, round(y), 1) y += m x += 1 computer graphics graphics pipeline 2009 fabio pellacini 24

bresenham s line rasterization at each pixel (x p,y p ), only two options: E(x p +1,y p ) or NE(x p +1,y p +1) d = ( x p + 1) m + b y p if d > 0.5 then NE else E can evaluate d using incremental differences NE: d += m - 1 E: d += m can use integers only computer graphics graphics pipeline 2009 fabio pellacini 25 bresenham s line rasterization x = ceil(x0) y = round(m*x + b) d = m*(x+1)+b-y while x < floor(x1) write(x, y, 1) x += 1 d += m if d > 0.5 y += 1 d -= 1 computer graphics graphics pipeline 2009 fabio pellacini 26

midpoint vs. point-sampled line point-sampled varying thickness midpoint same thickness computer graphics graphics pipeline 2009 fabio pellacini 27 antialiased line rasterization for each pixel, color is the ratio of the area covered by the line need to touch multiple pixels per column can be done efficiently by precomputation and lookup tables area only depends on line to pixel distance computer graphics graphics pipeline 2009 fabio pellacini 28

interpolating parameters along a line often associate params q i at line vertices colors, alphas linearly interpolate q i qi ( s) qi0 (1 s) + q s is fractional distance along the line = i1 can be done using incremental differences s computer graphics graphics pipeline 2009 fabio pellacini 29 triangle rasterization most common operation in graphics pipelines can be the only one: turn everything into triangles input: 2D triangle with vertex attributes 2d vertex coordinates: {(x 0,y 0 ), (x 1,y 1 ), (x 2,y 2 )} other attributes: {q i0,q i1,q i2 } output: list of fragments with interpol. attributes list of pixel coordinates that are to be drawn linearly interpolated vertex attributes computer graphics graphics pipeline 2009 fabio pellacini 30

triangle rasterization one triangle consistent triangles computer graphics graphics pipeline 2009 fabio pellacini 31 brute force triangle rasterization foreach pixel in image determine if inside triangle interpolate attributes use baricentric coordinates optimize by only checking triangle bounding box computer graphics graphics pipeline 2009 fabio pellacini 32

triangle baricentric coordinates p = α a + β b + γ c α + β + γ = 1 analytic interpretation coordinate system on the triangle p = a + β ( b a) + γ ( c a) geometric interpretation relative areas relative distances also useful for ray-triangle intersection computer graphics graphics pipeline 2009 fabio pellacini 33 brute force triangle rasterization for each pixel (x,y) in triangle bounding box compute (α,β,γ) if (α,β,γ) in [0,1] 3 q i = α q i0 + β q i1 + γ q i2 write(x,y,{q i }) can be made incremental as in line drawing more efficient options exists, but computer graphics graphics pipeline 2009 fabio pellacini 34

triangle rasterization on hardware old hardware: optimized for large triangles use smart algorithm clip triangle to screen window setup initial values interpolate hard to parallelize, high set up cost modern hardware: optimized for small triangles use incremental brute force algorithm only clip against near plane for correctness work with clipped bounding box easily parallelizable, little setup cost use tiles in image plane computer graphics graphics pipeline 2009 fabio pellacini 35 rasterization take home message complex but efficient set of algorithms lots of small little details that matters for correctness no clear winner architecture: parallel vs. serial input: e.g. size of triangles amortization: one-time vs. step-by-step cost complex algorithms have often hidden costs verify if they can be amortized loops are expensive: optimize as you can computer graphics graphics pipeline 2009 fabio pellacini 36

fragment processing vertex data vertex processing transformed vertex data clipping and rasterization fragments w/interpolated data fragment processing fragments color and depth framebuffer processing framebuffer computer graphics graphics pipeline 2009 fabio pellacini 37 fragment processing compute final fragment colors, alphas and depth depth is often untouched if no special effects final lighting computations lots of texture mapping: see later programmable hardware unit algorithm can be changed at run-time by application only recent change computer graphics graphics pipeline 2009 fabio pellacini 38

framebuffer processing vertex data vertex processing transformed vertex data clipping and rasterization fragments w/interpolated data fragment processing fragments color and depth framebuffer processing framebuffer computer graphics graphics pipeline 2009 fabio pellacini 39 framebuffer processing hidden surface elimination decides which surfaces are visible framebuffer blending composite transparent surfaces if necessary computer graphics graphics pipeline 2009 fabio pellacini 40

hidden surface removal painter alg. sort objects back to front draw in sorted order does not work in many cases computer graphics graphics pipeline 2009 fabio pellacini 41 hidden surface removal painter alg. sort objects back to front draw in sorted order does not work in many cases computer graphics graphics pipeline 2009 fabio pellacini 42

hidden surface removal z buffer brute force algorithm for each pixel, keep distance to closest object foreach object, rasterize updating pixels if distance is closer opaque objects: works in every case transparent objects: cannot properly composite computer graphics graphics pipeline 2009 fabio pellacini 43 hidden surface removal z buffer color buffer z-buffer [adapted from Shirley] computer graphics graphics pipeline 2009 fabio pellacini 44

hidden surface removal z buffer color buffer z-buffer [adapted from Shirley] computer graphics graphics pipeline 2009 fabio pellacini 45 which z distance use z value after homogenues xform linear interpolation works storage non-linear: more precision around near frame [Marschner 2004] computer graphics graphics pipeline 2009 fabio pellacini 46

which z distance use z value after homogenues xform linear interpolation works storage non-linear: more precision around near frame [Marschner 2004] computer graphics graphics pipeline 2009 fabio pellacini 47 hidden surface removal raycasting foreach ray, find intersection to closest surface works for opaque and transparent objects loops over pixels and then over surfaces inefficient would like to loop over surfaces only once computer graphics graphics pipeline 2009 fabio pellacini 48

hidden surface removal - scanline for each scanline, sort primitives incremental rasterization sorting can be done in many ways needs complex data structures works for opaque and transparent objects computer graphics graphics pipeline 2009 fabio pellacini 49 hidden surface removal - REYES foreach primitives, turn into small grids of quads hit-test quads by ray-casting keep list of sorted list hit-points per pixel like z-buffer but uses a list works for opaque and transparent objects hybrid between raycast and z-buffer very efficient for high complexity when using appropriate data-structures solves many other problems we will encounter later computer graphics graphics pipeline 2009 fabio pellacini 50

framebuffer processing hidden surface elimination using Z-buffer framebuffer blending using α-compositing but cannot sort fragments properly incorrect transparency blending need to presort transparent surfaces only like painter s algorithm, so not correct in many cases computer graphics graphics pipeline 2009 fabio pellacini 51 lighting computation where to evaluate lighting? flat: at vertices but do not interpolate colors Gourand: at vertices, with interpolated color Phong: at fragments, with interpolated normals computer graphics graphics pipeline 2009 fabio pellacini 52

lighting computation flat shading compute using normals of the triangle same as in raytracing flat and faceted look correct: no geometrical inconsistency computer graphics graphics pipeline 2009 fabio pellacini 53 lighting computation Gouraud shading compute light at vertex position with vertex normals interpolate colors linearly over the triangle computer graphics graphics pipeline 2009 fabio pellacini 54

lighting computation Phong shading interpolate normals per-pixels: shading normals compute lighting for each pixel lighting depends less on tessellation computer graphics graphics pipeline 2009 fabio pellacini 55 lighting computation Phong shading Gouraud Phong artifacts in highlights good highlights computer graphics graphics pipeline 2009 fabio pellacini 56

lighting computation per-pixel lighting is becoming ubiquitous much more robust move lighting from vertex to fragment processing new hardware architectures allows for this we introduce Gouraud for historical reasons raytracing can have this by using shading normals shading normals introduce inconsistencies lights can come from below the surface computer graphics graphics pipeline 2009 fabio pellacini 57 why graphics pipelines? simple algorithms can be mapped to hardware high performance using on-chip parallel execution highly parallel algorithms memory access tends to be coherent one-object at a time computer graphics graphics pipeline 2009 fabio pellacini 58

graphics pipeline architecture multiple arithmetic units NVidia Geforce 7800: 8 vertex units, 24 pixel units very small caches not needed since memory access are very coherent fast memory architecture needed for color/z-buffer traffic restricted memory access patterns no read-modify-write bound to change hopefully easy to make fast: this is what Intel would love! research into using for scientific computing computer graphics graphics pipeline 2009 fabio pellacini 59 graphics pipeline performance computer graphics graphics pipeline 2009 fabio pellacini 60

graphics pipeline performance computer graphics graphics pipeline 2009 fabio pellacini 61 graphics pipelines vs. raytracing raycasting graphics pipeline foreach pixel foreach object project pixels onto objects discretize first access objects many times scene must fit in memory very general solution O(log(n)) w/accel. struct. but constant very high foreach object foreach pixel project objects onto pixels discretize last access objects once image must fit in memory hard for complex effects O(n) or lower sometimes but constant very small computer graphics graphics pipeline 2009 fabio pellacini 62