DEFERRED RENDERING STEFAN MÜLLER ARISONA, ETH ZURICH SMA/

Similar documents
Deferred Rendering Due: Wednesday November 15 at 10pm

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

GUERRILLA DEVELOP CONFERENCE JULY 07 BRIGHTON

Screen Space Ambient Occlusion TSBK03: Advanced Game Programming

Shadows. COMP 575/770 Spring 2013

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

TSBK03 Screen-Space Ambient Occlusion

Pipeline Operations. CS 4620 Lecture 14

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

CS354R: Computer Game Technology

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

COMP 4801 Final Year Project. Ray Tracing for Computer Graphics. Final Project Report FYP Runjing Liu. Advised by. Dr. L.Y.

Real-Time Shadows. Computer Graphics. MIT EECS Durand 1

Ambient Occlusion. Ambient Occlusion (AO) "shadowing of ambient light "darkening of the ambient shading contribution

Pipeline Operations. CS 4620 Lecture 10

Advanced Deferred Rendering Techniques. NCCA, Thesis Portfolio Peter Smith

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

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

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

The Rasterization Pipeline

Deferred Renderer Proof of Concept Report

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

GLSL Applications: 2 of 2

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

Shaders. Slide credit to Prof. Zwicker

Parallelizing Graphics Pipeline Execution (+ Basics of Characterizing a Rendering Workload)

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Practical Techniques for Ray Tracing in Games. Gareth Morgan (Imagination Technologies) Aras Pranckevičius (Unity Technologies) March, 2014

Enhancing Traditional Rasterization Graphics with Ray Tracing. October 2015

Getting fancy with texture mapping (Part 2) CS559 Spring Apr 2017

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

Optimizing and Profiling Unity Games for Mobile Platforms. Angelo Theodorou Senior Software Engineer, MPG Gamelab 2014, 25 th -27 th June

Game Technology. Lecture Physically Based Rendering. Dipl-Inform. Robert Konrad Polona Caserman, M.Sc.

The Traditional Graphics Pipeline

Enhancing Traditional Rasterization Graphics with Ray Tracing. March 2015

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

Hardware Accelerated Volume Visualization. Leonid I. Dimitrov & Milos Sramek GMI Austrian Academy of Sciences

Real-Time Rendering of a Scene With Many Pedestrians

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

Rasterization Overview

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

Chapter 7 - Light, Materials, Appearance

Computer Graphics. Lecture 02 Graphics Pipeline. Edirlei Soares de Lima.

Computer Graphics Shadow Algorithms

Ambien Occlusion. Lighting: Ambient Light Sources. Lighting: Ambient Light Sources. Summary

Last Time. Reading for Today: Graphics Pipeline. Clipping. Rasterization

Deus Ex is in the Details

After the release of Maxwell in September last year, a number of press articles appeared that describe VXGI simply as a technology to improve

The Rasterization Pipeline

Next-Generation Graphics on Larrabee. Tim Foley Intel Corp

Computer Graphics. Shadows

Graphics Processing Unit Architecture (GPU Arch)

EECS 487: Interactive Computer Graphics

Basic GPU techniques Josef Pelikán CGG MFF UK Praha.

Screen Space Ambient Occlusion. Daniel Kvarfordt & Benjamin Lillandt

Parallelizing Graphics Pipeline Execution (+ Basics of Characterizing a Rendering Workload)

A bit more Deferred - CryEngine 3. Triangle Game Conference 2009 Martin Mittring Lead Graphics Programmer

The Traditional Graphics Pipeline

Real-Time Shadows. Last Time? Schedule. Questions? Today. Why are Shadows Important?

Render-To-Texture Caching. D. Sim Dietrich Jr.

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Real-Time Universal Capture Facial Animation with GPU Skin Rendering

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

Real Time Rendering of Expensive Small Environments Colin Branch Stetson University

CS-184: Computer Graphics. Administrative

Computer Graphics Lecture 11

CS4620/5620: Lecture 14 Pipeline

Dominic Filion, Senior Engineer Blizzard Entertainment. Rob McNaughton, Lead Technical Artist Blizzard Entertainment

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

The Traditional Graphics Pipeline

Interactive Methods in Scientific Visualization

By: Tyler Spears Mentor: Dr. Bijaya Karki. Visualizing Time- Dependent Atomic Data in OpenGL

Advanced Computer Graphics CS 563: Screen Space GI Techniques: Real Time

CHAPTER 1 Graphics Systems and Models 3

