1.09k likes | 1.23k Views
Advanced Computer Graphics. Bas Zalmstra Marries van de Hoef Tim de Jager. Ask questions. Who the .. are these guys?!. Graphics teaching assistants http://marries.nl http://baszalmstra.com. Who the .. are these guys?!. Marries van de Hoef Experimental Game Developer @ marriesvdh
E N D
Advanced Computer Graphics Bas Zalmstra Marries van de Hoef Tim de Jager
Who the .. are these guys?! • Graphics teaching assistants • http://marries.nl • http://baszalmstra.com
Who the .. are these guys?! • Marries van de Hoef • Experimental Game Developer • @marriesvdh • www.marries.nl
Seven Dimensions PLAY NAO -> www.marries.nl
Who the .. are these guys?! • Bas Zalmstra • Lead Developer @ Abbey Games • @baszalmstra • www.baszalmstra.nl
Who the .. are these guys?! • Tim de Jager • Game Developer @ Abbey Games • @tldejager
Reus www.reusgame.com
What are we talking about? • Deferred shading variants • Culling • Variance Shadow mapping • Subsurface scattering • GPU Particle Physics
Dynamic lighting • Dynamic lighting • Calculating lighting real-time • Moving objects • Moving light sources
A lot of variants Forward Shading Deferred Shading Deferred Lighting Light indexed deferred shading Tile based deferred shading Inferred Lighting Forward+
Forward Shading Deferred Shading Deferred Lighting Light indexed deferred shading Tile based deferred shading Inferred Lighting Forward+ Forward Shading
Forward shading • Multiple light sources • Graphics practical 3 assignment E3 • Additive blending of light sources
Forward shading • Lighting is calculated while rendering geometry • Calculated for the entire surface Two methods: • Add multiple light sources in single shader • Variable number of light sources in a shader • Render the object multiple times (additively) • Unnecessary vertex shader calculations
Forward Shading Deferred Shading Deferred Lighting Light indexed deferred shading Tile based deferred shading Inferred Lighting Forward+ Deferred Shading
Deferred shading • Render lighting per light source • Render the bounding volume
Deferred shading • What do we need for (Lambertian) shading? • Object: • Normals • Position • Surface color (albedo) • Light source: • Position • Lighting color • Object data is not available when rendering light volumes
Deferred shading • Store object properties in buffers (Texture2D’s)! • Everything has to be rendered once • Lighting uses data from buffers • Geometry-Buffer (G-buffer): Normals Depth (Position) Albedo
Deferred shading • For each light source • Use data from the G-buffer • Light source properties as shader parameters Normals Depth (Position) Albedo
Forward Shading DeferredShading Deferred Lighting Light indexed deferred shading Tile based deferred shading Inferred Lighting Forward+ Deferred LIGHTING
Deferred lighting • Deferred shading has limited object variability. • Defined by the properties in the G-Buffer. • What if we want a different shader per object?
Deferred lighting • (Also called Light pre-pass rendering) • Only calculate lighting • Specular lighting, diffuse lighting • DON’T combine with diffuse/specular color yet
Deferred lighting • Render all objects again • For each object • Use lighting buffer as lighting information • We can use a different shader for each object!
Deferred lighting • Recap: • Render each object to G-Buffer: • Use G-Buffer to calculate lighting: • Render each object again: • Use lighting buffer for shading
Deferred lighting • We also want different lighting per object • Still not possible…
Forward Shading DeferredShading Deferred Lighting Light indexed deferred shading Tile based deferred shading Inferred Lighting Forward+ Inferred LIGHTING
Inferred lighting • What about transparency • A buffer can store 1 value per pixel • Use stippling for the lighting • Search for surface when fetching the lighting
Inferred lighting • Lighting does not vary much over a surface • Lighting could be calculated at a lower resolution • Also search for the correct surface when sampling from the lighting buffer
Inferred lighting At lower resolution • Render each object to G-Buffer: • Use G-Buffer to calculate lighting: • Render each object again: • Use lighting buffer for shading
Forward Shading DeferredShading Deferred Lighting Light indexed deferred shading Tile based deferred shading Inferred Lighting Forward+ Tile based deferred shading
Tile based deferred shading • Rendering light volumes is slow • A lot of overdraw • Render lighting per tile • List of active light sources per tile • Frustum culling (on GPU?)
Forward Shading DeferredShading Deferred Lighting Light indexed deferred shading Tile based deferred shading Inferred Lighting Forward+ Forward+
Forward+ • We want different lighting per object • Don’t calculate lighting, but store which light sources are active • Store light indices per tile • Similar to tile based deferred rendering
Forward+ • Light indexed deferred rendering • Store light indices for each pixel in a texture • Limited number of light indices • Forward+ • Published in 2012 • Store light indices in DX11 linked list structure
Usage in games • Forward shading: Half-life 2, Portal, etc. • Deferred shading: Killzone 2, Starcraft 2, etc. • Deferred lighting: Most games • Inferred lighting: Red faction / Saints Row • Tile based def. sh.: Battlefield 3, Uncharted, …? • Forward+ : Dirt Showdown (so far)
What is culling? You No culling
What is culling? You No culling
What is culling? Cannot see that! You Frustum culling
What is culling? Cannot see that! You Frustum + Occlusion culling
Frustum culling Occlusion culling Culling
Frustum culling:Traditional approaches • Culling a few thousand objects is slow • Need optimizations • Create spatial hierarchy • Useful for quickly culling a lot of objects • Bounding Volume Hierarchy (BVH) • Battlefield 1 and 2 use a Bounding Sphere Hierarchy
Bounding Sphere Hierarchy A+B+C B A B+C A B C C
Problems • Hierarchical culling doesn’t scale well • Most computers have 4 or more cores • Hard to handle dynamic objects • Streaming in new parts of a level
Solution • Just do it parallel brute force • Scales over all available cores • No overhead of tree • CPU can do a lot more low level optimizations • Statistics (DICE): • 3 times faster • 1/5 of the original code • Seamlessly handles dynamic objects • Easy to optimize further
Frustum culling Occlusion culling Culling
Oclusion culling:Traditional approaches • Generate a static occlusion culling data structure • Used in Quake1-3 • Also used in newer engines like Unity3 • Umbra (used in Unreal Engine 3)