Pre-computing Lighting in Games

Slides:



Advertisements
Similar presentations
A Real Time Radiosity Architecture for Video Games
Advertisements

Computer graphics & visualization Global Illumination Effects.
SE 313 – Computer Graphics Lecture 12: Lighting and Materials Lecturer: Gazihan Alankuş 1.
Environment Mapping CSE 781 – Roger Crawfis
The Art and Technology Behind Bioshock’s Special Effects
3D Graphics Rendering and Terrain Modeling
Real-Time Rendering TEXTURING Lecture 02 Marina Gavrilova.
ATEC Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
Rendering with Environment Maps Jaroslav Křivánek, KSVI, MFF UK
Week 9 - Wednesday.  What did we talk about last time?  Fresnel reflection  Snell's Law  Microgeometry effects  Implementing BRDFs  Image based.
Real-Time Rendering Paper Presentation Imperfect Shadow Maps for Efficient Computation of Indirect Illumination T. Ritschel T. Grosch M. H. Kim H.-P. Seidel.
IMGD 1001: Illumination by Mark Claypool
3D Graphics Processor Architecture Victor Moya. PhD Project Research on architecture improvements for future Graphic Processor Units (GPUs). Research.
IN4151 Introduction 3D graphics 1 Introduction to 3D computer graphics part 2 Viewing pipeline Multi-processor implementation GPU architecture GPU algorithms.
Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
7M836 Animation & Rendering
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Computer Graphics Inf4/MSc Computer Graphics Lecture Notes #16 Image-Based Lighting.
Computer Graphics An Introduction. Computer Graphics 26/9/2008Lecture 12 What’s this course all about? We will cover… Graphics programming and algorithms.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
1 Perception and VR MONT 104S, Spring 2008 Lecture 22 Other Graphics Considerations Review.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Introducing To 3D Modeling George Atanasov Telerik Corporation
Today More raytracing stuff –Soft shadows and anti-aliasing More rendering methods –The text book is good on this –I’ll be using images from the CDROM.
Reflections Specular reflection is the perfect reflection of light from a surface. The law a reflection states that the direction of the incoming ray and.
Efficient Irradiance Normal Mapping Ralf Habel, Michael Wimmer Institute of Computer Graphics and Algorithms Vienna University of Technology.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
Jonathan M Chye Technical Supervisor : Mr Matthew Bett 2010.
-Global Illumination Techniques
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
TERRAIN SET09115 Intro to Graphics Programming. Breakdown  Basics  What do we mean by terrain?  How terrain rendering works  Generating terrain 
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
CS 638, Fall 2001 Today Project Stage 0.5 Environment mapping Light Mapping.
Real-Time Relighting Digital Image Synthesis Yung-Yu Chuang 1/10/2008 with slides by Ravi Ramamoorthi, Robin Green and Milos Hasan.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Global Illumination CMSC 435/634. Global Illumination Local Illumination – light – surface – eye – Throw everything else into ambient Global Illumination.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
04/30/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling We are now all done with modeling, the standard hardware pipeline.
SIGGRAPH 2010 Course: Physically Based Shading Models in Film and Game Production SIGGRAPH 2010 Physically Based Shading Models in Film and Game Production.
- Laboratoire d'InfoRmatique en Image et Systèmes d'information
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Surface Rendering Methods 고려대학교 컴퓨터 그래픽스 연구실.
Differential Instant Radiosity for Mixed Reality Martin Knecht, Christoph Traxler, Oliver Mattausch, Werner Purgathofer, Michael Wimmer Institute of Computer.
Spherical Harmonics in Actual Games
Pure Path Tracing: the Good and the Bad Path tracing concentrates on important paths only –Those that hit the eye –Those from bright emitters/reflectors.
Local Illumination and Shading
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
Ambient Occlusion Patrick Cozzi University of Pennsylvania CIS Fall 2013.
Unreal Lighting Clark Kromenaker. Unreal Lightmass UE3’s new lighting system is called Lightmass. Simulates bouncing light in an environment.
01/27/03© 2002 University of Wisconsin Last Time Radiometry A lot of confusion about Irradiance and BRDFs –Clarrified (I hope) today Radiance.
Light Animation with Precomputed Light Paths on the GPU László Szécsi, TU Budapest László Szirmay-Kalos, TU Budapest Mateu Sbert, U of Girona.
1© 2009 Autodesk Hardware Shade – Presenting Your Designs Hardware and Software Shading HW Shade Workflow Tessellation Quality Settings Lighting Settings.
Perspective, Scene Design, and Basic Animation
Game Development Unity3D.
3D Graphics Rendering PPT By Ricardo Veguilla.
Understanding Theory and application of 3D
Austin Grosel & Aaron Ebbinghaus
(c) 2002 University of Wisconsin
Lighting.
Chapter XVI Texturing toward Global Illumination
UMBC Graphics for Games
CS5500 Computer Graphics May 29, 2006
Last Time Presentation of your game and idea Environment mapping
Patrick Cozzi University of Pennsylvania CIS Fall 2012
Illumination and Shading
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Real-time Global Illumination with precomputed probe
Presentation transcript:

