Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Similar documents
Graphics Pipeline & APIs

Graphics Pipeline & APIs

Today. Rendering - III. Outline. Texturing: The 10,000m View. Texture Coordinates. Specifying Texture Coordinates in GL

Lecture 2. Shaders, GLSL and GPGPU

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

Rendering Objects. Need to transform all geometry then

X. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1

E.Order of Operations

Introduction to Shaders.

The Application Stage. The Game Loop, Resource Management and Renderer Design

Graphics Hardware. Instructor Stephen J. Guy

Rasterization Overview

Evolution of GPUs Chris Seitz

Models and Architectures

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

CS427 Multicore Architecture and Parallel Computing

Programmable GPUs. Real Time Graphics 11/13/2013. Nalu 2004 (NVIDIA Corporation) GeForce 6. Virtua Fighter 1995 (SEGA Corporation) NV1

Working with Metal Overview

Programming Graphics Hardware

SHADER PROGRAMMING. Based on Jian Huang s lecture on Shader Programming

Introduction to Computer Graphics with WebGL

Pipeline Operations. CS 4620 Lecture 14

Graphics Processing Unit Architecture (GPU Arch)

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI

Advanced Rendering Techniques

TSBK03 Screen-Space Ambient Occlusion

Introduction to the OpenGL Shading Language

The Graphics Pipeline

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Shaders. Slide credit to Prof. Zwicker

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

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

Spring 2009 Prof. Hyesoon Kim

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

GeForce4. John Montrym Henry Moreton

Spring 2011 Prof. Hyesoon Kim

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Scanline Rendering 2 1/42

CHAPTER 1 Graphics Systems and Models 3

CS4620/5620: Lecture 14 Pipeline

CSE4030 Introduction to Computer Graphics

Graphics Performance Optimisation. John Spitzer Director of European Developer Technology

The Rasterization Pipeline

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley

Could you make the XNA functions yourself?

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

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

INF3320 Computer Graphics and Discrete Geometry

Programming shaders & GPUs Christian Miller CS Fall 2011

CS770/870 Fall 2015 Advanced GLSL

Sign up for crits! Announcments

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

OpenGL SUPERBIBLE. Fifth Edition. Comprehensive Tutorial and Reference. Richard S. Wright, Jr. Nicholas Haemel Graham Sellers Benjamin Lipchak

CS451Real-time Rendering Pipeline

Graphics Hardware. Graphics Processing Unit (GPU) is a Subsidiary hardware. With massively multi-threaded many-core. Dedicated to 2D and 3D graphics

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 Graphics and OpenGl. First Steps

Graphics Hardware, Graphics APIs, and Computation on GPUs. Mark Segal

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

WebGL (Web Graphics Library) is the new standard for 3D graphics on the Web, designed for rendering 2D graphics and interactive 3D graphics.

Module 13C: Using The 3D Graphics APIs OpenGL ES

Enabling immersive gaming experiences Intro to Ray Tracing

Supplement to Lecture 22

2.11 Particle Systems

Introduction to the Direct3D 11 Graphics Pipeline

Beginning Direct3D Game Programming: 1. The History of Direct3D Graphics

Grafica Computazionale: Lezione 30. Grafica Computazionale. Hiding complexity... ;) Introduction to OpenGL. lezione30 Introduction to OpenGL

World Coordinate System

Graphics Hardware. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 2/26/07 1

Graphics Pipeline 2D Geometric Transformations

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

INF3320 Computer Graphics and Discrete Geometry

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

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

1.2.3 The Graphics Hardware Pipeline

Real - Time Rendering. Pipeline optimization. Michal Červeňanský Juraj Starinský

Sung-Eui Yoon ( 윤성의 )

CS770/870 Spring 2017 Open GL Shader Language GLSL

CS770/870 Spring 2017 Open GL Shader Language GLSL

Computergrafik. Matthias Zwicker. Herbst 2010

OpenGL. White Square Code 11/4/09. OpenGL. OpenGL. OpenGL

PROFESSIONAL. WebGL Programming DEVELOPING 3D GRAPHICS FOR THE WEB. Andreas Anyuru WILEY. John Wiley & Sons, Ltd.

Drawing Fast The Graphics Pipeline

Direct Rendering of Trimmed NURBS Surfaces

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

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

PowerVR Hardware. Architecture Overview for Developers

Ciril Bohak. - INTRODUCTION TO WEBGL

CS450/550. Pipeline Architecture. Adapted From: Angel and Shreiner: Interactive Computer Graphics6E Addison-Wesley 2012

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

Drawing Fast The Graphics Pipeline

Drawing Fast The Graphics Pipeline

Computer graphics 2: Graduate seminar in computational aesthetics

Next-Generation Graphics on Larrabee. Tim Foley Intel Corp

OpenGL refresher. Advanced Computer Graphics 2012

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

Lecture 9: Deferred Shading. Visual Computing Systems CMU , Fall 2013

