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

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

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

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

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

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Today. Rendering algorithms. Rendering algorithms. Images. Images. Rendering Algorithms. Course overview Organization Introduction to ray tracing

Overview. By end of the week:

Rasterization Overview

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

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

Prof. Feng Liu. Fall /19/2016

Geometry: Outline. Projections. Orthographic Perspective

Models and The Viewing Pipeline. Jian Huang CS456

CSE328 Fundamentals of Computer Graphics

Lecture 4. Viewing, Projection and Viewport Transformations

Three-Dimensional Viewing Hearn & Baker Chapter 7

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

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

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

3D Viewing. CS 4620 Lecture 8

Game Architecture. 2/19/16: Rasterization

COMP3421. Introduction to 3D Graphics

Viewing. Reading: Angel Ch.5

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker

Viewing and Projection

Viewing and Projection

CS230 : Computer Graphics Lecture 6: Viewing Transformations. Tamar Shinar Computer Science & Engineering UC Riverside

Virtual Cameras & Their Matrices

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

CS451Real-time Rendering Pipeline

The Graphics Pipeline and OpenGL I: Transformations!

COMP3421. Introduction to 3D Graphics

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

Viewing COMPSCI 464. Image Credits: Encarta and

3.1 Viewing and Projection

Computer Graphics. Chapter 10 Three-Dimensional Viewing

Drawing in 3D (viewing, projection, and the rest of the pipeline)

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

OpenGL Transformations

To Do. Demo (Projection Tutorial) Motivation. What we ve seen so far. Outline. Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 5: Viewing

Computer Graphics 7: Viewing in 3-D

COMP3421. Introduction to 3D Graphics

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

Drawing in 3D (viewing, projection, and the rest of the pipeline)

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

To Do. Motivation. Demo (Projection Tutorial) What we ve seen so far. Computer Graphics. Summary: The Whole Viewing Pipeline

CHAPTER 1 Graphics Systems and Models 3

Viewing with Computers (OpenGL)

Motivation. What we ve seen so far. Demo (Projection Tutorial) Outline. Projections. Foundations of Computer Graphics

Lecture 4 of 41. Lab 1a: OpenGL Basics

Classical and Computer Viewing. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Graphics Pipeline 2D Geometric Transformations

Rendering Objects. Need to transform all geometry then

Introduction to Computer Graphics 4. Viewing in 3D

3D Viewing. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

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

Overview of Projections: From a 3D world to a 2D screen.

One or more objects A viewer with a projection surface Projectors that go from the object(s) to the projection surface

Last week. Machiraju/Zhang/Möller/Fuhrmann

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

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

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Computergrafik. Matthias Zwicker. Herbst 2010

Models and Architectures

Evening s Goals. Mathematical Transformations. Discuss the mathematical transformations that are utilized for computer graphics

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

Perspective projection and Transformations

CS 4620 Program 3: Pipeline

Introduction to Computer Graphics with WebGL

Chapter 5. Projections and Rendering

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

Transforms 3: Projection Christian Miller CS Fall 2011

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

The Rendering Pipeline (1)

Viewing and Projection

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

Projection: Mapping 3-D to 2-D. Orthographic Projection. The Canonical Camera Configuration. Perspective Projection

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

The Graphics Pipeline and OpenGL I: Transformations!

Overview. Viewing and perspectives. Planar Geometric Projections. Classical Viewing. Classical views Computer viewing Perspective normalization

Graphics pipeline and transformations. Composition of transformations

The Importance of Matrices in the DirectX API. by adding support in the programming language for frequently used calculations.

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

3D Viewing. Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Fondamenti di Grafica 3D The Rasterization Pipeline.

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

CS 591B Lecture 9: The OpenGL Rendering Pipeline

- Rasterization. Geometry. Scan Conversion. Rasterization

CS 130 Final. Fall 2015

Reminder: Affine Transformations. Viewing and Projection. Shear Transformations. Transformation Matrices in OpenGL. Specification via Ratios

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

CS 4204 Computer Graphics

Transformation Pipeline

CITSTUDENTS.IN VIEWING. Computer Graphics and Visualization. Classical and computer viewing. Viewing with a computer. Positioning of the camera

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

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

Pipeline Operations. CS 4620 Lecture 14

Transcription:

