Computer Graphics with OpenGL ES (J. Han) Chapter VII Rasterizer

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

Rasterization Overview

OpenGL Transformations

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

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

The Graphics Pipeline and OpenGL I: Transformations!

3D Graphics for Game Programming (J. Han) Chapter II Vertex Processing

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

Rendering Objects. Need to transform all geometry then

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

CS 112 The Rendering Pipeline. Slide 1

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

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

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

The Rendering Pipeline (1)

Pipeline Operations. CS 4620 Lecture 14

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

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

Projection Matrix Tricks. Eric Lengyel

Rendering If we have a precise computer representation of the 3D world, how realistic are the 2D images we can generate? What are the best way to mode

Chapter 5. Projections and Rendering

三維繪圖程式設計 3D Graphics Programming Design 第三章三維繪圖狀態設定和幾何元件繪製嘉大資工系盧天麒

Advanced Lighting Techniques Due: Monday November 2 at 10pm

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

Pipeline Operations. CS 4620 Lecture 10

CS4620/5620: Lecture 14 Pipeline

CS 464 Review. Review of Computer Graphics for Final Exam

- Rasterization. Geometry. Scan Conversion. Rasterization

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

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

Class of Algorithms. Visible Surface Determination. Back Face Culling Test. Back Face Culling: Object Space v. Back Face Culling: Object Space.

3D Viewing. CS 4620 Lecture 8

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

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

CHAPTER 1 Graphics Systems and Models 3

Lecture 4. Viewing, Projection and Viewport Transformations

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

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

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

Scanline Rendering 2 1/42

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

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

1 OpenGL - column vectors (column-major ordering)

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

Introduction to Computer Graphics with WebGL

CS488. Implementation of projections. Luc RENAMBOT

Practical Shadow Mapping

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

Models and Architectures

CS 428: Fall Introduction to. Polygon rendering: additional topics. Andrew Nealen, Rutgers, /14/2009 1

Computer Graphics. Chapter 10 Three-Dimensional Viewing

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

E.Order of Operations

CS 130 Final. Fall 2015

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

The Graphics Pipeline and OpenGL I: Transformations!

OUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system

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

CSC 305 The Graphics Pipeline-1

Rendering. Part 1 An introduction to OpenGL

Computer Graphics 10 - Shadows

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Visibility: Z Buffering

Hidden surface removal. Computer Graphics

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

CS 432 Interactive Computer Graphics

Computer Graphics. Shadows

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

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

CSE452 Computer Graphics

CSE328 Fundamentals of Computer Graphics

Texture Mapping. Texture (images) lecture 16. Texture mapping Aliasing (and anti-aliasing) Adding texture improves realism.

Hidden Surface Removal

lecture 16 Texture mapping Aliasing (and anti-aliasing)

CS464 Oct 3 rd Assignment 3 Due 10/6/2017 Due 10/8/2017 Implementation Outline

VTU QUESTION PAPER SOLUTION UNIT -1 INTRODUCTION

World Coordinate System

Normalized Device Coordinate System (NDC) World Coordinate System. Example Coordinate Systems. Device Coordinate System

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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: 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

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

Game Architecture. 2/19/16: Rasterization

CS 4204 Computer Graphics

Graphics Pipeline. CS535 Fall Daniel G. Aliaga Department of Computer Science Purdue University

CS452/552; EE465/505. Intro to Lighting

Einführung in Visual Computing

CS 130 Exam I. Fall 2015

Hidden-Surface Removal.

4.5 VISIBLE SURFACE DETECTION METHODES

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Culling. Computer Graphics CSE 167 Lecture 12

Computer Graphics and Visualization. Graphics Systems and Models

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

CS Exam 1 Review Problems Fall 2017

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques

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

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Transcription:

Chapter VII Rasterizer

Rasterizer The vertex shader passes the clip-space vertices to the rasterizer, which performs the following: Clipping Perspective division Back-face culling Viewport transform Scan conversion (rasterization in a narrow sense) 7-2

