Pipeline Operations. CS 4620 Lecture 14

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

Pipeline Operations. CS 4620 Lecture 10

CS4620/5620: Lecture 14 Pipeline

The Rasterization Pipeline

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Graphics Pipeline 2D Geometric Transformations

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Rasterization Overview

3D Rasterization II COS 426

CHAPTER 1 Graphics Systems and Models 3

CS 4620 Program 3: Pipeline

Deferred Rendering Due: Wednesday November 15 at 10pm

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Interpolation using scanline algorithm

Computer Graphics I Lecture 11


CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

CS 130 Exam I. Fall 2015

Introduction to Visualization and Computer Graphics

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

CS 130 Final. Fall 2015

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

CS 464 Review. Review of Computer Graphics for Final Exam

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

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Computer Graphics Lecture 11

Computergrafik. Matthias Zwicker. Herbst 2010

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

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

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

TSBK03 Screen-Space Ambient Occlusion

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

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

CS451Real-time Rendering Pipeline

Chapter 7 - Light, Materials, Appearance

The Traditional Graphics Pipeline

CS 130 Exam I. Fall 2015

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

Blue colour text questions Black colour text sample answers Red colour text further explanation or references for the sample answers

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

Models and Architectures. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

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

Graphics Hardware and Display Devices

RASTERISED RENDERING

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Rasterization. Computer Graphics Fabio Pellacini and Steve Marschner

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Interactive Computer Graphics A TOP-DOWN APPROACH WITH SHADER-BASED OPENGL

CEng 477 Introduction to Computer Graphics Fall 2007

Computer Graphics. Shadows

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

Adaptive Point Cloud Rendering

Computer Graphics. Illumination and Shading

Projections and Hardware Rendering. Brian Curless CSE 557 Fall 2014

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Lecture 2. Shaders, GLSL and GPGPU

Illumination & Shading: Part 1

Graphics and Interaction Rendering pipeline & object modelling

- Rasterization. Geometry. Scan Conversion. Rasterization

Phong Lighting & Materials. Some slides modified from: David Kabala Others from: Andries Van Damm, Brown Univ.

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

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading

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

Models and Architectures

Introduction to Computer Graphics with WebGL

Illumination and Shading

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

Chapter 2 A top-down approach - How to make shaded images?

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

Hidden surface removal. Computer Graphics

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

Introduction to Computer Graphics 7. Shading

9. Illumination and Shading

Course Title: Computer Graphics Course no: CSC209

Objectives. Introduce Phong model Introduce modified Phong model Consider computation of required vectors Discuss polygonal shading.

Computer Graphics 10 - Shadows

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

Level of Details in Computer Rendering

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

Hidden Surfaces II. Week 9, Mon Mar 15

COMP environment mapping Mar. 12, r = 2n(n v) v

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

QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

E.Order of Operations

3D Programming. 3D Programming Concepts. Outline. 3D Concepts. 3D Concepts -- Coordinate Systems. 3D Concepts Displaying 3D Models

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

Graphics for VEs. Ruth Aylett

Advanced Rendering Techniques

Rasterization. COMP 575/770 Spring 2013

Illumination and Shading

Virtual Reality for Human Computer Interaction

CS452/552; EE465/505. Intro to Lighting

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

Rendering. Illumination Model. Wireframe rendering simple, ambiguous Color filling flat without any 3D information

Topics and things to know about them:

Transcription:

Pipeline Operations CS 4620 Lecture 14 2014 Steve Marschner 1

Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives to pixels RASTERIZATION FRAGMENTS blending, compositing, shading FRAGMENT PROCESSING FRAMEBUFFER IMAGE user sees this DISPLAY 2014 Steve Marschner 2

Pipeline of transformations Standard sequence of transforms object space camera space screen space modeling transformation camera transformation projection transformation viewport transformation world space canonical view volume 2014 Steve Marschner 3

Hidden surface elimination We have discussed how to map primitives to image space projection and perspective are depth cues occlusion is another very important cue 2014 Steve Marschner 4

Back face culling For closed shapes you will never see the inside therefore only draw surfaces that face the camera implement by checking n. v 2014 Steve Marschner 5

Back face culling For closed shapes you will never see the inside therefore only draw surfaces that face the camera implement by checking n. v 2014 Steve Marschner 5

