The “Dark” Side of Game Development

Slides:



Advertisements
Similar presentations
Exploration of advanced lighting and shading techniques
Advertisements

An Optimized Soft Shadow Volume Algorithm with Real-Time Performance Ulf Assarsson 1, Michael Dougherty 2, Michael Mounier 2, and Tomas Akenine-Möller.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 1/16 Deferred Lighting Deferred Lighting – 11/18/2014.
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Parallax-Interpolated Shadow Map Occlusion
Normal Map Compression with ATI 3Dc™ Jonathan Zarge ATI Research Inc.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Exploration of bump, parallax, relief and displacement mapping
Graphics Pipeline.
Game Programming 09 OGRE3D Lighting/shadow in Action
Computer Graphics methods
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
3D Graphics Rendering and Terrain Modeling
Week 9 - Wednesday.  What did we talk about last time?  Fresnel reflection  Snell's Law  Microgeometry effects  Implementing BRDFs  Image based.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
Real-Time Rendering Paper Presentation Logarithmic Perspective Shadow Maps Brandon Lloyd Naga Govindaraju Cory Quammen Steve Molnar Dinesh Manocha Slides.
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
(conventional Cartesian reference system)
Perspective Shadow Maps Marc Stamminger and George Drettakis Speaker: Alvin Date: 5/28/2003 SIGGRAPH 2002.
Real-Time High Quality Rendering COMS 6160 [Fall 2004], Lecture 4 Shadow and Environment Mapping
Perspective Shadow Maps Marc Stamminger REVES/INRIA, Sophia-Antipolis, France now at: Bauhaus-Universität, Weimar, Germany George Drettakis REVES/INRIA,
LOGO Shadows On the GPU Presented by Lukai Lan. LOGO Contents  Introductions  Recent Shadow Maps  What we are NOT covering today  Perspective Shadow.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
SET09115 Intro Graphics Programming
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel  dramatic effects  spooky effects Without shadows the.
Computer Graphics Mirror and Shadows
Aaron Schultz. Idea: Objects close to a light shadow those far away. Anything we can see from the light’s POV is lit. Everything hidden is dark. Distance.
Shadow Algorithms Ikrima Elhassan.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Week 2 - Wednesday CS361.
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.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
GAM532 DPS932 – Week 8 Texture Shadow Implementation.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Fast Cascade VSM By Zhang Jian.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Perspective Shadow Maps Marc Stamminger REVES/INRIA, Sophia-Antipolis, France now at: Bauhaus-Universität, Weimar, Germany George Drettakis REVES/INRIA,
Hardware-accelerated Rendering of Antialiased Shadows With Shadow Maps Stefan Brabec and Hans-Peter Seidel Max-Planck-Institut für Informatik Saarbrücken,
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
Sample Based Visibility for Soft Shadows using Alias-free Shadow Maps Erik Sintorn – Ulf Assarsson – uffe.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Global Illumination. Local Illumination  the GPU pipeline is designed for local illumination  only the surface data at the visible point is needed to.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
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.
Applications and Rendering pipeline
- Introduction - Graphics Pipeline
Real-Time Soft Shadows with Adaptive Light Source Sampling
Deferred Lighting.
Robust Shadow Maps for Large Environments
3D Graphics Rendering PPT By Ricardo Veguilla.
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Jim X. Chen George Mason University
Introduction to Computer Graphics with WebGL
Real-time Rendering Shadow Maps
UMBC Graphics for Games
Computer Graphics Module Overview
ATO Project: Year 3 Main Tasks
Frame Buffer Applications
Presentation transcript:

The “Dark” Side of Game Development Shadowing in XNA

Let’s see some ID… Julian Spillane CEO / Technical Director, Frozen North Productions, Inc. We make video games. Currently working on a next-gen XBLA project January 2008 release PC release to follow soon after…