CS427 Multicore Architecture and Parallel Computing

Sung-Eui Yoon ( 윤성의 )

Graphics Performance Optimisation. John Spitzer Director of European Developer Technology

OpenGL fun in the Sponza Atrium

Mali Demos: Behind the Pixels. Stacy Smith

Computergrafik. Matthias Zwicker. Herbst 2010

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

Real-Time Shadows. MIT EECS 6.837, Durand and Cutler

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

Tiled shading: light culling reaching the speed of light. Dmitry Zhdan Developer Technology Engineer, NVIDIA

Real-Time Voxelization for Global Illumination

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

Voxel Cone Tracing and Sparse Voxel Octree for Real-time Global Illumination. Cyril Crassin NVIDIA Research

High-quality Shadows with Improved Paraboloid Mapping

Applications of Explicit Early-Z Z Culling. Jason Mitchell ATI Research

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

Dynamic Ambient Occlusion and Indirect Lighting. Michael Bunnell NVIDIA Corporation

Shadow and Environment Maps

PowerVR Hardware. Architecture Overview for Developers

SUMMARY. CS380: Introduction to Computer Graphics Ray tracing Chapter 20. Min H. Kim KAIST School of Computing 18/05/29. Modeling

CS452/552; EE465/505. Shadow Mapping in WebGL

CS 498 VR. Lecture 19-4/9/18. go.illinois.edu/vrlect19

Rendering Grass with Instancing in DirectX* 10

Rendering Objects. Need to transform all geometry then

Transcription:

DEFERRED RENDERING STEFAN MÜLLER ARISONA, ETH ZURICH SMA/2013-11-04

DEFERRED RENDERING?

CONTENTS 1. The traditional approach: Forward rendering 2. Deferred rendering (DR) overview 3. Example uses of DR: a. Deferred shading b. Ambient occlusion (AO) 4. Basic mechanisms to realize DR in OpenGL 5. A simple deferred renderer in C++/Cinder 6. Wrap-up & discussion 7. Questions & further reading

LEARNING GOALS Understand the motivation for DR and how it is different from forward rendering. Know the advantages, challenges, and limitations of DR. Understand example uses of DR (shading, AO). Know the basic mechanisms in OpenGL to realize DR. Download and explore the sample renderer.

1. FORWARD RENDERING

FORWARD RENDERING GENERAL APPROACH The traditional approach since early OpenGL. Geometric objects are sent as primitives to the GL. Their vertices are transformed and processed by the vertex shader. The primitives are rasterized. The fragments are processed by the fragment shader (final color, depth test, masking, blending). Shading can happen either in vertex or fragment shader or both. Final fragments are written (or not written) to the framebuffer.

Source: opengl.org OpenGL 1.1 specification

Source: opengl.org OpenGL 4.4 specification, p32

FORWARD RENDERING OBSERVATIONS & LIMITATIONS Classic, widely established and straightforward approach. Supported by all graphics hardware. Lighting cost Every object in the scene is shaded (remember that depth test happens after fragment shading). Complexity is o(n Geometries_pixels * n Lights ). Some workarounds do exist (e.g. early depth test). Local lighting only, no support for global illumination (GI). Shader complexity increases with number of geometry types, material types, and light types.

2. DEFERRED RENDERING

DEFERRED RENDERING GENERAL IDEA Multi-pass rendering approaches. Emerging methodology, refers to a whole class of approaches, with many different options and possibilities. General goal of the approaches is to reduce the amount of fragments shaded (i.e., shade final visible fragments only).

DEFERRED RENDERING ORIGINAL IDEA Pass 1: Write geometry plus attributes into buffers (often called G-Buffers). Typical attributes: Diffuse color, position, normal, texture coordinates. Pass 2 - n: Operate on rendered frame buffers (i.e. in screen space). Use attributes to calculate final pixel color. M Deering, S Winner, B Schediwy, C Duffy, N Hunt (1988). "The triangle processor and normal vector shader: a VLSI system for high performance graphics". ACM SIGGRAPH Computer Graphics 22 (4): 21 30. T Saito, T Takahashi (1990). "Comprehensible rendering of 3-D shapes". ACM SIGGRAPH Computer Graphics 24 (4): 197 206.

Object Geometry & Attributes Lights & Other Shading-related Information Geometry Pass G-Buffer G-Buffer Shading Pass(es) Shading Pass Final Image (via Blending or Compositing)

3A. EXAMPLE USES OF DR DEFERRED SHADING