Back face culling For closed shapes you will never see the inside therefore only draw surfaces that face the camera implement by checking n. v 2014 Steve Marschner 5

Back face culling For closed shapes you will never see the inside therefore only draw surfaces that face the camera implement by checking n. v n v v n 2014 Steve Marschner 5

Painter s algorithm Simplest way to do hidden surfaces Draw from back to front, use overwriting in framebuffer 2014 Steve Marschner 6

Painter s algorithm Simplest way to do hidden surfaces Draw from back to front, use overwriting in framebuffer 2014 Steve Marschner 6

Painter s algorithm Simplest way to do hidden surfaces Draw from back to front, use overwriting in framebuffer 2014 Steve Marschner 6

Painter s algorithm Simplest way to do hidden surfaces Draw from back to front, use overwriting in framebuffer 2014 Steve Marschner 6

Painter s algorithm Simplest way to do hidden surfaces Draw from back to front, use overwriting in framebuffer 2014 Steve Marschner 6

Painter s algorithm Simplest way to do hidden surfaces Draw from back to front, use overwriting in framebuffer 2014 Steve Marschner 6

Painter s algorithm Amounts to a topological sort of the graph of occlusions that is, an edge from A to B means A sometimes occludes B any sort is valid ABCDEF BADCFE if there are cycles there is no sort A B C D E F B F C D A E 2014 Steve Marschner 7

Painter s algorithm Amounts to a topological sort of the graph of occlusions that is, an edge from A to B means A sometimes occludes B any sort is valid ABCDEF BADCFE if there are cycles there is no sort [Foley et al.] 2014 Steve Marschner 7

Painter s algorithm Useful when a valid order is easy to come by Compatible with alpha blending 2014 Steve Marschner 8[Foley et al.]

The z buffer In many (most) applications maintaining a z sort is too expensive changes all the time as the view changes many data structures exist, but complex Solution: draw in any order, keep track of closest allocate extra channel per pixel to keep track of closest depth so far when drawing, compare object s depth to current closest depth and discard if greater this works just like any other compositing operation 2014 Steve Marschner 9

The z buffer [Foley et al.] another example of a memory-intensive brute force approach that works and has become the standard 2014 Steve Marschner 10

Precision in z buffer The precision is distributed between the near and far clipping planes this is why these planes have to exist also why you can t always just set them to very small and very large distances Generally use z (not world z) in z buffer 2014 Steve Marschner 11

Interpolating in projection linear interp. in screen space linear interp. in world (eye) space 2014 Steve Marschner 12

Interpolating in projection linear interp. in screen space linear interp. in world (eye) space 2014 Steve Marschner 12

Interpolating in projection linear interp. in screen space linear interp. in world (eye) space 2014 Steve Marschner 12

Interpolating in projection linear interp. in screen space linear interp. in world (eye) space 2014 Steve Marschner 12

Interpolating in projection linear interp. in screen space linear interp. in world (eye) space 2014 Steve Marschner 12

Interpolating in projection linear interp. in screen space linear interp. in world (eye) space 2014 Steve Marschner 12

Interpolating in projection linear interp. in screen space linear interp. in world (eye) space 2014 Steve Marschner 12

Pipeline for minimal operation Vertex stage (input: position / vtx; color / tri) transform position (object to screen space) pass through color Rasterizer pass through color Fragment stage (output: color) write to color planes 2014 Steve Marschner 13

Result of minimal pipeline 2014 Steve Marschner 14

Pipeline for basic z buffer Vertex stage (input: position / vtx; color / tri) transform position (object to screen space) pass through color Rasterizer interpolated parameter: z (screen z) pass through color Fragment stage (output: color, z ) write to color planes only if interpolated z < current z 2014 Steve Marschner 15

Result of z-buffer pipeline 2014 Steve Marschner 16

Flat shading Shade using the real normal of the triangle same result as ray tracing a bunch of triangles Leads to constant shading and faceted appearance truest view of the mesh geometry [Foley et al.] 2014 Steve Marschner 17

Pipeline for flat shading Vertex stage (input: position / vtx; color and normal / tri) transform position and normal (object to eye space) compute shaded color per triangle using normal transform position (eye to screen space) Rasterizer interpolated parameters: z (screen z) pass through color Fragment stage (output: color, z ) write to color planes only if interpolated z < current z 2014 Steve Marschner 18

Result of flat-shading pipeline 2014 Steve Marschner 19