Pre-computing Lighting in Games David Larsson Autodesk Inc.

What is baked lighting? Precompute lighting information for static scenes and lights Typically baked to Vertices Textures Light probe points in space for relighting of dynamic objects Most common approach to get access to GI in games Independent of GI algorithm As long as it works in texture space Precomputed lighting is a general concept. This presentation focuses on the static light, static geometry case. Ambient occlusion and PRT, etc are also baked “lighting”. The idea is to move the heavy part of the light computations into the game studio in order to save runtime cpu and gpu time for other things. In the end it’s about delivering 30 or 60 frames per second and that doesn’t leave you with much margins, games is still all about smoke and mirrors. Baked lighting is independent is independent of choice of GI algorithm and can also store direct lighting.

What is baked lighting? Wireframe scene Wireframe UV layout Content courtesy of A2M

What is baked lighting? Diffuse Reflectance scene Diffuse Reflectance in UV space Content courtesy of A2M

What is baked lighting? Lighting only Scene Lighting only in UV space Diffuse light is view independent, suitable for light maps. Specular effects frome baking are possible. It will be covered later in the presentation Lighting only Scene Lighting only in UV space Content courtesy of A2M

What is baked lighting? * = Content courtesy of A2M

Why bake lighting? Quality Performance Lighting Workflow

Quality Allows the highest quality light simulation algorithms GI effects Multiple bounces Allows high quality direct lighting

Quality Image from Mirrors Edge, by EA DICE Note the color bleeding affecting the white object in its yellow environment. Note the blue sky lighting that is the major source of lighting in the shadows Note the shadow penumbra in the sun shadow. All these effects would be expensive to simulate in realtime Image from Mirrors Edge, by EA DICE

Workflow Baked lighting is a way to give artists access to Global Illumination (GI) Define the lighting in terms of actual light sources No artificial fill lights Decouples lighting from the geometry/materials Baked Lighting allows a richer set of light sources Physically based Soft Shadows Shadow Casting HDR light probes GI is a powertool for lighting. Less Manual work. We have seen examples of literally thousands of light sources to simulate an overcast sky environment for an outdoor level Placing manual bounce lights forces change of lighting if you change involved materials and geometry. GI encourages reuse of scenes since you can change the look of an environment by just changing the lighting conditions Examples of light sources that are hard to run in realtime: Emissive objects, lights with soft shadows, HDR domes with shadow casting.

Performance Runtime performance very good Independent of light setup Independent of GI algorithm Good looking light maps run with the same performance as poor looking ones The runtime performance is about one or a few texture fetches per shading sample. The fetches are done in a cache friendly way, it’s not about abusing a texture for a data structure that was never meant to be stored in a texture.

Predictable Performance Runtime performance tends to be very robust Artists can add as many lights as they want Realtime shadow map performance and GI less predictable Light angle and position affects the performance of the shadow rendering Player position affects what lights needs resolution Predictable performance is important. Don’t want the game runtime performance to be different because an artist happened to add too many lights in a small area. Game Engines often have hard limitations on how many lights that can affect an object which can give strange results. Some games uses a higher sun direction for the shadows than for lighting in order to make sure the shadows aren’t cast over the entire scene at sunrise/sunset times. With baked lighting the performance is the same regardless of this.