DEFERRED SHADING GENERAL IDEA Similar to previously shown diagram. Geometry pass stores information required for lighting in each fragment: Diffuse color, position, normals. Shading pass then shades each framebuffer pixel for each light according to chosen shading equation. n L(v, n) = cdiff fdiff(blk, lk, v, n)+ cspec fspec(blk, lk, v, n) k=1

Object Geometry & Attributes Lights (Point or Directional) Geometry Pass G-Buffer G-Buffer Lighting Pass Final Image (via Blending or Compositing) Diffuse Color, Normal, Position Diffuse & Phong Coefficients

Diffuse Depth Normals Position

DEFERRED SHADING GENERAL IDEA Similar to previously shown diagram Geometry pass stores information required for lighting in each fragment: Diffuse color, position, normals. Shading pass then shades each framebuffer pixel for each light according to chosen shading equation. Overall complexity o(n Framebuffer_pixels * n Lights )

DEFERRED SHADING LIGHT VOLUMES Most lights do not influence every pixel, e.g. when distant / small. Thus, for each light we can only draw the area of influence. For point lights, use a sphere or a cube. For directional lights, use a cone or a pyramid. Size of objects is determined by a light s attenuation factors.

3B. EXAMPLE USES OF DR AMBIENT OCCLUSION

AMBIENT OCCLUSION INTRODUCTION Ambient occlusion is a technique that approximates global illumination (GI), and in particular deals with ambient environment lighting. In simple terms, the techniques takes into account that some areas of an object receive less light from the surrounding environment than others. Such areas need to be attenuated. First implemented by Hayden Landis et al. at ILM around 2002 for RenderMan, i.e. non-real-time.

Diffuse Lighting Only Ambient Occlusion Diffuse + AO AO Contact Shadow Lucas Digital LLC. Source: Pixar http://renderman.pixar.com/view/production-ready-global-illumination