Computergrafik Today Rendering pipeline s View volumes, clipping Viewport Matthias Zwicker Universität Bern Herbst 2008 Rendering pipeline Rendering pipeline Hardware & software that draws 3D scenes on the screen Most operations performed by specialized hardware (GPU) Access to hardware through low-level 3D API (DirectX, OpenGL) jogl is a Java binding to OpenGL All scene data flows through the pipeline at least once for each frame Rendering pipeline Rendering pipeline implements object order algorithm Loop over all objects Draw triangles one by one (rasterization) Alternatives? Advantages, disadvantages? Object vs. order Object order Rasterization type algorithms Desirable memory access pattern ( streaming, data locality, avoid random scene access) Suitable for real time rendering (OpenGL, DirectX) Popular for production rendering (Pixar RenderMan), where scenes often do not fit in RAM Full global illumination not possible with purely object order algorithm order Ray tracing type algorithms Undesirable memory access pattern (random scene access) Requires sophisticaed data structures for fast scene access Full global illumination possible Most popular for photo-realistic image synthesis Rendering engine Rendering engine (jtrt) Rendering pipeline Additional software layer encapsulating low-level API (OpenGL, DirectX, ) Additional functionality Layered software architecture common in industry Game engines http://en.wikipedia.org/wiki /Game_engine 1

Rendering pipeline stages Rendering pipeline stages Geometry Vertices and how they are connected Triangles, lines, points, triangle strips Attributes such as color Specified in object Processed by the rendering pipeline one-by-one Textures, lights, etc. Transform object to camera MODELVIEW matrix Specified by GL_MODELVIEW matrix in OpenGL User computes GL_MODELVIEW matrix as discussed Rendering pipeline stages Rendering pipeline stages Look up light sources Compute color for each vertex Later in the course Project 3D vertices to 2D image positions GL_PROJECTION matrix This lecture Rendering pipeline stages Rendering pipeline stages Draw primitives (triangles, lines, etc.) Determine what is visible Next lecture Pixel colors 2

Today Rendering pipeline s View volumes, clipping Viewport Object, world, camera coords. Object World Objects in camera We have things lined up the way we like them on screen x to the right y up -z going into the screen Objects to look at are in front of us, i.e. have negative z values But objects are still in 3D Today: how to project them into 2D s Given 3D points (vertices) in camera, determine corresponding 2D image Orthographic projection Simply ignore z-coordinate Use camera space xy as image Orthographic projection Project points to x-y plane along parallel lines Graphical illustrations, architecture Most common for computer graphics Simplified model of human eye, or camera lens (pinhole camera) Things farther away seem smaller Discovery/formalization attributed to Filippo Brunelleschi in the early 1400 s 3

Project along rays that converge in center of projection Parallel lines no longer parallel, converge at one point Center of projection 3D scene 2D image plane Earliest example La Trinitá (1427) by Masaccio The math: simplified case The math: simplified case plane plane Can express this using homogeneous, 4x4 matrices The math: simplified case matrix Homogeneous division matrix Homogeneous coord.!= 1! Homogeneous division Using projection matrix, homogeneous division seems more complicated than just multiplying all by d/z, so why do it? Will allow us to handle different types of projections in a unified way define arbitrary view volumes 4

Background Projective space: the space of one-dimensional vector subspaces of a given vector space Elements of projective spaces are 1D vector subspaces Each element of 1D subspace is equivalent (represents same element of projective space) For example, projective space P 3 represented using R 4 and homogeneous Each point along 4D ray is equivalent to same 3D point at w=1 x λx x/w y λy y/w equivalent z λz z/w w λw 1 1D vector subspace, arbitrary scalar value Equivalent element, for any Background Projective mapping: any non-singular linear mapping on homogeneous, for example, Generalization of affine mappings, arbitrary homogeneous coordinate Projective mappings preserve straight lines, but not parallel lines Much more theory http://www.math.toronto.edu/mathnet/questioncorner/projective.html http://en.wikipedia.org/wiki/projective_space Background P 3 can be interpreted as consisting of R 3 and its points at infinity Points are said to be at infinity if w = 0 Represented by direction vector Do parallel lines intersect at infinity? In projective geometry, yes. http://www.math.toronto.edu/mathnet/questioncorner/infin ity.html Points at infinity (2,1,0,1) (2,1,0,0.5) ~ (4,2,0,1) Point at infinity, direction vector (2,1,0,0) (2,1,0,0.33333) ~ (6,3,0,1) 2D line intersection Two line equations Intersection c b x 0 = 0 0 / c 1 b 1 y 0 = a 0 c 0 a 1 c 1 a 0 x + b 0 y + c 0 =0 a 1 x + b 1 y + c 1 =0 a 0 b 0 a 1 b 1 / a 0 b 0 a 1 b 1 Determinant Using homogeneous Line equations a 0 x + b 0 y + wc 0 =0 a 1 x + b 1 y + wc 1 =0 h a0 b 0 x i c 0 y w h a1 b 1 x i c 1 y w Lines parallel: division by zero 5