Break it down… XNA? Shadowing in Games Shadowing Algorithms How does it stack up Reception by the pros Shadowing in Games Shadowing Algorithms Maps, volumes, geometry projection… Why I prefer maps Basic Shadow Map Theory & Implementation Variants DPSM, PSM, TSM, LiSPSM, PSSM, VSM… Tips for Optimization, Soft Shadows Further Reading

XNA’s Not Acronymed What IS XNA? Who is using XNA? A managed framework for developing games on both PC and Xbox 360 Graphics device, input, and audio management along with math helpers Who is using XNA? Hobbyists Independent developers … and yes, professionals Torpex Games, Hidden Path Entertainment, GarageGames Inc.

XNA’s Not Acronymed (cont’d) Why XNA? Unmanaged background C, C++, assembly XNA exposed me to a new language XNA allows for RAD Full games can be put together in obscenely short periods of time Allows developers to focus on content, gameplay, balancing over technical issues XNA does things more inuitively than DirectX Render Targets Device Management Preaching to the choir? ;)

XNA’s Not Acronymed (cont’d) Full game built in 2 weeks using XNA with no prior knowledge of the API…

Shadowing in Games Why are shadows important? Add a sense of presence and volume to a scene Important visual cues Make for interesting gameplay mechanics Adds to realism (caveats?) Players expect dynamic lighting Shadows play a major role How many different ways are there to shadow? In a word: lots

Shadowing Algorithms Geometry Based Image Based Projected Shadows Geometry collapse using “Shadow Matrix” Shadow Volumes Regular volumes Z-fail / “Carmack’s Reverse” GPU-generated Both cases ~O(n) in terms of scene complexity Image Based Shadow Map Depth-based shadowing system Many variants: PSM, TSM, LiSPSM, PSSM, CSM, VSM, DPSM, etc. Relatively O(1) in terms of geometric scene complexity Forward Shadow Mapping Proposed technique

Shadowing Algorithms (cont’d) Geometry Based Pros Sharp, crisp shadows Easy to compute If it’s visible on-screen, you already have the data to shadow it Easily extendable to the vertex shader Speed benefits through pipeline-integration Cons Shadow complexity is O(n), n = # edges Means speed α complexity-1 Fine balance between object count and edge resolution Requires image-space modification or ugly jitter for soft-shadows No support for alpha-blended textures without extreme trickery We’re talking leprechaun-level, here…

Shadowing Algorithms (cont’d) Shadow Volumes – Algorithm, Demonstration Images courtesy of Østfold University College, Norway and NVIDIA Corporation

Shadowing Algorithms (cont’d) Image Based Pros Shadow complexity α scene complexity!!! Means cube equally expensive as Marcus Fenix ™ (sorta…) Gives shadowed alpha for free Soft shadows feasible in real-time Self-shadowing is free Cons Inherently aliased / artifact’d Aliasing from texture resolution and light projection settings Artifacts from limitations of texture projection Both are mitigated through technique variations Memory intensive Memory consumption α shadow quality Dependent on texture size No unified approach Different techniques for different situations

Shadowing Algorithms (cont’d) Images courtesy of me. Demonstration of vanilla shadowing using PCF and screen-space blur.

Shadowing Algorithms (cont’d) This presentation will focus on shadow mapping, its theory, implementation and variants On modern hardware, pros far outweigh cons Self-shadowing and alpha blending! Scenes in games are growing in complexity Vertex-bound techniques will cause even more problems as time progresses Independent of model / vertex data architecture Personal preference ;)

What Is Shadow Mapping? Rendering from the light’s POV Using results to generate projective texture Generally filled with single-color depth information Two-Pass Process Generating the shadow map Shadowing the scene Shader Approach Can be done using FF, but deprecated

Creating the Shadow Map Theory Render from light’s point of view Any object that can be seen must be lit Store the depth value of every element Render the scene as normal Take the position of every vertex Transform into light-space coordinates Retrieve the point as it is seen from the point of view of the light (depth map) Depth-compare with light-view map If depth value of surface is further away, it must be behind an occluder and shadowed (z-fail test)