AMBIENT OCCLUSION EARLIER IMPLEMENTATIONS Generate ambient occlusion map for the model. Render the map together with environment map. Generation can be hardware accelerated, e.g., using shadow mapping with a large number of lights. For each triangle { Compute center of triangle Generate set of rays over the hemisphere there Vector avgunoccluded = Vector(0, 0, 0); int numunoccluded = 0; For each ray { If (ray doesn't intersect anything) { avgunoccluded += ray.direction; ++numunoccluded; } } avgunoccluded = normalize(avgunoccluded); accessibility = numunoccluded / numrays; } From NVidia GPUGems, Chapter 17 http://http.developer.nvidia.com/gpugems/gpugems_ch17.html

AMBIENT OCCLUSION APPROXIMATION USING DR How can AO be achieved using deferred rendering?

SSAO: SCREEN SPACE AMBIENT OCCLUSION!!! Approximates AO for real-time applications using a deferred fragment shader.!!! Originally developed at Crytec in 2007 for the game Crysis, and then extended / modified by others.!!! Instead of casting rays to obtain occlusion information, the SSAO approach samples the depth buffer.!

SSAO Most of today s implementations use a depth and a normal map, with random samples on a hemisphere. Each sample is then tested whether it occludes the current pixel or not (depending on depth difference). The number of samples needs to be reduced to a minimum (typically 10-16) to achieve acceptable performance. If for every pixel the same samples are used, banding results. Therefore the sample locations are randomly rotated for every pixel. The random rotation results in noise, which is then removed through blur.

From http://john-chapman-graphics.blogspot.com/2013/01/ssao-tutorial.html

SSAO Advantages Independent of scene complexity & dynamics. Fully in hardware. Well suited for deferred renderers (as normal map is typically available). Disadvantages Noise removal requires extra blur stage. Limited range of sample sphere makes approach relatively local and view dependent.

4. OPENGL MECHANISMS

Source: opengl.org OpenGL 4.4 specification, p32

OPENGL MECHANISMS OVERVIEW OpenGL mechanisms that are used for realizing DR: 1. Programmable shading Vertex shading, fragment shading 2. Framebuffer objects (FBOs) 3. Multiple render targets (MRTs)

OPENGL MECHANISMS FRAMEBUFFER OBJECTS (FBOS) FBOs encapsulate a framebuffer that can be used for offscreen rendering. Each FBO has a given dimension, and a number of attachments (n color buffers, depth buffer, and stencil buffer). Attached buffers are either textures or renderbuffers. FBOs can be enabled for writing and reading.

OPENGL MECHANISMS FBO RELEVANT API glgenframebuffer, gldeleteframebuffers glbindframebuffer Bind for reading or writing glclearbuffer glframebuffertexture2d Attach texture to FBO glcheckframebufferstatus Important: Check if FBO is correctly set up

OPENGL MECHANISMS MULTIPLE RENDER TARGETS (MRT) Since we want to write multiple object attributes to the FBO s attachments, the corresponding outputs need to be declared in the shader: out vec4 color; out vec4 normal; Use gldrawbuffers to enable writing to selected FBO attachments. Note: Make sure these specifications match the FBO structure.

5. A SIMPLE DEFERRED RENDERER IN C++/CINDER

CINDER DEFERRED RENDERER OVERVIEW A small renderer exemplifying some of the presented techniques. Written in C++ using the Cinder framework. Adapted from original code by Anthony Scavarelli and others, with several fixes and optimizations. http://libcinder.org https://github.com/arisona/cinder_deferred_renderer Note 1: Based on OpenGL 2.0 + Extensions L Note 2: Updated to use C++11 J

CINDER DEFERRED RENDERER FEATURES Deferred shading of a large number of point lights (1000+). SSAO http://www.gamerendering.com/2009/01/14/ssao/ Shadow support, but not for 1000 lights (more on this during the next lecture). FXAA (screen space software approximation to antialiasing). http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/fxaa_whitepaper.pdf

Diffuse Color, Normal, Position Depth, Two-sided Flag Diffuse & Phong Coefficients Object Geometry & Attributes Geometry Pass G-Buffer G-Buffer Lighting Pass FBO Compositing & FXAA Lights (Point) SSAO & Blur FBO Final Image Shadow Map Creation (Simplified) FBO

6. WRAP UP & DISCUSSION

WRAP UP DR can be used to build a multi-pass renderer that includes lighting, GI and effect compositing. Allows for large amount of (dynamic) lights. However, minimization of light volumes is essential. Many game engines include deferred renderers (e.g. Unity Pro, Torque). In particular, SSAO has become a standard technique for ambient lighting.

WRAP UP DR LIMITATIONS Requires reasonably modern, programmable graphics hardware (not generally a problem today). Memory usage. Memory bandwidth. No support for transparency, need to use forward rendering for semi-transparent objects. If above limitations become a factor, forward rendering can still be the better choice.

UNITY RENDERING PATHS! Rendering Paths Comparison Deferred Lighting Forward Rendering Vertex Lit Features Per-pixel lighting (normal maps, light cookies) Yes Yes - Realtime shadows Yes 1 Directional Light - Dual Lightmaps Yes - - Depth&Normals Buffers Yes Additional render passes - Soft Particles Yes - - Semitransparent objects - Yes Yes Anti-Aliasing - Yes Yes Light Culling Masks Limited Yes Yes Lighting Fidelity All per-pixel Some per-pixel All per-vertex Performance Cost of a per-pixel Light Number of pixels it illuminates Number of pixels * Number of objects it illuminates - Platform Support PC (Windows/Mac) Shader Model 3.0+ Shader Model 2.0+ Anything Mobile (ios/android) OpenGL ES 2.0 OpenGL ES 2.0 OpenGL ES 2.0 & 1.1 Consoles 360, PS3 360, PS3 - Page last updated: 2013-08-27 Source: Unity Technologies

7. QUESTIONS & LINKS

LINKS: DEFERRED SHADING http://en.wikipedia.org/wiki/deferred_shading http://ogldev.atspace.co.uk/www/tutorial35/tutorial35.html OpenGL deferred shading tutorial (tutorials 35-37). http://developer.amd.com/wordpress/media/2012/10/deferred%20shading%20optimizations.pps Excellent discussion on deferred shading strategies and optimizations. http://www.realtimerendering.com/blog/deferred-lighting-approaches/ Some additional considerations regarding deferred lighting. http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/fxaa_whitepaper.pdf FXAA method used in sample code. Very useful for screen space operations.

LINKS: AO / SSAO http://en.wikipedia.org/wiki/ambient_occlusion http://renderman.pixar.com/view/production-ready-global-illumination Good overview into ambient lighting techniques by Hayden Landis. http://http.developer.nvidia.com/gpugems/gpugems_ch17.html Overview of AO (not SSAO) implementation of GPUs. http://en.wikipedia.org/wiki/screen_space_ambient_occlusion http://john-chapman-graphics.blogspot.com/2013/01/ssao-tutorial.html Comprehensive and intuitive SSAO tutorial.