Transforming normal vectors Transforming surface normals differences of points (and therefore tangents) transform OK normals do not --> use inverse transpose matrix 2014 Steve Marschner (with previous instructors James/Bala) 20

Transforming normal vectors Transforming surface normals differences of points (and therefore tangents) transform OK normals do not --> use inverse transpose matrix 2014 Steve Marschner (with previous instructors James/Bala) 20

Gouraud shading Often we re trying to draw smooth surfaces, so facets are an artifact compute colors at vertices using vertex normals interpolate colors across triangles Gouraud shading Smooth shading [Gouraud thesis] 2014 Steve Marschner 21

Gouraud shading Often we re trying to draw smooth surfaces, so facets are an artifact compute colors at vertices using vertex normals interpolate colors across triangles Gouraud shading Smooth shading [Foley et al.] [Gouraud thesis] 2014 Steve Marschner 21

Pipeline for Gouraud shading Vertex stage (input: position, color, and normal / vtx) transform position and normal (object to eye space) compute shaded color per vertex transform position (eye to screen space) Rasterizer interpolated parameters: z (screen z); r, g, b color Fragment stage (output: color, z ) write to color planes only if interpolated z < current z 2014 Steve Marschner 22

Result of Gouraud shading pipeline 2014 Steve Marschner 23

Local vs. infinite viewer, light Phong illumination requires geometric information: light vector (function of position) eye vector (function of position) surface normal (from application) Light and eye vectors change need to be computed (and normalized) for each vertex 2014 Steve Marschner 24

Local vs. infinite viewer, light Look at case when eye or light is far away: distant light source: nearly parallel illumination distant eye point: nearly orthographic projection in both cases, eye or light vector changes very little Optimization: approximate eye and/or light as infinitely far away 2014 Steve Marschner 25

Directional light Directional (infinitely distant) light source light vector always points in the same direction often specified by position [x y z 0] many pipelines are faster if you use directional lights 2014 Steve Marschner 26

Directional light Directional (infinitely distant) light source light vector always points in the same direction often specified by position [x y z 0] many pipelines are faster if you use directional lights 2014 Steve Marschner 26

Infinite viewer Orthographic camera projection direction is constant Infinite viewer even with perspective, can approximate eye vector using the image plane normal can produce weirdness for wide-angle views Blinn-Phong: light, eye, half vectors all constant! 2014 Steve Marschner 27

Vertex normals Need normals at vertices to compute Gouraud shading Best to get vtx. normals from the underlying geometry e. g. spheres example Otherwise have to infer vtx. normals from triangles simple scheme: average surrounding face normals [Foley et al.] 2014 Steve Marschner 28

Non-diffuse Gouraud shading Can apply Gouraud shading to any illumination model it s just an interpolation method Results are not so good with fast-varying models like specular ones problems with any highlights smaller than a triangle [Foley et al.] 2014 Steve Marschner 29

Per-pixel (Phong) shading Get higher quality by interpolating the normal just as easy as interpolating the color but now we are evaluating the illumination model per pixel rather than per vertex (and normalizing the normal first) in pipeline, this means we are moving illumination from the vertex processing stage to the fragment processing stage 2014 Steve Marschner 30

Per-pixel (Phong) shading Bottom line: produces much better highlights [Foley et al.] 2014 Steve Marschner 31

Pipeline for per-pixel shading Vertex stage (input: position, color, and normal / vtx) transform position and normal (object to eye space) transform position (eye to screen space) pass through color Rasterizer interpolated parameters: z (screen z); r, g, b color; x, y, z normal Fragment stage (output: color, z ) compute shading using interpolated color and normal write to color planes only if interpolated z < current z 2014 Steve Marschner 32

Result of per-pixel shading pipeline 2014 Steve Marschner 33

Programming hardware pipelines Modern hardware graphics pipelines are flexible programmer defines exactly what happens at each stage do this by writing shader programs in domain-specific languages called shading languages rasterization is fixed-function, as are some other operations (depth test, many data conversions, ) One example: OpenGL and GLSL (GL Shading Language) several types of shaders process primitives and vertices; most basic is the vertex program after rasterization, fragments are processed by a fragment program 2014 Steve Marschner 34

GLSL Shaders application triangles attributes vertex program varying parameters uniform variables rasterizer varying parameters fragment program depth color framebuffer 2014 Steve Marschner 35