Scalable Performance Worked in Quake 1 Used on handheld devices today Used in today's high end games On low end platforms baked lighting is the most effective way to get good looking lighting.

Challenges Changing Light Setups Moving/Deformed Geometry Memory Usage for the Baked Lighting Light Rebuild Times

Memory Usage Lighting is global Material textures Lighting textures Instances share material textures Multiple objects can share textures Textures can be tiled and mirrored Lighting textures Must be unique per instance Cannot be tiled, mirrored etc Possible to optimize resolution based on resolution requirements Reference on memory usage for lightmaps Lightmap Compression in HALO 3, Hu Texture memory is scarce on game consoles and making good use of it is important. Lighting is different from many other kinds of textures. Lighting is HDR too which makes texture format choice or encoding even more important.

Normal Maps and Light Maps Normal maps are great for increase the geometry detail level Normal maps introduces high frequency details in the lighting High frequency lighting requires high texture resolution Normal maps forces the resolution of the light map to the same as the normal map in order to capture the details.

Directional Light Maps Details are in the geometry, not in the incoming lighting Store the hemisphere of incoming light per texel in the light map Allows approximation of lighting for different normal directions The first point is somewhat simplified, there is of course a self shadowing aspect of the normal map and fine geometric details

Directional Light Maps Content courtesy of A2M Baked Lighting Low resolution Directional Light maps combined with normal maps Normal Map

Directional Light Maps Typical Encodings Radiosity Normal Maps (RNM) SH (generally 2 bands, 4 components) Per pixel ambient and directional light H-basis Allows real BRDF:s Hemisphere is blurry but it’s possible to get reasonable specular effects from it too References Half-Life 2 / Valve Source Shading, Gary McTaggart An Efficient Representation for Irradiance Environment Maps, Ramamoorthi et al Efficient Irradiance Normal Mapping, Habel, et al

Changing Light Setups Possible to bake different times of days Combinatorial explosion if introducing more changeable lights Treat moving and intensity changing lights like ordinary runtime lights Good for explosions or lights that flicker No indirect lighting Daylight cycles are manageable to precompute since they tend to be the main source of lighting in outdoor scenes. There is no problem combining dynamic and baked lighting so if there are lights that just can’t be baked, it’s easy to treat them independently.

Changing Geometry Separate between local and global changes Local Characters moving in a room Small furniture Bullet holes Global Destroyed buildings Destroyed walls

Local Geometry Changes Two sides of the problem How is the object affected by the environment? How does the object affect its environment? Generally solved without considering how the object affect the indirect lighting in its surrounding.

Incoming Light on Moving Objects The Naïve approach is just adding direct lighting to moving objects. Tends to make characters to look out of place. Also in regions where no direct light reaches, the characters are completely black. Light probes solves these problems elegantly and gives a nice pipeline for lighting characters and other moving objects. Some games keep key lights out of the light probes and add them as more traditional direct lights. Content courtesy A2M

Incoming Light on Moving Objects Bake light probes in the room Use the closest ones to light the object Approximate the incoming lighting as one light probe for an entire object Works well on objects small compared to the environment Very large objects may need special treatment Encodings Spherical harmonics (typically 3 bands) Cube map with 1 pixel per side Single ambient color A light probe in this case means a representation of the incoming light for an arbitrary point in space.

Moving Objects Affecting the Environment Direct lighting lighting in light probes optional Allows self shadowing on dynamic objects Allows the object to cast shadow on the environment Possible to extract strongest light direction from light probes too Described in Stupid SH tricks, Peter Pike Sloan Gives the possibility for self shadowing from indirect lighting Some titles only bake indirect light for lights where character shadow on environment is a big deal Indirect lighting from characters generally insignificant Subtracting a dynamic shadow of a light baked into a light map is not trivial. Common to just multiply the light map color with a darkening factor. More advanced would be to subtract the shadow from the lighting in case the light is not already occluded by the environment but it can give seams since the shadow border from the realtime and the bake shadow doesn’t necessarily match up perfectly.

