We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byAddison Merton
Modified over 2 years ago
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 2/16 Per-vertex lighting is ugly Can increase number of vertices, but this requires lots of extra memory Per-pixel lighting looks a lot better But is much slower than per-vertex, must calculate lighting equation for each pixel instead of each vertex. Naïve implementation has many wasted calculations Why? Calculates lighting on pixels that are later overwritten by a closer triangle Deferred lighting removes most of the wasted calculations and provides further optimizations Deferred Lighting – 11/18/2014 Motivation
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 3/16 How can we avoid wasted calculations? Only calculate lighting once for each pixel But the fragment shader has no way of knowing if the value it is calculating will be the final value for that pixel Solution: Multiple passes First pass Render geometry and keep track of data necessary to calculate lighting Second pass Calculate diffuse and specular values that are independent of material Third Pass Combine diffuse/specular from second pass with geometry and materials (ex. Object color) to complete lighting model Deferred Lighting – 11/18/2014 Overview
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 4/16 A “pass” just means generating a texture (or multiple textures). Use framebuffer objects (FBOs) to group textures Most of the shaders you’ve written used a single pass Take in geometry and various uniforms, output a texture to the screen In lab 8 you used multiple passes Use geometry/lights to output a texture with per-pixel phong lighting (first pass) Use phong texture in brightpass, output texture with bright areas (second pass) Use brightpass texture in lightblur, output blurred texture (third pass) Use blurred texture and original phong texture, output final image (fourth pass) Deferred Lighting – 11/18/2014 Passes
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 5/16 Takes in all our geometry as input Doesn’t need material properties (ex. textures) It outputs exactly the information we need to calculate lighting Normals Positions – but we can use a trick to save space Shininess – store as alpha channel of normal Deferred Lighting – 11/18/2014 First Pass
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 6/16 Takes in normals, shininess and positions from first pass and light data Outputs diffuse and specular light contributions Can save space by rendering to a single texture and storing specular contribution as alpha (but we only get monochromatic specular highlights) Or render diffuse and specular to separate textures How do we send light data to GPU? For each light: Set necessary uniforms (position, direction, etc…) Naïve: render full-screen quad to run the fragment shader on each pixel Can do better, see slide 10 But each light would overwrite data from previous light Solution: glBlendFunc(GL_ONE, GL_ONE) for additive blending glBlendFunc Deferred Lighting – 11/18/2014 Second Pass (1/2)
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 7/16 Deferred Lighting – 11/18/2014 Second Pass (2/2) DiffuseSpecular
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 8/16 Takes in diffuse and specular contribution from second pass and geometry, textures, etc… (whatever we need to calculate object’s diffuse color) Render the scene again, this time applying any materials and finishing the lighting equation (i.e. finish calculating diffuse and specular term and add ambient + diffuse + specular) Output is our final lit scene which goes to the screen Deferred Lighting – 11/18/2014 Third Pass (1/2)
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/16 Deferred Lighting – 11/18/2014 Third Pass (2/2)
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 10/16 Instead of calculating lighting on every pixel for every light, calculate lighting on only the subset of pixels that a light can possibly affect. Restrict the lighting calculations to the geometric shape that represents the volume of the light. In the second pass render this 3D shape instead of a full-screen quad. Point light: sphere (radius usually based on attenuation) Spot light: cone Directional light: full-screen quad What if the camera is inside the shape of the light? Represent light as a full-screen quad We will still have some wasted calculations, but this is much better (especially for small lights). Deferred Lighting – 11/18/2014 Optimizations
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 11/16 Deferred Lighting – 11/18/2014 Optimizations How the light is representedLight visualized in scene
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 12/16 Deferred Lighting – 11/18/2014 Optimizations Diffuse contribution Visualization of lights Final scene
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 13/16 The second pass needs to know the position of each pixel in world space Our first pass shader can easily write this position to a texture Doing this uses an extra texture (i.e. twice as much memory) Instead, use the depth buffer from the first pass. First pass already uses a depth buffer, so we don’t need any additional space. Depth buffer has z value from 0 to 1 for each pixel in screen space (convert x/y to screen space based on width/height). Use the (x,y,z) triplet in screen space and the inverse projection and view matrices to transform to world space. Deferred Lighting – 11/18/2014 Optimizations
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 14/16 Deferred shading is another method for speeding up per-pixel lighting, almost the same as deferred lighting. Note that the word “shading” here doesn’t refer to interpolating lighting values, its just the name of this technique Uses only 2 passes First pass renders geometry storing normals as in deferred lighting, but also stores all material properties (diffuse color, for example) in one or more additional textures Second pass calculates lighting and uses material properties to calculate final pixel color Pros: Less computation (don’t need to render the scene twice) Cons: Uses more memory and bandwidth (passing extra textures around) Deferred Lighting – 11/18/2014 Deferred Shading
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 15/16 Deferred Lighting – 11/18/2014 Deferred Lighting 1. Render normals, positions, and shininess to textures 2. Calculate diffuse and specular contributions for every light and output to textures 3. Render scene again using diffuse/specular light data to calculate final pixel color (according to lighting model) Deferred Shading 1. Render normals, positions, shininess, and material properties to textures 2. Calculate lighting for every light and combine with material properties to output final pixel color Overview
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 16/16 Can’t easily handle transparency (this is a generic issue with z-buffer rendering techniques) Solutions: Naïve: Sort transparent objects by distance Slow Can’t handle intersecting transparent objects Order-independent transparency: Depth peeling Order-independent transparency Use forward-rendering for transparent objects Forward-rendering is the standard rendering pipeline that you’ve been using Can’t use traditional anti-aliasing techniques MSAA (Multisample anti-aliasing), one of the most common AA techniques, doesn’t work at all with deferred lighting Usually use some sort of screen-space anti-aliasing instead (FXAA, MLAA, SMAA) Deferred Lighting – 11/18/2014 Disadvantages of Deferred Rendering
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Graphics Pipeline. Goals Understand the difference between inverse- mapping and forward-mapping approaches to computer graphics rendering Be familiar.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Parallel Lighting Directional Lighting Distant Lighting (take your pick) Paul Taylor 2010.
Technology and Historical Overview. Introduction to 3d Computer Graphics 3D computer graphics is the science, study, and method of projecting a mathematical.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Deferred Shading Optimizations Nicolas Thibieroz, AMD
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Week 7 - Monday. What did we talk about last time? Specular shading Aliasing and antialiasing.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Status – Week 277 Victor Moya. Lightning Diffuse Lightning. Diffuse Lightning. Light Sources. Light Sources. Specular Lightning. Specular Lightning. Emission.
Computer Graphics An Introduction. What’s this course all about? 05/10/2014 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Visual Appearance Chapter 4 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
2010©. Introduction Graphics Rendering Pipeline Architecture Application Stages Geometry Stages Rasterizer Stages.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
4.3. L IGHTING AND S HADING Exploration of advanced lighting and shading techniques.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Rendering Fur with Three Dimensional Textures James T. Kajiya and Timothy L. Kay.
Cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam Texture Mapping Beautification of Surfaces 1/23.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Point-based Graphics for Estimated Surfaces Tyler Johnson Department of Computer Science University of North Carolina at Chapel Hill COMP 236 Final Project.
1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Week 6 - Wednesday. What did we talk about last time? Light Material Sensors.
3D Graphics Rendering and Terrain Modeling Technology and Historical Overview By Ricardo Veguilla.
Computer Graphics Inf4/MSc Computer Graphics Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
13.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
4.2. D EFERRED S HADING Exploration of deferred shading (rendering)
Grass, Fur and all things hairy Nicolas ThibierozKarl Hillesland Gaming Engineering Manager, AMDSenior Research Engineer, AMD.
Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
The Art and Technology Behind Bioshock’s Special Effects Presented by Stephen Alexander (Effects Artist) Jesse Johnson (Graphics Programmer)
CAP4730: Computational Structures in Computer Graphics Lighting and Shading.
POST-PROCESSING SET09115 Intro Graphics Programming.
TERRAIN SET09115 Intro to Graphics Programming. Breakdown Basics What do we mean by terrain? How terrain rendering works Generating terrain
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
LIGHTING SET09115 Intro Graphics Programming. Breakdown Working with Colour Basics of Lighting Why Lighting? Ambient Light Surface Lighting.
Single Pass Point Rendering and Transparent Shading Paper by Yanci Zhang and Renato Pajarola Presentation by Harmen de Weerd and Hedde Bosman.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
© 2017 SlidePlayer.com Inc. All rights reserved.