Using homogeneous Line equations a 0 x + b 0 y + wc 0 =0 a 1 x + b 1 y + wc 1 =0 h a0 b 0 x i c 0 y w h a1 b 1 x i c 1 y w Intersection: any scalar multiple of = x 0 a 0 a y 0 b 0 1 b w 0 1 c 0 c x 0 /w 0 1 y 0 /w 0 Lines not parallel: intersection is 1 Lines parallel: w =0, intersection at infinity! Projective space Projective space [xyzw] homogeneous includes points at infinity (w=0) projective mappings (perspective projection) Vector space Affine space [xyz] [xyz1], [xyz0] represents vectors homogeneous coords. linear mappings distinguishes points (rotation around origin, and vectors scaling, shear) affine mappings (translation) In practice Use 4x4 homogeneous matrices normally Modeling & viewing s are affine mappings points keep w=1 no need to divide by w when doing modeling operations or transforming into camera space is a projective transform Resulting w coordinate not always 1 Divide by w (perspective division, homogeneous division) after multiplying with projection matrix OpenGL rendering pipeline (graphics hardware) does this automatically Realistic image formation More than perspective projection Lens effects Focus, depth of field Fish-eye lens Realistic image formation Chromatic aberration Motion blur Today Rendering pipeline s View volumes, clipping Viewport Often too complicated for hardware rendering pipeline 6

View volumes Define 3D volume seen by camera Perspective view volume General view volume Perspective view volume Orthographic view volume World World Defined by 6 parameters, in camera Left, right, top, bottom boundaries Near, far clipping planes Clipping planes to avoid numerical problems Divide by zero Low precision for distant objects Usually symmetric, i.e., left=-right, top=-bottom Perspective view volume Symmetric view volume Orthographic view volume y y=top FOV -z z=-near Only 4 parameters Vertical field of view (FOV) aspect ratio (width/height) Near, far clipping planes z=-far right left aspect ratio= top bottom right top tan(fov /2) top near Parametrized by 6 parameters Right, left, top, bottom, near, far If symmetric Width, height, near, far Clipping Need to identify objects outside view volume Avoid division by zero Efficiency, don t draw objects outside view volume Performed by OpenGL rendering pipeline Clipping always to canonic view volume Cube[-1..1]x[-1..1]x[-1..1] centered at origin Need to transform desired view frustum to canonic view frustum Clipping Primitives Clip to view frustum 7

Canonic view volume matrix is set such that User defined view volume is transformed into canonic view volume, i.e., cube [-1,1]x[-1,1]x[-1,1] Multiplying vertices of view volume by projection matrix and performing homogeneous divide yields canonic view volume Perspective and orthographic projection are treated exactly the same way matrix matrix Canonic view volume Clipping matrix General view frustum matrix Compare to simple projection matrix from before Simple projection General view frustum matrix Symmetric view frustum with field of view, aspect ratio, near and far clip planes y y=top FOV z=-near 1 0 0 0 aspect tan(fov /2) 1 0 0 0 P persp (FOV,aspect,near, far) tan(fov /2) near far 0 0 near far 0 0 1 0 z=-far -z 2 near far near far Orthographic projection matrix 2 right left 0 0 right left right left 2 top bottom 0 0 P ortho (right,left,top,bottom,near, far) top bottom top bottom 2 far near 0 0 far near far near 0 0 0 1 2 0 0 0 width 2 0 0 0 P ortho (width,height,near, far) height 2 far near 0 0 far near far near 0 0 0 1 w = 1 after mult. with orthographic projection matrix 8

Questions? Today Rendering pipeline s View volumes Viewport Viewport After applying projection matrix, image points are in normalized view Per definition range [-1..1] x [-1..1] Map points to image (i.e., pixel) User defined range [x0 x1] x [y0 y1] Scale and translation The complete transform Mapping a 3D point in object to pixel Object space Dx 0, x 1, y 0, y 1 2 0 0 x 0 x 1 2 2 x 1 x 0 0 y 1 y 0 2 0 y 0 y 1 0 0 1 2 12 0 0 0 1 The complete transform Mapping a 3D point in object to pixel The complete transform Mapping a 3D point in object to pixel Object space World space Object space World space space 9

The complete transform Mapping a 3D point in object to pixel The complete transform Mapping a 3D point in object to pixel Object space World space space Canonic view volume Object space World space space Canonic view volume space The complete transform Mapping a 3D point in object to pixel OpenGL OpenGL GL_MODELVIEW matrix OpenGL GL_PROJECTION matrix Pixel OpenGL rendering pipeline performs these matrix multiplications automatically User just specifies the matrices Seejrtr.GLRenderContext.draw OpenGL GL_MODELVIEW, C -1 M Up to you to define GL_PROJECTION, P Utility routines to set it by specifying view volume: glfrustum(), glperspective(), glortho() Do not use utility functions for project 2 You will implement a software renderer in project 3, which will not rely on any OpenGL Viewport, D Specify implicitly via glviewport() No direct access Coming up Next lecture Drawing (rasterization) Visibility (z-buffering) Exercise session Project 2, interactive viewing 10