Global Geometry Changes Highly dynamic games tend to avoid global baked lighting Other subsystems tends to rely on or perform better on static geometry as well Path Finding Collision Detection Game story often requires players following certain paths

Hybrid Solutions Bake only indirect lighting Indirect light generally smoother than direct lighting Sharp shadows needs higher texture resolution Special treatment of the sun Sunlight is often the most influential light for outdoor scenes Direct sunlight often a source of sharp shadows and dynamic range differences Bake indirect only from the sun, add direct as a runtime light Most games are hybrids to some extent. Some lights or components of some lights are computed as dynamic lights. Games having key lights outside the light maps often uses standard one component (as opposed to directional) light maps for the baked lighting. This saves them memory and the key lights will contribute with normal map and specular effects.

Pipeline Level and lighting workflow Asset Creation Level Assembling Light Baking Breakdown of the Light Baking phase Scene Export Light Map Rendering UV Atlasing Texture Compression Data import Not necessarily a one way process but changes in the assets or the scene assembly forces light builds. Scene assembly and lighting are iterative processes. Asset Creation, tends to happen inside Maya, Max etc for meshes and paint programs for textures. Scene Assembly, happens in a dedicated game editor or Maya, Max, or other modeling programs. Lighting, happens inside the game editor and must happen when the entire scene is assebled since it is a global effect where everything can affect everything. UV Atlasing refers to the process of creating a few large textures from many small. This gives no limitations on texture sizes, reduces number of texture switches when rendering and allows different objects uv spaces to overlap as long as no baked information overlaps.

Pipeline implications Light build stage can be time consuming In the magnitude of CPU hours Dependent on algorithm, resolutions, level size, light setup, number of bounces etc Tools to speed things up Selective Light Builds Preview Quality Builds Preview Tools Camera render tools Progressive light map generation Distribution Automatic rebuilds to make sure lighting is always up to date Tools to shorten the iteration times makes a big difference for artist productivity. Being able to work on a room at the time can be an effective way of shortening iteration times. Doing camera renderings inside the offline renderer can give fast previews. It also exposes any differences in what was exported and what the GI result was. Distribution can dramatically cut render times. <ShamelessProductPromotion>Check out Ernst from Autodesk for a cool preview tool for light map baking</ShamelessProductPromotion> Automatic rebuilds is a convenient way to make sure there is always up to date lighting for the scene available after geometry modifications.

Pipeline Implications Clear separation of what is static and dynamic Both for Lights and Geometry Tools for placing and managing light probes in levels Grids Hierarchical grids Arbitrary points Tools for managing texture resolutions and bake type

Pipeline Implications Tools for managing GI specific light source properties Scale factors for direct and indirect lighting in order to exaggerate and separate light contributions Tools for managing GI specific material properties What gives good glow effects and the right look on screen is not necessarily giving the desired light emission on the environment Increase or decrease overall reflectivity for scenes These are just examples. Even if GI should give automatic realism, artists will always want control of the exact end results. Too much artist control can make things less realistic. Lots of SIGGRAPH 2010 presentations praised energy conserving materials since they guarantee a consistent look and levels for content.

Pipeline Implications Texture baked shapes needs unique UV Possible to automate to some extent Content that is easy to unwrap is preferable Keep details in the normal map layer if possible Vertex baking is common No seams because of insufficient texture resolution Normal maps together with directional light maps can help give details in low resolution lighting Not good with shadows and other lighting discontinuities inside polygons Unwrapping can be done automatically, but good artists can improve the results with manual work. Ideally the UV layout should be continuous where the surface is smooth and discontinuous where the surface isn’t smooth to avoid bilinear filtering over sharp edges in the lighting. Unwrapping tends to work better on low polygon normal mapped geometry as opposed to high detail meshes since folds and wrinkles should preferably end up as seams in the uv layout. If doing this the UV layout will be constructed from lots of small islands which will waste texture memory on padding. Vertex baking is more common than most people thinks and supports directional light maps too.

Questions?