Pipeline Operations. CS 4620 Lecture 10

Similar documents
Pipeline Operations. CS 4620 Lecture 14

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

CS4620/5620: Lecture 14 Pipeline

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

3D Rasterization II COS 426

The Rasterization Pipeline

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

Introduction to Visualization and Computer Graphics

Rasterization Overview

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

Computer Graphics. Shadows

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

CS 464 Review. Review of Computer Graphics for Final Exam

CS 130 Final. Fall 2015

CEng 477 Introduction to Computer Graphics Fall 2007

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

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

CHAPTER 1 Graphics Systems and Models 3

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

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Deferred Rendering Due: Wednesday November 15 at 10pm

Interpolation using scanline algorithm

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

The Traditional Graphics Pipeline

CS 4620 Program 3: Pipeline

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

Computer Graphics Lecture 11

Illumination & Shading: Part 1

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

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

Graphics and Interaction Surface rendering and shading

Lecture outline Graphics and Interaction Surface rendering and shading. Shading techniques. Introduction. Surface rendering and shading

Computer Graphics 10 - Shadows

CS5620 Intro to Computer Graphics

Graphics for VEs. Ruth Aylett

The Traditional Graphics Pipeline

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

Computer Graphics I Lecture 11

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

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

The Traditional Graphics Pipeline

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

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

Graphics Hardware and Display Devices

Hidden surface removal. Computer Graphics

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

Graphics and Interaction Rendering pipeline & object modelling


Illumination and Shading

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

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

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

Graphics Pipeline 2D Geometric Transformations

CS 130 Exam I. Fall 2015

Hidden Surface Removal

Introduction to Computer Graphics with WebGL

Illumination and Shading

CS Computer Graphics: Hidden Surface Removal

9. Illumination and Shading

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

Graphics for VEs. Ruth Aylett

- Rasterization. Geometry. Scan Conversion. Rasterization

CS 4620 Midterm, March 21, 2017

Computer Graphics. Bing-Yu Chen National Taiwan University

QUESTION BANK 10CS65 : COMPUTER GRAPHICS AND VISUALIZATION

Level of Details in Computer Rendering

RASTERISED RENDERING

CS 325 Computer Graphics

Projections and Hardware Rendering. Brian Curless CSE 557 Fall 2014

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

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

Illumination Models & Shading

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Computer Graphics. Illumination and Shading

Computergrafik. Matthias Zwicker. Herbst 2010

Computer Graphics Introduction. Taku Komura

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

Homework #2. Shading, Ray Tracing, and Texture Mapping

Models and Architectures

Visualisatie BMT. Rendering. Arjan Kok

Topics and things to know about them:

Complex Shading Algorithms

Hidden Surfaces II. Week 9, Mon Mar 15

CS452/552; EE465/505. Intro to Lighting

Institutionen för systemteknik

Introduction to Computer Graphics 7. Shading

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

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

CS 130 Exam I. Fall 2015

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

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

Computer Graphics. Illumination and Shading

Virtual Reality for Human Computer Interaction

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Intro to Ray-Tracing & Ray-Surface Acceleration

Advanced Shading I: Shadow Rasterization Techniques

Illumination and Shading

Rendering Light Reflection Models

Illumination & Shading

Transcription:

Pipeline Operations CS 4620 Lecture 10 2008 Steve Marschner 1

Hidden surface elimination Goal is to figure out which color to make the pixels based on what s in front of what.

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 2008 Steve Marschner 3

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 n v v 2008 Steve Marschner 4

5

Painter s algorithm Simplest way to do hidden surfaces Draw from back to front, use overwriting in framebuffer 2008 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 D A D ABCDEF E B BADCFE A F C B E if there are cycles F there is no sort C 2008 Steve Marschner 7

Painter's algorithm examples of cycles No sort unless polygons are divided into small pieces 8

Painter s algorithm [Foley et al.] Useful when a valid order is easy to come by Compatible with alpha blending (later) 2008 Steve Marschner 9

The z buffer In many (most) applications maintaining a z sort is too expensive changes all the time when the view changes many data structures exist, but complex Solution: draw in any order, keep track of closest Z-buffer keeps track of closest depth so far when drawing, compare object s depth to current closest depth and discard if greater 2008 Steve Marschner 1

1

Z-Buffering: Algorithm allocate z-buffer; viewport. // Allocate depth buffer Same size as for each pixel (x,y) // For each pixel in viewport. writepixel(x,y,backgrnd); // Initialize color. writedepth(x,y,farplane); // Initialize depth (z) buffer. for each polygon // Draw each polygon (in any order). for each pixel (x,y) in polygon // Rasterize polygon. pz = polygon s z-value at (x,y);// Interpolate z-value at (x, y). if (pz > z-buffer(x,y)) // If new depth is closer: writepixel(x,y,color); // Write new (polygon) color. writedepth(x,y,pz); // Write new depth.

Z-Buffering: Example Scan convert the following two polygons. The number in the pixel represents the z- value for that pixel -1-3 -2-5 -4-3 -7-6 -5-4 -1-2 -3-3 -4-5 -4-5 -6-7 (0,3) (0,0) (3,0) (0,0) Does order matter? (3,0) (3,3)

Z-Buffering: Example + -1-2 -3-3 -4-5 -4-5 -6-7 = -1-2 -3-3 -4-5 -4-5 -6-7 = -1-3 -2-5 -4-3 -7-6 -5-4 + -1-3 -2-5 -4-3 -7-6 -5-4 + -1-2 -3-3 -4-5 -4-5 -6-7 = -1-1 -2-3 -3-2 -3-4 -5-4 -3-4 -5-6 -5-7 -4 = -1-1 -2-3 -3-2 -3-4 -5-4 -3-4 -7-5 -6-5 -4 + -1-3 -2-5 -4-3 -7-6 -5-4

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

Z-Buffering : Summary Advantages: Easy to implement Fast with hardware support Fast depth buffer memory On most hardware No sorting of objects Shadows are easy (later) Disadvantages: Extra memory required for z-buffer: Integer depth values Scan-line algorithm Prone to aliasing Super-sampling

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 2008 Steve Marschner 1

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 2008 Steve Marschner 1

Interpolating in projection linear interp. in screen space linear interp. in world (eye) space Solution: linearly interpolate 1/z' Read, if you are interested, http://www.lysator.liu.se/~mikaelk/doc/perspectivetexture/ 2008 Steve Marschner 1

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 [Foley et al.] truest view of the mesh geometry 2008 Steve Marschner 2

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 2008 Steve Marschner 2

Result of flat-shading pipeline 2008 Steve Marschner 2

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 face 2008 Steve Marschner 2

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 2008 Steve Marschner 2

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 2008 Steve Marschner 2

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! 2008 Steve Marschner 2

Specular shading (Blinn-Phong) Close to mirror half vector near normal Measure near by dot product of unit vectors Cornell CS4620 Fall 2008 Lecture 3 specularly reflected light specular coefficient 2008 Steve Marschner 27

Gouraud shading [Gouraud thesis] 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 2008 Steve Marschner 2 ]

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 2008 Steve Marschner 2

Result of Gouraud shading pipeline 2008 Steve Marschner 3

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

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 [Foley et al.] problems with any highlights smaller than a triangle 2008 Steve Marschner 3

Phong shading Get higher quality by interpolating the normal [Foley et al.] 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 2008 Steve Marschner 3

Phong shading [Foley et al.] Bottom line: produces much better highlights 2008 Steve Marschner 3

Pipeline for Phong 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 2008 Steve Marschner 3

Result of Phong shading pipeline 2008 Steve Marschner 3