Creating the Shadow Map Can be represented in many formats Best Choice: R32F (single channel float) Only if hardware supports… Can use ARGB, just less precision Unless interesting depth hashing with the channels… Use XNA RenderTarget2D Writeable surface, can convert to texture Easy to use

Creating the Shadow Map Matrices Need light’s view, projection matrices Choice in projection Ortho best for large, directional lights (i.e. sun) LightProj = Matrix.CreateOrthographic(w, h, n, f) w, h are width and height of view volume n, f are near and far planes of the view volume Recommend calculating these instead of arbitrary Perspective for local, spot lights LightProj = Matrix.CreatePerspectiveFOV(f, a, n, f) f: perspective FOV, a: perspective aspect ratio Implies we need light information Position, target, up vector LightView = Matrix.CreateLookAt(position, target, up)

Creating the Shadow Map

Creating the Shadow Map Effect Let’s now consider the effect Needs to push unlit vertices Return depth information Store depth independently POSITION cannot be read directly Very simple shader Don’t make it any more complex than it needs to be

Creating the Shadow Map

Creating the Shadow Map

Creating the Shadow Map Statue seen from the light’s point of view. Blue because of R32F texture. Notice gradation: depth values

Shadowing the Scene Projection Now we have depth values stored Need to render a second pass from camera Project the shadow texture into the scene and depth compare Yet another matrix Texture bias and projection matrix Used to map position from projection space into texture space

Shadowing the Scene Depth Comparison Transform position using previous matrix Compare z-value to value stored in shadow sampler if stored depth < visible depth at that point Must be occluded and therefore shadowed Easy pixel shader comparison Single texture lookup with 1 inline conditional branch (ps_2_0 only)

Shadowing the Scene

Shadowing the Scene

Shadowing the Scene Images courtesy of Frozen North Productions, Inc.

Shadowing the Scene Final Steps Merging with the scene Simply multiply shadow term by diffuse colour / lighting / texture So…improvements? Aliasing artifacts, projection artifacts, hard edges, the list goes on How do we mitigate the problems? Variations on the technique I will cover overviews with links to papers and demos

Shadowing the Scene Images courtesy of Frozen North Productions, Inc.

Shadow Map Variants Dual-Paraboloid Shadow Maps Basic shadow mapping is inherently spot / directional Need creative solution to handle omnidirecitonal (point) lights Paraboloid Mapping “[I]mage obtained by an orthographic camera view a perfectly reflecting paraboloid.” Single map can cover a full hemisphere Implies only 2 rendering passes for omni light vs 6 passes for cube lookup Find a point P in R3 on the paraboloid that reflects a given direction towards +/- Z Depth value calculated by using the distance from surface point to center of paraboloid Extends from a 2D-3D mapping to a 3D-3D mapping “Shadow Mapping for Hemispherical and Omnidirectional Light Sources” Brabec, et al., Computer Graphics Group, Max-Planck Institute, Saarbrucken Germany http://www.mpi-inf.mpg.de/~tannen/papers/cgi_02.pdf http://www.gamedev.net/reference/articles/article2308.asp

Shadow Map Variants Perspective Shadow Maps Aliasing due to depth resolution issues PSMs Generated post-perspective transformation Light is transformed projectively to the unit cube Reduces perspective aliasing since the depth values are considered after perspective proejction Caveats Cases to handle for objects behind the viewer but cast shadows (lit from behind the viewer) Comparatively convoluted implementation “Perspective Shadow Maps”, Stamminger, Marc and Drettakis, George, REVES – INRIA Sophia Antipolis, France http://www-sop.inria.fr/reves/Basilic/2002/SD02/PerspectiveShadowMaps.pdf