Clipping Clipping is performed in the clip space, but the following figure presents its concept in the camera space, for the sake of intuitive understanding. Completely outside triangles are discarded. Completely inside triangles are accepted. Intersecting triangles are clipped. As a result of clipping, vertices may be added to and deleted from the triangle. Clipping in the (homogeneous) clip space is a little complex but welldeveloped algorithm. 7-3

Perspective Division Unlike affine transforms, the last row of M proj is not (0 0 0 1) but (0 0-1 0). When M proj is applied to (x,y,z,1), the w-coordinate of the transformed vertex is z. In order to convert from the homogeneous (clip) space to the Cartesian space, each vertex should be divided by its w-coordinate (which equals z). 7-4

Perspective Division (cont d) Note that z is a positive value representing the distance from the xy-plane of the camera space. Division by z makes distant objects smaller. It is perspective division. The result is said to be in NDC (normalized device coordinates). 7-5

Back-face Culling The polygons facing away from the viewpoint of the camera are discarded. Such polygons are called back-faces. (The polygons facing the camera are called front-faces.) The projection transform defines a universal connecting vector parallel to the z-axis, which is identical to the view direction. 7-6

Back-face Culling (cont d) Viewing a triangle along the universal view direction is equivalent to orthographically projecting the triangle onto the xy-plane. A 2D triangle with CW-ordered vertices is a back-face, and a 2D triangle with CCW-ordered vertices is a front-face. Compute the following determinant, where the first row represents the 2D vector connecting v 1 and v 2, and the second row represents the 2D vector connecting v 1 and v 3. If negative, CW and so back-face. If it is positive, CCW and so front-face. If 0, edge-on face. 7-7

Back-face Culling (cont d) The back-faces are not always culled. Consider rendering a translucent sphere. For the back-faces to show through the front-faces, no face will be culled. Another example is culling only the front faces of a hollow sphere. Then the cross-section view of the sphere will be obtained. Various GL capabilities are enabled by glenable and disabled by gldisable. void glenable(glenum cap) & void gldisable(glenum cap) An example is glenable(gl_cull_face), which enables face culling. The default value is GL_FALSE. 7-8

Back-face Culling (cont d) When face culling is enabled, glcullface() specifies whether front or back faces are culled. It accepts the following symbolic constants: GL_FRONT GL_BACK GL_FRONT_AND_BACK The default value is GL_BACK, and back faces are culled. Then, glfrontface() specifies the vertex order of front faces. It accepts the following: GL_CW GL_CCW The default value is GL_CCW. 7-9

Viewport A window at the computer screen is associated with its own screen space. A viewport defines a screen-space rectangle into which the scene is projected. The rectangle is not necessarily the entire window, but can be a sub-area of the window. y window viewport x 7-10

Viewport In reality, the screen space is 3D and so is the viewport, where the z-axis goes into the window. void glviewport(glint MinX, GLint MinY, GLsizei W, GLsizei H) (MinX,MinY) specify the screen coordinates of the viewport s lower left corner in pixels W and H specify the width and height of viewport in pixels. These values must be > 0 void gldepthrangef(glclampf n, GLclampf f) (n,f) specify the desired depth range. Default values for n and f are 0.0 and 1.0. 7-11

Viewport Transform In most applications, MinZ and MaxZ are set to 0.0 and 1.0, respectively, and both of MinX and MinY are zero. 7-12

Scan Conversion Each screen-space triangle is rasterized into a set of fragments at the screenspace pixel locations covered by the triangle. The per-vertex attributes are interpolated to determine the per-fragment attributes at each pixel location. The per-vertex attributes usually do not include RGB color but include normals and texture coordinates. Just for the convenience of presentation, however, let s assume color attributes and use R color for scan conversion. 7-13

Scan Conversion (cont d) 7-14

Scan Conversion (cont d) 7-15

Scan Conversion (cont d) In general, what are actually interpolated are not colors but vertex normals and texture coordinates. Given (n x, n y, n z ) per vertex, each of n x, n y, and n z is independently interpolated. Then we have the following interpolated normals. 7-16