Case 1:17-cv SLR Document 1-3 Filed 01/23/17 Page 1 of 33 PageID #: 60 EXHIBIT C

Transcription:

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer wimmer@cg.tuwien.ac.at

Walking down the graphics pipeline Application Geometry Rasterizer

What for? Understanding the rendering pipeline is the key to real-time rendering! Insights into how things work Understanding algorithms Insights into how fast things work Performance Vienna University of Technology 3

Simple Graphics Pipeline Often found in text books Will take a more detailed look into OpenGL Application Geometry Rasterizer Display Vienna University of Technology 4

Rasterizer Geometry CPU Graphics Pipeline (pre DX10, OpenGL 2 ) Application Driver Command Geometry Rasterization Texture Fragment Display Nowadays, everything part of the pipeline is hardware accelerated Fragment: pixel, but with additional info (alpha, depth, stencil, ) Vienna University of Technology 5

Fixed Function Pipeline Dataflow View video memory on-chip cache memory system memory geometry commands pre-tnl cache vertex shading (T&L) post-tnl cache CPU triangle setup rasterization textures frame buffer texture cache fragment shading and raster operations Vienna University of Technology 6

Rasterizer Geometry CPU DirectX10 /OpenGL 3.2 Evolution Application Driver Command Geometry Rasterization Texture Fragment Display Vertex Buffer Index Buffer Texture Texture Buffer Memory Texture Depth Color Stream Out Input Assembler Vertex Shader Geometry Shader Setup/ Rasterization Pixel Shader Output Merger Vienna University of Technology 7

OpenGL 3.0 OpenGL 2.x is not as capable as DirectX 10 But: New features are vendor specific extensions (geometry shaders, streams ) GLSL a little more restrictive than HLSL (SM 3.0) OpenGL 3.0 did not clean up this mess! OpenGL 2.1 + extensions Geometry shaders are only an extension New: depreciation mechanism OpenGL 4.x New extensions OpenGL ES compatibility! Vienna University of Technology 8

DirectX 11/OpenGL 4.0 Evolution Not the final place in the pipeline!!! fixed programmable memory Constant Constant Constant Constant Control Point Shader Input Tessellator Assembler Vertex Shader Geometry Shader Setup Rasterizer Pixel Shader Output Merger Sampler Sampler Sampler Stream Sampler out Texture Vertex Buffer Index Texture Buffer Texture Stream Buffer Texture Depth Stencil Render Target Memory Vienna University of Technology 9

DirectX 11 Tesselation At unexpected position! Compute Shaders Multithreading To reduce state change overhead Dynamic shader linking HDR texture compression Many other features... Vienna University of Technology 10

DirectX 11 Pipeline Vienna University of Technology 11

DirectX 12/Vulkan/AMD Mantle/Apple Metal Reduce driver overhad Indirect drawing Pipeline state objects Command lists/bundles Partly possible already in OpenGL 4.3+ Other features Conservative rasterization (for culling) New blend modes Order-independent transparency Vienna University of Technology 12

Application Generate database (Scene description) Usually only once Load from disk Build acceleration structures (hierarchy, ) Simulation (Animation, AI, Physics) Input event handlers Modify data structures Database traversal Shaders (vertex,geometry,fragment) Vienna University of Technology 13

Driver Maintain graphics API state Command interpretation/translation Host commands GPU commands Handle data transfer Memory management Emulation of missing hardware features Usually huge overhead! Significantly reduced in DX10 Vienna University of Technology 14

Geometry Stage Command Vertex Processing Tesselation Geometry Shading Primitive Assembly Clipping Perspective Division Culling Vienna University of Technology 15

Command Command buffering (!) Command interpretation Unpack and perform format conversion ( Input Assembler ) glloadidentity( ); glmultmatrix( T ); glbegin( GL_TRIANGLE_STRIP ); glcolor3f ( 0.0, 0.5, 0.0 ); glvertex3f( 0.0, 0.0, 0.0 ); glcolor3f ( 0.5, 0.0, 0.0 ); glvertex3f( 1.0, 0.0, 0.0 ); glcolor3f ( 0.0, 0.5, 0.0 ); glvertex3f( 0.0, 1.0, 0.0 ); glcolor3f ( 0.5, 0.0, 0.0 ); glvertex3f( 1.0, 1.0, 0.0 ); glend( ); T Color Transformation matrix Vienna University of Technology 16

v e r t e x Vertex Processing Transformation Vertex Processing object eye clip normalized device Modelview Matrix Projection Matrix Perspective Division Viewport Transform window Modelview Projection Modelview Vienna University of Technology 17

Vertex Processing Fixed function pipeline: User has to provide matrices, the rest happens automatically Programmable pipeline: User has to provide matrices/other data to shader Shader Code transforms vertex explicitly We can do whatever we want with the vertex! Usually a gl_modelviewprojectionmatrix is provided In GLSL-Shader : gl_position = ftransform(); Vienna University of Technology 18