Shadow Map Variants Trapezoidal Shadow Maps Similar to PSMs Approximates eye frustum as seen from the light using a trapezoid to warp it onto a shadow map Designed to address perspective-induced aliasing and quality discontinuity (flickers) Biases shadow map so quality increases closer to the camera “Anti-aliasing and Continuity with Trapezoidal Shadow Maps”, Martin, Tobias and Tan, Tiow-Seng, School of Computing, National University of Singapore http://www.comp.nus.edu.sg/~tants/tsm/tsm.pdf

Shadow Map Variants Light-Space Perspective Shadow Mapping LiSPSM Modification to the PSM algorithm A bit of a mouthful Designed to address artifacts inherent in the PSM algorithm Perspective distortion, missed shadow casters, singularities in post-projective space Perspective transform specified in light-space Allow for treating all lights as directional while still maintaining perspective benefits Far more complicated than regular shadow maps Benefits outweigh time cost of implementation General opinion mixed “Light Space Perspective Shadow Maps”, Wimmer et. al, Vienna University of Technology, Austria, 2005 http://www.cg.tuwien.ac.at/research/vr/lispsm/shadows_egsr2004_revised.pdf

Shadow Map Variants Parallel-Split Shadow Maps PSSM Splits the view frustum into parts using plane parallel to the viewing plane Generates smaller shadow maps for split parts Tighter bounds on each map takes better advantage of texture resolution Results in crisper shadows at lower cost Widely implemented Lots of available example code Current shadow map fad Very useful for large, outdoor environments Makes good use of orthographic cameras “Parallel-Split Shadow Maps for Large-Scale Virtual Environments”, Zhang et. al., Chinese University of Hong Kong, 2006 http://appsrv.cse.cuhk.edu.hk/~fzhang/pssm_vrcia/shadow_vrcia.pdf

Shadow Map Variants

Shadow Map Variants Variance Shadow Maps VSM Developed by a fellow UW alum and IGDA Toronto member Andrew Lauritzen, University of Waterloo student Presented at i3D 2006 then GDC 2007 Taking the industry by storm Designed to solve aliasing issues by using calculated variance to determine an upper-bound on the fraction of an occluded, shaded fragment Store mean and mean2 of a range of depths Allows computation of variance Relatively simple to compute on modern GPUs A bit more overhead, but well worth the cost Allows for mipmapping and texture filtering Generally uncomputable for SSM because of single depth value Caveats Light bleeding on filter areas with high variance “Variance Shadow Maps”, Donnelly, William and Lauritzen, Andrew, CGL, University of Waterloo http://www.punkuser.net/vsm/vsm_paper.pdf

Shadow Map Variants

Optimizations Things to consider Texture size Conditional statements Depth comparison in shader Texture filtering Combining of algorithms PSSM + VSM particularly interesting for large outdoor scenes Selecting the right algorithm for the scene Unified solution does not exist

Soft Shadows Large Topic Various Techniques Could spend another two hours on various techniques Various Techniques Percentage Closer Filtering Penumbra Calculations Screen-Space Blur Combinations… Will demo PCF with Screen-Space Blur

Further Reading “Casting Curved Shadows on Curved Surface”, Williams, Lance, CGL, New York Institute of Technology, New York, 1978 The original introduction of shadow mapping (yes it’s that old) "Shadow mapping." Wikipedia, The Free Encyclopedia. 1 Sep 2007, 09:57 UTC. Wikimedia Foundation, Inc. 29 Sep 2007 <http://en.wikipedia.org/w/index.php?title=Shadow_mapping&oldid=154989894>. “Shadow Mapping Tutorial”, Paul’s Projects, http://www.paulsprojects.net/tutorials/smt/smt.html “Hardware Shadow Mapping”, NVIDIA Corporation http://developer.nvidia.com/attach/8456

Questions?

Thank You Contact Information Email: jspillane@frozennorth.net Office: (519) 513-2409 Website: www.frozennorth.net