Vertex Processing Lighting Texture coordinate generation and/or transformation Vertex shading for special effects T Object-space triangles Screen-space lit triangles Vienna University of Technology 19

Tesselation If just triangles, nothing needs to be done, otherwise: Evaluation of polynomials for curved surfaces Create vertices (tesselation) DirectX11 specifies this in hardware! 3 new shader stages!!! Still not trivial (special algorithms required) Vienna University of Technology 20

DirectX11 Tesselation control shader evaluation shader Vienna University of Technology 21

Tesselation Example Optimally tesslated! Vienna University of Technology 22

Geometry Shader Calculations on a primitive (triangle) Access to neighbor triangles Limited output (1024 32-bit values) No general tesselation! Applications: Render to cubemap Shadow volume generation Triangle extension for ray tracing Extrusion operations (fur rendering) Vienna University of Technology 23

Rest of Geometry Stage Primitive assembly Geometry shader Clipping (in homogeneous coordinates) Perspective division, viewport transform Culling Vienna University of Technology 24

Rasterization Stage Triangle Setup Rasterization Fragment Processing Texture Processing Raster Operations Vienna University of Technology 25

Rasterization Setup (per-triangle) Sampling (triangle = {fragments}) Interpolation (interpolate colors and coordinates) Screen-space triangles Fragments Vienna University of Technology 26

Rasterization Sampling inclusion determination In tile order improves cache coherency Tile sizes vendor/generation specific Old graphics cards: 16x64 New: 4x4 Smaller tile size favors conditionals in shaders All tile fragments calculated in parallel on modern hardware Vienna University of Technology 27

Rasterization Coordinates Fragments represent future pixels y window coordinate 3.0 Pixel center at (2.5, 1.5)! Lower left corner of the window 2.0 1.0 0.0 Pixel (2,1) 0.0 1.0 2.0 3.0 x window coordinate Vienna University of Technology 28

Rasterization Rules Separate rule for each primitive Non-ambiguous! Polygons: Pixel center contained in polygon On-edge pixels: only one is rasterized Vienna University of Technology 29

Texture Texture transformation and projection E.g., projective textures Texture address calculation (programmable in shader) Texture filtering Fragments Texture Fragments Vienna University of Technology 30

Fragment Texture operations (combinations, modulations, animations etc.) Texture Fragments Fragments Textured Fragments Vienna University of Technology 31

Raster Tests Ownership Is pixel obscured by other window? Scissor test Only render to scissor rectangle Depth test Test according to z-buffer Alpha test Test according to alpha-value Stencil test Test according to stencil buffer Textured Fragments Framebuffer Pixels Vienna University of Technology 32

Raster Operations Blending or compositing Dithering Logical operations Textured Fragments Framebuffer Pixels Vienna University of Technology 33

Raster Operations After fragment color calculation ( Output Merger ) Fragment and associated data Pixel Ownership Test Depth Test Scissor Test Stencil Test Alpha Test Depth Buffer Stencil Buffer Blending (RGBA only) Dithering Logicop Frame Buffer Vienna University of Technology 34

Display Gamma correction Digital to analog conversion if necessary Framebuffer Pixels Light Vienna University of Technology 35

Display Frame buffer pixel format: RGBA vs. index (obsolete) Bits: 16, 32, 128 bit floating point, Double buffered vs. single buffered Quad-buffered for stereo Overlays (extra bit planes) for GUI Auxiliary buffers: alpha, stencil Vienna University of Technology 36

Functionality vs. Frequency Geometry processing = per-vertex Transformation and Lighting (T&L) Historically floating point, complex operations Today: fully programmable flow control, texture lookup 20-1500 million vertices per second Fragment processing = per-fragment Blending and texture combination Historically fixed point and limited operations Up to 50 billion fragments ( Gigatexel /sec) Floating point, programmable complex operations Vienna University of Technology 37

Computational Requirements Application Command Geometry Rasterization Texture Fragment Display Assume typical non-trivial fixedfunction rendering task 1 light, texture coordinates, projective texture mapping 7 interpolants (z,r,g,b,s,t,q) Trilinear filtering, texture-, color blending, depth buffering Rough estimate: ADD CMP MUL DIV Vertex 102 30 108 5 Fragment 66 9 70 1 Vienna University of Technology 38

Communication Requirements Vertex size: Position x,y,z Normal x,y,z Texture coordinate s,t 8 4 = 32 bytes Texture: Color r,g,b,a, 4 bytes Display: Color r,g,b, 3 bytes Fragment size (in frame buffer): Color r,g,b,a Depth z (assume 32 bit) 8 bytes, but goes both ways (because of blending!) Vienna University of Technology 39

Communication Requirements 20 Mvert/s 0.640 GB/s Application Command Geometry Rasterization Vertex Fragment 4 GB/s 5 Gops 150 Gops 1000 Mpix/s Texture Fragment Texture Memory Framebuffer 120 Mpix/s Display 0.36 GB/s Vienna University of Technology 40 16 GB/s