Rendering Tech of Space Marine

Pope Kim
Pope KimSenior 3D Programmer
Rendering Tech of Space Marine
                Korea Game Conference 2011
                       Nov 6-9, 2011




         Pope Kim                   Daniel Barrero
Senior Graphics Programmer    PhD, Graphics Programmer
What is Space Marine?
●
    3rd Person Action Game
●
    Shipped in September 2011
●
    XBOX 360, PS3 and PC
●
    Based on Warhammer 40,000 Franchise
Video
Goals
●   Tech-driven goals
    ●
        Supports Xbox 360, PS3 and PC
    ●
        Runs at solid 30 frames per second
●   Art-driven goals
    ●
        Fast iteration
    ●
        Highly detailed models
    ●
        Lots of lights, blood, gore and explosion
●
    Design-driven goals
    ●
        Lots of orks
    ●
        Lots of blood (yes, again)
Features: Industry Standard
●
    Deferred Lighting
●
    SSAO
●
    Linear Space Lighting
●
    Full-screen AA (similar to FXAA)
●
    Cascaded Shadow Map
●
    Deferred Shadow
●
    Colour Correction (Colour Grading)
Features: Space Marine Specific
●
    World Occlusion
●
    Screen Space Decal
●
    Character Fill Light
●
    Ambient Saturation
●
    FX system that does everything
●
    Character Customization
Agenda
1. Deferred Lighting
2. Screen Space Decals
3. World Occlusion
Example Scene
Rendering Passes
Pass                      Budget(ms)
Depth-Pre                 0.50
G-Buffer + Linear Depth   5.05
Ambient Occlusion         2.25
Lighting                  8.00
Combiner Pass             5.00
Blend                     0.15
Gamma Conversion          1.30
FX                        2.75
Post Processing           3.70
UI                        0.50
Total                     29.20
Deferred Lighting Overview
●   (Traditional) Forward Rendering
   Object rendering pass: does everything
    ●


● Deferred Shading


    ● Object rendering pass: saves all surface
      parameters
    ● Lighting pass: saves lighting result


    ● Combiner pass: combines lighting result +


      surface material in screen space
Deferred Lighting Overview
●
    Deferred Lighting
    ●
        Our approach
    ●
        Also called Light Pre-Pass [Wolf08]
    ●
        Almost same as deferred shading except:
        –   First pass doesn't saves surface material
        –   Combiner pass is another object pass combining:
             ●
                 Lighting result (full-screen)
             ●
                 Surface material (from object)
    ●
        For more details:
        http://en.wikipedia.org/wiki/Deferred_shading
Deferred Lighting Passes
Pass                      Budget(ms)
Depth-Pre                 0.50
G-Buffer + Linear Depth   5.05
Ambient Occlusion         2.25
Lighting                  8.00
Combiner Pass             5.00
Blend                     0.15
Gamma Conversion          1.30
FX                        2.75
Post Processing           3.70
UI                        0.50
Total                     29.20
Our Deferred Implementation
●   Rendering resolution
    ●   Xbox 360: 1200 x 720
    ●   PS3: 1138 x 640
●   No multiple Render Targets
    ●   Saves ROP bandwidth
    ●   Reduces number of texture look-ups
●   To achieve this:
    ●   G-Buffer: Encode roughness and specular together
    ●   Lighting Pass: spec result is saved as monochrome
Depth-pre Pass
●   To reject occluded objects early in G-Buffer
    Double fill rate if render target is disabled
    ●


  ● Hi-Z to reject before ROP(Raster Operation)


● Front-to-back


●   But, drawing all objects was slow
●   To fit this in 0.5 ms, we only draw
    Maximum 75 objects
    ●


  ● Big enough objects in project space


    ● X360: 0.5


    ● PC and PS3: 2.0


● Other objects will be drawn to Z-buffer in Gbuffer pass
Example Scene
Depth-pre Pass
Geometry Buffer Pass
●
    One A8R8G8B8 RT
    ●
        View space normal in RGB
        viewNormal.rgb * half3(0.5, 0.5, 0.66666) + half3(0.5, 0.5, 0.33333)

    ●
        Specular power/roughness in A
●
    Sort by material
●
    Occlusion query is issued per draw call
    ●
        If depth-pre did a good job, many objects are culled
    ●
        The query result is used in combiner pass
    ●
        On x360, new faster occlusion query API was used
●
    This is last stage where we write to depth
Example Scene
Geometry Buffer
G-Buffer (Alpha, inverted)
Depth Buffer after Gbuffer Pass
Lighting Pass
●   Almost all objects are lit in this pass
    ●   Exception: transparent objects(e.g, hair)
●   Uses the resulting buffer from GBuffer pass
●   Our basic diffuse lighting model is Oren-Nayar
    ●   Rough surface propagates lights across surface=slow
        fall-off
    ●   Usual Lambertian model very smooth surface, not ideal
        for human face or cloth
    ●   Indeed, we use roughness only for characters
Oren-Nayar Lighting Model
●
    We used a lookup texture for optimization for a while
    ( http://content.gpwiki.org/index.php/D3DBook:(Lighting)_Oren-Nayar )
half computeOrenNayarLighting_TextureLookup( half3 N, half3 L, half3 V, half roughness )
{
  half LdotN = dot( L, N );
  half result = saturate(LdotN);
  if ( roughness > 0 )
  {
      // compute the other aliases
      half VdotN = dot( V, N );
      half gamma = dot( V - N * VdotN, L - N * LdotN );
      half rough_sq = roughness * roughness;
      half A = 1.0 - 0.5 * (rough_sq / (rough_sq + 0.33));
      half B = 0.45 * (rough_sq / (rough_sq + 0.09));
      // The two dot-products will be in the range of
      // 0.0 to 1.0 which is perfect for a texture lookup:
      half2 tex_coord = half2( VdotN, LdotN ) * 0.5 + 0.5;
      half C = tex2D(gOrenNayarSampler, tex_coord).x;
      result *= (A + B * max(0.0, gamma) * C);
  }
  return result;
}
Oren-Nayar Lighting Model
    ●   But we made it even faster with an approximation
    ●   Practically, we didn't notice any badness from this
half ComputeOrenNayarLighting_Fakey( half3 N, half3 L, half3 V, half roughness )

{

    // Through brute force iteration I found this approximation. Time to test it out.
    half LdotN = dot( L, N );

    half VdotN = dot( V, N );

    half result = saturate(LdotN);

    half soft_rim = saturate(1-VdotN/2); //soft view dependant rim
    half fakey = pow(1-result*soft_rim,2);//modulate lambertian by rim lighting

    half fakey_magic = 0.62;

    //(1-fakey)*fakey_magic to invert and scale down the lighting

    fakey = fakey_magic - fakey*fakey_magic;
    return lerp( result, fakey, roughness );

}
Roughness & Specular Power?
●   Only characters ended up using roughness
●   Used to store both spec power and roughness separately
    ●   Needed 2 RTs = expensive
●   But aren't they necessarily same?
    ●   Rougher surface = less tight spec = lower spec power
●   So we packed roughness and spec power into one channel
    ●   Bit 7: roughness flag
    ●   Bit 6~0: specular power
    ●   When bit 7 is 1, roughness is inverse curve function of specular
        power
Many Many Lights?
●   In the example scene, we are drawing 31 lights
●   Many lights + shadow sounds nice, but slow. Need
    optimization
●   We draw lights in two passes
    ●   Stencil/hi-stencil masking pixels that should be lit
    ●   Draw lights again with stencil test
●   Light mask
    ●   Fake shadow
    ●   Think it as a filter you attach in front of a concert light
Light Mask
Light Mask
Our Lighting Buffer
●   Used to use two RTs
●   Now we use only one A16R16B16G16F RT
    RGB: diffuse lighting result
    ●


  ● A: specular lighting result


    ● Encoded as luminance


    ● Reconstructed in combiner pass


● Reasons for using 16-bit per channel


    ● Linear space lighting
    ● HDR
Example Scene
Lighting Buffer, Diffuse
Lighting Buffer, Specular
Shadow
●
    Sun shadow
    ●
        Cascade Shadow Map with 4 cascades
    ●
        Blend between 2 neighbouring cascades to
        hide sudden transition
●
    Any lights can have shadows in theory
●
    9-sample manual PCF on X360, 3-sample
    HW PCF on PC and PS3
    ●
        Too expensive, especially with cascade blends
    ●
        Solution: deferred Shadow
Deferred Shadow
●   Generates shadow map for 1 cascade
●   Draws current cascade on deferred buffer in screen-
    space
●   Draws it in two passes
    ●   Pass 0: where no more blending needed. Stencil mark
    ●   Pass 1: where further blending needed with next cascade
●   PCF while drawing onto deferred shadow buffer
●   Result is like a light map in screen-space
Example Scene
Deferred Shadow Buffer–C2, P0
Deferred Shadow Buffer–C2, P0
Deferred Shadow Buffer–C2, P0
Deferred Shadow Buffer–C2, P1
Deferred Shadow Buffer–C1, P0
Deferred Shadow Buffer–C1, P0
Better Example
Better Example
Better Example
Better Example
Better Example
Better Example
Better Example
Better Example
Combiner Pass
●
    Another geometry pass that combines
    ●
        Lighting result
    ●
        Two ambient colours based on Ambient
        Occlusion factor
    ●
        Ambient saturation
    ●
        Character fill light
●
    Everything is written in linear space in
    16-bit per channel
Combiner Pass
Character Fill Light
●   Used rim light once
●   What we wanted: making characters pop out in the shadow
●   So borrowed the concept of fill lights from movie industry
●   First implementation: 3 directional lights on characters
    ●   Based on camera angle (top, left and right)
    ●   Turns out to be too expensive
●   Shipped (optimized) version: 2 directional lights
    ●   One for diffuse only
    ●   The other for spec only
    ●   Blended in based on diffuse lighting
Example Scene
Example Scene(no Fill Light)
Example Scene (Difference)
Ambient Colour / Saturation
●   We have two ambient colours
●   Based on occlusion depth, we blend between these two
    colours (think them as deep and shallow shadow colours)
●   However, sometimes we want diffuse texture to stand out
    ●   Especially on Space Marines
    ●   We call it ambient saturation
●   We have two global ambient saturation each for:
    ●   Environments
    ●   Character
        unlitColour *= lerp(lum(diffuse),diffuse,saturation);
Overcoming Cons of Deferred Lighting
●
    Transparent Objects
    ●
        We used hard-alpha (alpha testing) as much
        as possible
    ●
        Some special treatment for hair
    ●
        If it's a co-planar object, we use a SSD
●
    Anti-aliasing
    ●
        Hard with DX9 level GPUs
    ●
        made something similar to FXAA
Ambient Occlusion
Pass                      Budget(ms)
Depth-Pre                 0.50
G-Buffer + Linear Depth   5.05
Ambient Occlusion         2.25
Lighting                  8.00
Combiner Pass             5.00
Blend                     0.15
Gamma Conversion          1.30
FX                        2.75
Post Processing           3.70
UI                        0.50
Total                     29.20
Ambient Occlusion
●
    Will explain later in detail
Gamma Conversion
Pass                      Budget(ms)
Depth-Pre                 0.50
G-Buffer + Linear Depth   5.05
Ambient Occlusion         2.25
Lighting                  8.00
Combiner Pass             5.00
Blend                     0.15
Gamma Conversion          1.30
FX                        2.75
Post Processing           3.70
UI                        0.50
Total                     29.20
Gamma Conversion
●   We do lighting and combiner in linear space (HDR)
●   In this step, we separate HDR image into LDR and
    bloom intensity
●   LDR image is stored in RGB (in gamma space)
●   Bloom intensity is stored in Alpha channel
    ●   Based on pixel luminance and threshold set by artists
    ●   Later used in bloom pass
●   For more about linear lighting, please take a look at
    this presentation by John Hable:
    ●   http://filmicgames.com/Downloads/GDC_2010/Uncharted2-
        Hdr-Lighting.pptx
Gamma Conversion (LDR)
Gamma Conversion(HDR Intensity)
FX(Particle) Pass
Pass                      Budget(ms)
Depth-Pre                 0.50
G-Buffer + Linear Depth   5.05
Ambient Occlusion         2.25
Lighting                  8.00
Combiner Pass             5.00
Blend                     0.15
Gamma Conversion          1.30
FX                        2.75
Post Processing           3.70
UI                        0.50
Total                     29.20
FX(Particle) Pass
●   Relic is known for the crazy amount of particles
●   Additive, blend, distortion, soft particles, lit particles...
●   Mesh or Decal spawn
●   Particle updates and submission, heavily multi-threaded
●   God rays
●   Dynamic FX lights
    ●   Can have shadow -> expensive
    ●   A lot of time, we use light mask
●   Optimization:
    ●   Half-res particles when FPS is slower
    ●   Batch through pre-multiplied alpha and texture page
●   Too big of a system to fit in this presentation, but is a collection of standard
    industry practices and techniques
Without FX
With FX
Post Processing
Pass                      Budget(ms)
Depth-Pre                 0.50
G-Buffer + Linear Depth   5.05
Ambient Occlusion         2.25
Lighting                  8.00
Combiner Pass             5.00
Blend                     0.15
Gamma Conversion          1.30
FX                        2.75
Post Processing           3.70
UI                        0.50
Total                     29.20
(Uber) Post-Processing
●
    Uber pass processing almost all the post-
    processing at once
●
    Mostly to save Resolve cost on Xbox 360
    ●
        Generate Distortion Vector Texture
    ●
        Generate Depth-of-Field + Camera Motion Blur
    ●
        Generate HDR Bloom Texture
        –   Colour Correction
        –   AA
        –   Vignette
Generate Distortion Vector Texture
●
    Nothing special
●
    All from FX
●
    2D UV offset is stored in screen-space
●
    Later this offset is used when combining all post-
    processing effect with the frame buffer
Generate DOF + MB
●
    Both Depth-of-Field and Camera Motion Blur are blurry
●
    So let's process both at the same time
    ●
        Pass 0: generates a blur offset based on distance to
        camera and camera motion blur
    ●
        Pass 1: separable masked gaussian blur
    ●
        Pass 2: separable masked gaussian blur + store mask
        into Alpha channel
●
    All done in half-res
●
    Later mask value (in Alpha channel) is used to blend
    between this texture and the full-res frame buffer
DOF + MB (Before)
DOF + MB (Offset)
DOF + MB (Pass 1)
DOF + MB (Pass 2)
Generate HDR Bloom Texture
●
    Nothing special
●
    Close to Halo 3 way
●
    We don't do tone mapping
●
    Done in 3 passes with half-res frame
    buffer
    ●
        ½ downsample and blur
    ●
        ½ downsample again and blur
    ●
        Merge back to ¼ res buffer and blur
Colour Correction
●   Originally implemented for a previous unreleased project
●   We use a 32x32x32 3D texture
    ●   Each dimension represent a channel's input value
    ●   Value stored in the texture replaces the input value
●   We created a Photoshop plug-in to help authoring the colour
    grade texture
    ●   Take a screenshot from game
    ●   Load the image in to Photoshop
    ●   Use whatever layer modifiers to male it look good
    ●   Press the Magic button
    ●   Done!
Anti-Aliasing
●
    Simplified version of FXAA using just 4 samples to
    find the slope of the luminance edge
●
    Use the slope to do a 3 pixel blending between
    blurred and unblurred versions of the textures
●
    Total 7 texture look-ups
Antialiasing (No AA)
Antialiasing
Before Post-Processing
After Post-Processing
UI
Pass                      Budget(ms)
Depth-Pre                 0.50
G-Buffer + Linear Depth   5.05
Ambient Occlusion         2.25
Lighting                  8.00
Combiner Pass             5.00
Blend                     0.15
Gamma Conversion          1.30
FX                        2.75
Post Processing           3.70
UI                        0.50
Total                     29.20
UI
●
    Nothing much to talk about
●
    We use Scaleform
First Half is Over!!



           Questions so far?
Agenda
1. Deferred Lighting
2. Screen Space Decals
3. World Occlusion
Traditional Decals
●   Example: Bullet Hole
    ●   Get the underlying collision geometry at collision point
    ●   Walk through the geometry to find out the smallest patch
        possible to represent the bullet hole
    ●   Make a mesh patch with the vertices found in step 2
    ●   Draw the underlying geometry
    ●   Draw the patch with the bullet hole textures
●   Problems
    ●   Decal stretching
    ●   Collision detection is expensive
    ●   Waste of vertex space: a plane cannot be simply 4 verts
        anymore
Screen Space Decals (SSDs)
●
    We already have all surface information in screen-
    space
    ●
        Normals
    ●
        Depth
    ●
        Position ( driven from depth info )
●
    So why don't we use these info instead of making a
    mesh patch?
●
    Benefits:
    ●
        Our collision meshes are super simple
    ●
        Our Havok broadphase is super fast
SSD Inspiration
SSD Inspiration
Screen Space Decals
●   Same Example: Bullet Hole
    1. Draw underlying visual geometries onto scene
    2. Rasterize a SSD box at the collision point
    3. Read the scene depth for each pixel
    4. Calculate 3D position from the depth
    5. If this position is outside of the SSD box, reject
    6. Otherwise, draw the pixel with the bullet hole texture
Screen Space Decals
● Not just for FX
● It's literally used everywhere:


    Blood splat on the wall or ground
    ●


  ● Stone wall decoration


  ● Burnt mark on concrete slate


  ● Ork painting


  ● Rubble piles on the ground


  ● Bullet holes


  ● Explosion damage


  ● ......and list goes on


● Yup, environment artists love it!
Scene with SSD
Scene without SSD
Screen Space Decals
●   SSD drawing is split into two passes
    in G-Buffer: update scene normals
    ●


  ● in Combiner: combine lighting result and surface


    materials
● Gives artists a lot of freedom


    Normal-only decals (e.g, stone wall decoration)
    ●


  ● Colour-only decals (e.g, blood splat)


  ● Normal + colour decals (e.g, thick ork painting)


● All the lighting & ambient occlusion are FREE
Normal Only SSD
Normal-only SSD
Colour-only SSD
Colour-only SSD
Normal + Colour SSD
Normal + Colour SSD
SSD - Problems
●
    Stretching
●
    Moving objects
●
    Performance
SSD - Stretching
SSD - Stretching
●   Problem
    Caused by projection boxes not fully submerged
    ●


    into underlying geometry
  ● Round objects have similar problem


● Solution


    ● Using 3D textures was an option, but expensive
    ● Instead, we reject pixels with normal threshold


       ● Get normal from underlying surface


       ● Dot-product this with SSD box's orientation


       ● If it's over an artist-set threshold, reject
SSD – Moving Objects
●   Problem
   If an object is moving through a SSD
    ●


   projection volume, you will see SSDs sliding
   across the object's surface
● Solution


    ● Stencil masking moving objects
    ● All skinned or dynamic objects don't receive


      decals by default
    ● Artists can override it (some skinned objects


      are not moving. e.g, props in healthy state)
SSD – Moving Objects
SSD – Moving Objects
SSD - Performance
●   Problem
    ●
        Box projection in screen-space
    ●
        Can only reject in pixel shader
    ●
        If a SSD box is covering full-screen, it's same as a full-
        screen draw pass
●
    Solution
    ●
        Make decals thin, but not too thin
    ●
        Utilize Hi-Z as much as possible for early rejection
    ●
        Doesn't solve FX decals' problem, but that's fine
Thick SSD = BAD
Thin SSD = GOOD
Agenda
1. Deferred Lighting
2. Screen Space Decals
3. World Occlusion
Ambient Occlusion
●
    Simulates occluded and bounced lights
●
    We use two techniques
    ●
        World Occlusion
        –   Our own approach
        –   Based on ambient occlusion technique used in COH
        –   Vertical occlusion in world space
●
    SSAO
    ●
        Same as other games
    ●
        Depth-only comparison in screen space
World Occlusion
World Occlusion Only
World Occlusion (Old Version)
●   Uses vertical distance between objects as
    attenuation factor
●   Proxy simplified objects are rendered on a
    depth only target
●   This normalized value is then blurred
●   This blurred value is used to blend between
    two ambient light values
    ● (^_^) Works great for outdoor scenes
    ● (T_T) For interior scenes, not so much
World Occlusion (New Version)
●
    Solves the problem of interior scenes
●
    No more, the highest distance to the
    ground
●
    Depth peeling to allow up to 4 different
    depth layers
●
    Rendered using a top-down view camera
World Occlusion
●   Then world occlusion texture is blurred
    ● At different amounts for each level
    ● So that vertical walls can cast/darken


      ambient light at the crevices with the
      ground
    ●
        This fakes horizontal bleeding of world
        occlusion
World Occlusion (Top Layer)
World Occlusion
World Occlusion
World Occlusion (Bottom Layer)
Applying World Occlusion
For each pixel on the screen:
1.Compute the world position of the pixel
2.Find out in what depth layer of world
 occlusion this pixel is
3.Compute the distance to the corresponding
 value stored in the world occlusion texture
4.Use normalized result to blend between the
 low and high ambient colour values (same
 time as SSAO)
World Occlusion
World Occlusion (Optimization)
●   Problems
    ●
        Drawing all objects 4 times is slow
    ●
        Applying it in full-screen is slow
●   Solutions
    ●
        Don't generate world occlusion map every frame
    ●
        Artists tag certain objects as World Occlusion
        contributors
    ●
        Layer heights are controlled by artists per region
    ●
        Use a half-res render texture when applying
SSAO
●   A lot of trials and errors
    ●
        Toy Story 3(game) way: way too noisy
    ●
        Improved version of Crytek way: noisy co-planar
        surface
    ●
        Simplified volumetric SSAO: too many samples
●
    Our final approach was rather simple
    ●
        Depth-only comparison
    ●
        Circular neighbour samples: 16 for X360, 9 for PS3
    ●
        No filtering of any kind
SSAO
References
●   [Timothy11] FXAA:
    http://timothylottes.blogspot.com/2011/03/nvidia-fxaa.html
●   [Aras09] Deferred Cascade Shadow Maps
    http://aras-p.info/blog/2009/11/04/deferred-cascaded-shadow-maps/
●   [Wolf08] Light Pre-Pass renderer:
    http://diaryofagraphicsprogrammer.blogspot.com/2008/03/light-pre-pass-
    renderer.html
●   [Val07] Deferred Rendering in Killzone 2:
    http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
●   [Jeremy05] Using Lookup Tables to Accerlate Color Transformations:
    http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html
Acknowledgements
●
    Space Marine rendering programmers:
    ●
        Ian Thomson
    ●
        Karl Schmidt
    ●
        Rod Reddekopp
    ●
        Angelo Pesce
●
    Space Marine artists for producing
    amazing content and pushing us to do
    more work!
Got Questions?
●
    Pope Kim
    ●
        blindrenderer@gmail.com
    ●
        Twitter
        –   Korean: BlindRendererKR
        –   English: BlindRenderer


●
    Daniel Barerro
    ●
        daniel.barrero@gmail.com
1 of 129

Recommended

The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014) by
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)Philip Hammer
7.3K views53 slides
Stochastic Screen-Space Reflections by
Stochastic Screen-Space ReflectionsStochastic Screen-Space Reflections
Stochastic Screen-Space ReflectionsElectronic Arts / DICE
156.8K views91 slides
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run by
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunFive Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunElectronic Arts / DICE
32.1K views96 slides
Physically Based and Unified Volumetric Rendering in Frostbite by
Physically Based and Unified Volumetric Rendering in FrostbitePhysically Based and Unified Volumetric Rendering in Frostbite
Physically Based and Unified Volumetric Rendering in FrostbiteElectronic Arts / DICE
160.6K views56 slides
Volumetric Lighting for Many Lights in Lords of the Fallen by
Volumetric Lighting for Many Lights in Lords of the FallenVolumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenBenjamin Glatzel
28.1K views78 slides
Optimizing the Graphics Pipeline with Compute, GDC 2016 by
Optimizing the Graphics Pipeline with Compute, GDC 2016Optimizing the Graphics Pipeline with Compute, GDC 2016
Optimizing the Graphics Pipeline with Compute, GDC 2016Graham Wihlidal
135.4K views99 slides

More Related Content

What's hot

Taking Killzone Shadow Fall Image Quality Into The Next Generation by
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationGuerrilla
14.9K views112 slides
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite by
Physically Based Sky, Atmosphere and Cloud Rendering in FrostbitePhysically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Physically Based Sky, Atmosphere and Cloud Rendering in FrostbiteElectronic Arts / DICE
29.8K views64 slides
Stable SSAO in Battlefield 3 with Selective Temporal Filtering by
Stable SSAO in Battlefield 3 with Selective Temporal FilteringStable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal FilteringElectronic Arts / DICE
185.5K views58 slides
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing... by
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Johan Andersson
19.1K views74 slides
Light prepass by
Light prepassLight prepass
Light prepasschangehee lee
10.2K views42 slides
Screen Space Reflections in The Surge by
Screen Space Reflections in The SurgeScreen Space Reflections in The Surge
Screen Space Reflections in The SurgeMichele Giacalone
8.8K views31 slides

What's hot(20)

Taking Killzone Shadow Fall Image Quality Into The Next Generation by Guerrilla
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Guerrilla14.9K views
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite by Electronic Arts / DICE
Physically Based Sky, Atmosphere and Cloud Rendering in FrostbitePhysically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Stable SSAO in Battlefield 3 with Selective Temporal Filtering by Electronic Arts / DICE
Stable SSAO in Battlefield 3 with Selective Temporal FilteringStable SSAO in Battlefield 3 with Selective Temporal Filtering
Stable SSAO in Battlefield 3 with Selective Temporal Filtering
Electronic Arts / DICE185.5K views
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing... by Johan Andersson
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
Johan Andersson19.1K views
Screen Space Reflections in The Surge by Michele Giacalone
Screen Space Reflections in The SurgeScreen Space Reflections in The Surge
Screen Space Reflections in The Surge
Michele Giacalone8.8K views
FrameGraph: Extensible Rendering Architecture in Frostbite by Electronic Arts / DICE
FrameGraph: Extensible Rendering Architecture in FrostbiteFrameGraph: Extensible Rendering Architecture in Frostbite
FrameGraph: Extensible Rendering Architecture in Frostbite
The Rendering Technology of Killzone 2 by Guerrilla
The Rendering Technology of Killzone 2The Rendering Technology of Killzone 2
The Rendering Technology of Killzone 2
Guerrilla11.1K views
Crysis Next-Gen Effects (GDC 2008) by Tiago Sousa
Crysis Next-Gen Effects (GDC 2008)Crysis Next-Gen Effects (GDC 2008)
Crysis Next-Gen Effects (GDC 2008)
Tiago Sousa10.5K views
Past, Present and Future Challenges of Global Illumination in Games by Colin Barré-Brisebois
Past, Present and Future Challenges of Global Illumination in GamesPast, Present and Future Challenges of Global Illumination in Games
Past, Present and Future Challenges of Global Illumination in Games
Siggraph2016 - The Devil is in the Details: idTech 666 by Tiago Sousa
Siggraph2016 - The Devil is in the Details: idTech 666Siggraph2016 - The Devil is in the Details: idTech 666
Siggraph2016 - The Devil is in the Details: idTech 666
Tiago Sousa7.1K views
Graphics Gems from CryENGINE 3 (Siggraph 2013) by Tiago Sousa
Graphics Gems from CryENGINE 3 (Siggraph 2013)Graphics Gems from CryENGINE 3 (Siggraph 2013)
Graphics Gems from CryENGINE 3 (Siggraph 2013)
Tiago Sousa11K views
Star Ocean 4 - Flexible Shader Managment and Post-processing by umsl snfrzb
Star Ocean 4 - Flexible Shader Managment and Post-processingStar Ocean 4 - Flexible Shader Managment and Post-processing
Star Ocean 4 - Flexible Shader Managment and Post-processing
umsl snfrzb7.2K views
Lighting Shading by John Hable by Naughty Dog
Lighting Shading by John HableLighting Shading by John Hable
Lighting Shading by John Hable
Naughty Dog16.9K views

Viewers also liked

Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating... by
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...Daniel Barrero
16.7K views49 slides
The Producer by
The ProducerThe Producer
The Producer포프 김
13.3K views17 slides
아티스트에게 사랑받는 3DS Max 우버쉐이더 by
아티스트에게 사랑받는 3DS Max 우버쉐이더아티스트에게 사랑받는 3DS Max 우버쉐이더
아티스트에게 사랑받는 3DS Max 우버쉐이더포프 김
20.5K views88 slides
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린) by
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)포프 김
31.7K views112 slides
[2012 대학특강] 아티스트 + 프로그래머 by
[2012 대학특강] 아티스트 + 프로그래머[2012 대학특강] 아티스트 + 프로그래머
[2012 대학특강] 아티스트 + 프로그래머포프 김
15.5K views114 slides
[Kgc2013] 모바일 엔진 개발기 by
[Kgc2013] 모바일 엔진 개발기[Kgc2013] 모바일 엔진 개발기
[Kgc2013] 모바일 엔진 개발기changehee lee
17.6K views52 slides

Viewers also liked(8)

Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating... by Daniel Barrero
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...
Company of Heroes 2 (COH2) Rendering Technology: The cold facts of recreating...
Daniel Barrero16.7K views
The Producer by 포프 김
The ProducerThe Producer
The Producer
포프 김13.3K views
아티스트에게 사랑받는 3DS Max 우버쉐이더 by 포프 김
아티스트에게 사랑받는 3DS Max 우버쉐이더아티스트에게 사랑받는 3DS Max 우버쉐이더
아티스트에게 사랑받는 3DS Max 우버쉐이더
포프 김20.5K views
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린) by 포프 김
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
스크린 스페이스 데칼에 대해 자세히 알아보자(워햄머 40,000: 스페이스 마린)
포프 김31.7K views
[2012 대학특강] 아티스트 + 프로그래머 by 포프 김
[2012 대학특강] 아티스트 + 프로그래머[2012 대학특강] 아티스트 + 프로그래머
[2012 대학특강] 아티스트 + 프로그래머
포프 김15.5K views
[Kgc2013] 모바일 엔진 개발기 by changehee lee
[Kgc2013] 모바일 엔진 개발기[Kgc2013] 모바일 엔진 개발기
[Kgc2013] 모바일 엔진 개발기
changehee lee17.6K views
Z Buffer Optimizations by pjcozzi
Z Buffer OptimizationsZ Buffer Optimizations
Z Buffer Optimizations
pjcozzi18.2K views
[Ndc11 박민근] deferred shading by MinGeun Park
[Ndc11 박민근] deferred shading[Ndc11 박민근] deferred shading
[Ndc11 박민근] deferred shading
MinGeun Park15.8K views

Similar to Rendering Tech of Space Marine

A Bit More Deferred Cry Engine3 by
A Bit More Deferred   Cry Engine3A Bit More Deferred   Cry Engine3
A Bit More Deferred Cry Engine3guest11b095
12K views27 slides
Unity: Next Level Rendering Quality by
Unity: Next Level Rendering QualityUnity: Next Level Rendering Quality
Unity: Next Level Rendering QualityUnity Technologies
814 views68 slides
The rendering technology of 'lords of the fallen' philip hammer by
The rendering technology of 'lords of the fallen'   philip hammerThe rendering technology of 'lords of the fallen'   philip hammer
The rendering technology of 'lords of the fallen' philip hammerMary Chan
1.1K views53 slides
new_age_graphics_android_x86 by
new_age_graphics_android_x86new_age_graphics_android_x86
new_age_graphics_android_x86Droidcon Berlin
1.3K views47 slides
Killzone Shadow Fall Demo Postmortem by
Killzone Shadow Fall Demo PostmortemKillzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo PostmortemGuerrilla
42.8K views103 slides
Deferred shading by
Deferred shadingDeferred shading
Deferred shadingFrank Chao
11.9K views98 slides

Similar to Rendering Tech of Space Marine(20)

A Bit More Deferred Cry Engine3 by guest11b095
A Bit More Deferred   Cry Engine3A Bit More Deferred   Cry Engine3
A Bit More Deferred Cry Engine3
guest11b09512K views
The rendering technology of 'lords of the fallen' philip hammer by Mary Chan
The rendering technology of 'lords of the fallen'   philip hammerThe rendering technology of 'lords of the fallen'   philip hammer
The rendering technology of 'lords of the fallen' philip hammer
Mary Chan1.1K views
Killzone Shadow Fall Demo Postmortem by Guerrilla
Killzone Shadow Fall Demo PostmortemKillzone Shadow Fall Demo Postmortem
Killzone Shadow Fall Demo Postmortem
Guerrilla42.8K views
Deferred shading by Frank Chao
Deferred shadingDeferred shading
Deferred shading
Frank Chao11.9K views
Secrets of CryENGINE 3 Graphics Technology by Tiago Sousa
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics Technology
Tiago Sousa32.3K views
Smedberg niklas bringing_aaa_graphics by changehee lee
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
changehee lee966 views
GDC 2012: Advanced Procedural Rendering in DX11 by smashflt
GDC 2012: Advanced Procedural Rendering in DX11GDC 2012: Advanced Procedural Rendering in DX11
GDC 2012: Advanced Procedural Rendering in DX11
smashflt74.4K views
Paris Master Class 2011 - 05 Post-Processing Pipeline by Wolfgang Engel
Paris Master Class 2011 - 05 Post-Processing PipelineParis Master Class 2011 - 05 Post-Processing Pipeline
Paris Master Class 2011 - 05 Post-Processing Pipeline
Wolfgang Engel2.5K views
Paris Master Class 2011 - 01 Deferred Lighting, MSAA by Wolfgang Engel
Paris Master Class 2011 - 01 Deferred Lighting, MSAAParis Master Class 2011 - 01 Deferred Lighting, MSAA
Paris Master Class 2011 - 01 Deferred Lighting, MSAA
Wolfgang Engel1.4K views
Advanced Lighting for Interactive Applications by stefan_b
Advanced Lighting for Interactive ApplicationsAdvanced Lighting for Interactive Applications
Advanced Lighting for Interactive Applications
stefan_b841 views
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons... by Unity Technologies
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unity Technologies2.4K views
Develop2012 deferred sanchez_stachowiak by Matt Filer
Develop2012 deferred sanchez_stachowiakDevelop2012 deferred sanchez_stachowiak
Develop2012 deferred sanchez_stachowiak
Matt Filer623 views
Dissecting the Rendering of The Surge by Philip Hammer
Dissecting the Rendering of The SurgeDissecting the Rendering of The Surge
Dissecting the Rendering of The Surge
Philip Hammer3.4K views
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3 by Electronic Arts / DICE
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3
SPU-Based Deferred Shading in BATTLEFIELD 3 for Playstation 3

Recently uploaded

handbook for web 3 adoption.pdf by
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdfLiveplex
22 views16 slides
Mini-Track: Challenges to Network Automation Adoption by
Mini-Track: Challenges to Network Automation AdoptionMini-Track: Challenges to Network Automation Adoption
Mini-Track: Challenges to Network Automation AdoptionNetwork Automation Forum
12 views27 slides
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdfDr. Jimmy Schwarzkopf
19 views29 slides
The Research Portal of Catalonia: Growing more (information) & more (services) by
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)CSUC - Consorci de Serveis Universitaris de Catalunya
80 views25 slides
Transcript: The Details of Description Techniques tips and tangents on altern... by
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...BookNet Canada
136 views15 slides
PharoJS - Zürich Smalltalk Group Meetup November 2023 by
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023Noury Bouraqadi
127 views17 slides

Recently uploaded(20)

handbook for web 3 adoption.pdf by Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex22 views
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by Dr. Jimmy Schwarzkopf
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada136 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi127 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
Serverless computing with Google Cloud (2023-24) by wesley chun
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)
wesley chun11 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada127 views
Piloting & Scaling Successfully With Microsoft Viva by Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software263 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri16 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma39 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...

Rendering Tech of Space Marine

  • 1. Rendering Tech of Space Marine Korea Game Conference 2011 Nov 6-9, 2011 Pope Kim Daniel Barrero Senior Graphics Programmer PhD, Graphics Programmer
  • 2. What is Space Marine? ● 3rd Person Action Game ● Shipped in September 2011 ● XBOX 360, PS3 and PC ● Based on Warhammer 40,000 Franchise
  • 4. Goals ● Tech-driven goals ● Supports Xbox 360, PS3 and PC ● Runs at solid 30 frames per second ● Art-driven goals ● Fast iteration ● Highly detailed models ● Lots of lights, blood, gore and explosion ● Design-driven goals ● Lots of orks ● Lots of blood (yes, again)
  • 5. Features: Industry Standard ● Deferred Lighting ● SSAO ● Linear Space Lighting ● Full-screen AA (similar to FXAA) ● Cascaded Shadow Map ● Deferred Shadow ● Colour Correction (Colour Grading)
  • 6. Features: Space Marine Specific ● World Occlusion ● Screen Space Decal ● Character Fill Light ● Ambient Saturation ● FX system that does everything ● Character Customization
  • 7. Agenda 1. Deferred Lighting 2. Screen Space Decals 3. World Occlusion
  • 9. Rendering Passes Pass Budget(ms) Depth-Pre 0.50 G-Buffer + Linear Depth 5.05 Ambient Occlusion 2.25 Lighting 8.00 Combiner Pass 5.00 Blend 0.15 Gamma Conversion 1.30 FX 2.75 Post Processing 3.70 UI 0.50 Total 29.20
  • 10. Deferred Lighting Overview ● (Traditional) Forward Rendering Object rendering pass: does everything ● ● Deferred Shading ● Object rendering pass: saves all surface parameters ● Lighting pass: saves lighting result ● Combiner pass: combines lighting result + surface material in screen space
  • 11. Deferred Lighting Overview ● Deferred Lighting ● Our approach ● Also called Light Pre-Pass [Wolf08] ● Almost same as deferred shading except: – First pass doesn't saves surface material – Combiner pass is another object pass combining: ● Lighting result (full-screen) ● Surface material (from object) ● For more details: http://en.wikipedia.org/wiki/Deferred_shading
  • 12. Deferred Lighting Passes Pass Budget(ms) Depth-Pre 0.50 G-Buffer + Linear Depth 5.05 Ambient Occlusion 2.25 Lighting 8.00 Combiner Pass 5.00 Blend 0.15 Gamma Conversion 1.30 FX 2.75 Post Processing 3.70 UI 0.50 Total 29.20
  • 13. Our Deferred Implementation ● Rendering resolution ● Xbox 360: 1200 x 720 ● PS3: 1138 x 640 ● No multiple Render Targets ● Saves ROP bandwidth ● Reduces number of texture look-ups ● To achieve this: ● G-Buffer: Encode roughness and specular together ● Lighting Pass: spec result is saved as monochrome
  • 14. Depth-pre Pass ● To reject occluded objects early in G-Buffer Double fill rate if render target is disabled ● ● Hi-Z to reject before ROP(Raster Operation) ● Front-to-back ● But, drawing all objects was slow ● To fit this in 0.5 ms, we only draw Maximum 75 objects ● ● Big enough objects in project space ● X360: 0.5 ● PC and PS3: 2.0 ● Other objects will be drawn to Z-buffer in Gbuffer pass
  • 17. Geometry Buffer Pass ● One A8R8G8B8 RT ● View space normal in RGB viewNormal.rgb * half3(0.5, 0.5, 0.66666) + half3(0.5, 0.5, 0.33333) ● Specular power/roughness in A ● Sort by material ● Occlusion query is issued per draw call ● If depth-pre did a good job, many objects are culled ● The query result is used in combiner pass ● On x360, new faster occlusion query API was used ● This is last stage where we write to depth
  • 21. Depth Buffer after Gbuffer Pass
  • 22. Lighting Pass ● Almost all objects are lit in this pass ● Exception: transparent objects(e.g, hair) ● Uses the resulting buffer from GBuffer pass ● Our basic diffuse lighting model is Oren-Nayar ● Rough surface propagates lights across surface=slow fall-off ● Usual Lambertian model very smooth surface, not ideal for human face or cloth ● Indeed, we use roughness only for characters
  • 23. Oren-Nayar Lighting Model ● We used a lookup texture for optimization for a while ( http://content.gpwiki.org/index.php/D3DBook:(Lighting)_Oren-Nayar ) half computeOrenNayarLighting_TextureLookup( half3 N, half3 L, half3 V, half roughness ) { half LdotN = dot( L, N ); half result = saturate(LdotN); if ( roughness > 0 ) { // compute the other aliases half VdotN = dot( V, N ); half gamma = dot( V - N * VdotN, L - N * LdotN ); half rough_sq = roughness * roughness; half A = 1.0 - 0.5 * (rough_sq / (rough_sq + 0.33)); half B = 0.45 * (rough_sq / (rough_sq + 0.09)); // The two dot-products will be in the range of // 0.0 to 1.0 which is perfect for a texture lookup: half2 tex_coord = half2( VdotN, LdotN ) * 0.5 + 0.5; half C = tex2D(gOrenNayarSampler, tex_coord).x; result *= (A + B * max(0.0, gamma) * C); } return result; }
  • 24. Oren-Nayar Lighting Model ● But we made it even faster with an approximation ● Practically, we didn't notice any badness from this half ComputeOrenNayarLighting_Fakey( half3 N, half3 L, half3 V, half roughness ) { // Through brute force iteration I found this approximation. Time to test it out. half LdotN = dot( L, N ); half VdotN = dot( V, N ); half result = saturate(LdotN); half soft_rim = saturate(1-VdotN/2); //soft view dependant rim half fakey = pow(1-result*soft_rim,2);//modulate lambertian by rim lighting half fakey_magic = 0.62; //(1-fakey)*fakey_magic to invert and scale down the lighting fakey = fakey_magic - fakey*fakey_magic; return lerp( result, fakey, roughness ); }
  • 25. Roughness & Specular Power? ● Only characters ended up using roughness ● Used to store both spec power and roughness separately ● Needed 2 RTs = expensive ● But aren't they necessarily same? ● Rougher surface = less tight spec = lower spec power ● So we packed roughness and spec power into one channel ● Bit 7: roughness flag ● Bit 6~0: specular power ● When bit 7 is 1, roughness is inverse curve function of specular power
  • 26. Many Many Lights? ● In the example scene, we are drawing 31 lights ● Many lights + shadow sounds nice, but slow. Need optimization ● We draw lights in two passes ● Stencil/hi-stencil masking pixels that should be lit ● Draw lights again with stencil test ● Light mask ● Fake shadow ● Think it as a filter you attach in front of a concert light
  • 29. Our Lighting Buffer ● Used to use two RTs ● Now we use only one A16R16B16G16F RT RGB: diffuse lighting result ● ● A: specular lighting result ● Encoded as luminance ● Reconstructed in combiner pass ● Reasons for using 16-bit per channel ● Linear space lighting ● HDR
  • 33. Shadow ● Sun shadow ● Cascade Shadow Map with 4 cascades ● Blend between 2 neighbouring cascades to hide sudden transition ● Any lights can have shadows in theory ● 9-sample manual PCF on X360, 3-sample HW PCF on PC and PS3 ● Too expensive, especially with cascade blends ● Solution: deferred Shadow
  • 34. Deferred Shadow ● Generates shadow map for 1 cascade ● Draws current cascade on deferred buffer in screen- space ● Draws it in two passes ● Pass 0: where no more blending needed. Stencil mark ● Pass 1: where further blending needed with next cascade ● PCF while drawing onto deferred shadow buffer ● Result is like a light map in screen-space
  • 50. Combiner Pass ● Another geometry pass that combines ● Lighting result ● Two ambient colours based on Ambient Occlusion factor ● Ambient saturation ● Character fill light ● Everything is written in linear space in 16-bit per channel
  • 52. Character Fill Light ● Used rim light once ● What we wanted: making characters pop out in the shadow ● So borrowed the concept of fill lights from movie industry ● First implementation: 3 directional lights on characters ● Based on camera angle (top, left and right) ● Turns out to be too expensive ● Shipped (optimized) version: 2 directional lights ● One for diffuse only ● The other for spec only ● Blended in based on diffuse lighting
  • 56. Ambient Colour / Saturation ● We have two ambient colours ● Based on occlusion depth, we blend between these two colours (think them as deep and shallow shadow colours) ● However, sometimes we want diffuse texture to stand out ● Especially on Space Marines ● We call it ambient saturation ● We have two global ambient saturation each for: ● Environments ● Character unlitColour *= lerp(lum(diffuse),diffuse,saturation);
  • 57. Overcoming Cons of Deferred Lighting ● Transparent Objects ● We used hard-alpha (alpha testing) as much as possible ● Some special treatment for hair ● If it's a co-planar object, we use a SSD ● Anti-aliasing ● Hard with DX9 level GPUs ● made something similar to FXAA
  • 58. Ambient Occlusion Pass Budget(ms) Depth-Pre 0.50 G-Buffer + Linear Depth 5.05 Ambient Occlusion 2.25 Lighting 8.00 Combiner Pass 5.00 Blend 0.15 Gamma Conversion 1.30 FX 2.75 Post Processing 3.70 UI 0.50 Total 29.20
  • 59. Ambient Occlusion ● Will explain later in detail
  • 60. Gamma Conversion Pass Budget(ms) Depth-Pre 0.50 G-Buffer + Linear Depth 5.05 Ambient Occlusion 2.25 Lighting 8.00 Combiner Pass 5.00 Blend 0.15 Gamma Conversion 1.30 FX 2.75 Post Processing 3.70 UI 0.50 Total 29.20
  • 61. Gamma Conversion ● We do lighting and combiner in linear space (HDR) ● In this step, we separate HDR image into LDR and bloom intensity ● LDR image is stored in RGB (in gamma space) ● Bloom intensity is stored in Alpha channel ● Based on pixel luminance and threshold set by artists ● Later used in bloom pass ● For more about linear lighting, please take a look at this presentation by John Hable: ● http://filmicgames.com/Downloads/GDC_2010/Uncharted2- Hdr-Lighting.pptx
  • 64. FX(Particle) Pass Pass Budget(ms) Depth-Pre 0.50 G-Buffer + Linear Depth 5.05 Ambient Occlusion 2.25 Lighting 8.00 Combiner Pass 5.00 Blend 0.15 Gamma Conversion 1.30 FX 2.75 Post Processing 3.70 UI 0.50 Total 29.20
  • 65. FX(Particle) Pass ● Relic is known for the crazy amount of particles ● Additive, blend, distortion, soft particles, lit particles... ● Mesh or Decal spawn ● Particle updates and submission, heavily multi-threaded ● God rays ● Dynamic FX lights ● Can have shadow -> expensive ● A lot of time, we use light mask ● Optimization: ● Half-res particles when FPS is slower ● Batch through pre-multiplied alpha and texture page ● Too big of a system to fit in this presentation, but is a collection of standard industry practices and techniques
  • 68. Post Processing Pass Budget(ms) Depth-Pre 0.50 G-Buffer + Linear Depth 5.05 Ambient Occlusion 2.25 Lighting 8.00 Combiner Pass 5.00 Blend 0.15 Gamma Conversion 1.30 FX 2.75 Post Processing 3.70 UI 0.50 Total 29.20
  • 69. (Uber) Post-Processing ● Uber pass processing almost all the post- processing at once ● Mostly to save Resolve cost on Xbox 360 ● Generate Distortion Vector Texture ● Generate Depth-of-Field + Camera Motion Blur ● Generate HDR Bloom Texture – Colour Correction – AA – Vignette
  • 70. Generate Distortion Vector Texture ● Nothing special ● All from FX ● 2D UV offset is stored in screen-space ● Later this offset is used when combining all post- processing effect with the frame buffer
  • 71. Generate DOF + MB ● Both Depth-of-Field and Camera Motion Blur are blurry ● So let's process both at the same time ● Pass 0: generates a blur offset based on distance to camera and camera motion blur ● Pass 1: separable masked gaussian blur ● Pass 2: separable masked gaussian blur + store mask into Alpha channel ● All done in half-res ● Later mask value (in Alpha channel) is used to blend between this texture and the full-res frame buffer
  • 72. DOF + MB (Before)
  • 73. DOF + MB (Offset)
  • 74. DOF + MB (Pass 1)
  • 75. DOF + MB (Pass 2)
  • 76. Generate HDR Bloom Texture ● Nothing special ● Close to Halo 3 way ● We don't do tone mapping ● Done in 3 passes with half-res frame buffer ● ½ downsample and blur ● ½ downsample again and blur ● Merge back to ¼ res buffer and blur
  • 77. Colour Correction ● Originally implemented for a previous unreleased project ● We use a 32x32x32 3D texture ● Each dimension represent a channel's input value ● Value stored in the texture replaces the input value ● We created a Photoshop plug-in to help authoring the colour grade texture ● Take a screenshot from game ● Load the image in to Photoshop ● Use whatever layer modifiers to male it look good ● Press the Magic button ● Done!
  • 78. Anti-Aliasing ● Simplified version of FXAA using just 4 samples to find the slope of the luminance edge ● Use the slope to do a 3 pixel blending between blurred and unblurred versions of the textures ● Total 7 texture look-ups
  • 83. UI Pass Budget(ms) Depth-Pre 0.50 G-Buffer + Linear Depth 5.05 Ambient Occlusion 2.25 Lighting 8.00 Combiner Pass 5.00 Blend 0.15 Gamma Conversion 1.30 FX 2.75 Post Processing 3.70 UI 0.50 Total 29.20
  • 84. UI ● Nothing much to talk about ● We use Scaleform
  • 85. First Half is Over!! Questions so far?
  • 86. Agenda 1. Deferred Lighting 2. Screen Space Decals 3. World Occlusion
  • 87. Traditional Decals ● Example: Bullet Hole ● Get the underlying collision geometry at collision point ● Walk through the geometry to find out the smallest patch possible to represent the bullet hole ● Make a mesh patch with the vertices found in step 2 ● Draw the underlying geometry ● Draw the patch with the bullet hole textures ● Problems ● Decal stretching ● Collision detection is expensive ● Waste of vertex space: a plane cannot be simply 4 verts anymore
  • 88. Screen Space Decals (SSDs) ● We already have all surface information in screen- space ● Normals ● Depth ● Position ( driven from depth info ) ● So why don't we use these info instead of making a mesh patch? ● Benefits: ● Our collision meshes are super simple ● Our Havok broadphase is super fast
  • 91. Screen Space Decals ● Same Example: Bullet Hole 1. Draw underlying visual geometries onto scene 2. Rasterize a SSD box at the collision point 3. Read the scene depth for each pixel 4. Calculate 3D position from the depth 5. If this position is outside of the SSD box, reject 6. Otherwise, draw the pixel with the bullet hole texture
  • 92. Screen Space Decals ● Not just for FX ● It's literally used everywhere: Blood splat on the wall or ground ● ● Stone wall decoration ● Burnt mark on concrete slate ● Ork painting ● Rubble piles on the ground ● Bullet holes ● Explosion damage ● ......and list goes on ● Yup, environment artists love it!
  • 95. Screen Space Decals ● SSD drawing is split into two passes in G-Buffer: update scene normals ● ● in Combiner: combine lighting result and surface materials ● Gives artists a lot of freedom Normal-only decals (e.g, stone wall decoration) ● ● Colour-only decals (e.g, blood splat) ● Normal + colour decals (e.g, thick ork painting) ● All the lighting & ambient occlusion are FREE
  • 102. SSD - Problems ● Stretching ● Moving objects ● Performance
  • 104. SSD - Stretching ● Problem Caused by projection boxes not fully submerged ● into underlying geometry ● Round objects have similar problem ● Solution ● Using 3D textures was an option, but expensive ● Instead, we reject pixels with normal threshold ● Get normal from underlying surface ● Dot-product this with SSD box's orientation ● If it's over an artist-set threshold, reject
  • 105. SSD – Moving Objects ● Problem If an object is moving through a SSD ● projection volume, you will see SSDs sliding across the object's surface ● Solution ● Stencil masking moving objects ● All skinned or dynamic objects don't receive decals by default ● Artists can override it (some skinned objects are not moving. e.g, props in healthy state)
  • 106. SSD – Moving Objects
  • 107. SSD – Moving Objects
  • 108. SSD - Performance ● Problem ● Box projection in screen-space ● Can only reject in pixel shader ● If a SSD box is covering full-screen, it's same as a full- screen draw pass ● Solution ● Make decals thin, but not too thin ● Utilize Hi-Z as much as possible for early rejection ● Doesn't solve FX decals' problem, but that's fine
  • 109. Thick SSD = BAD
  • 110. Thin SSD = GOOD
  • 111. Agenda 1. Deferred Lighting 2. Screen Space Decals 3. World Occlusion
  • 112. Ambient Occlusion ● Simulates occluded and bounced lights ● We use two techniques ● World Occlusion – Our own approach – Based on ambient occlusion technique used in COH – Vertical occlusion in world space ● SSAO ● Same as other games ● Depth-only comparison in screen space
  • 115. World Occlusion (Old Version) ● Uses vertical distance between objects as attenuation factor ● Proxy simplified objects are rendered on a depth only target ● This normalized value is then blurred ● This blurred value is used to blend between two ambient light values ● (^_^) Works great for outdoor scenes ● (T_T) For interior scenes, not so much
  • 116. World Occlusion (New Version) ● Solves the problem of interior scenes ● No more, the highest distance to the ground ● Depth peeling to allow up to 4 different depth layers ● Rendered using a top-down view camera
  • 117. World Occlusion ● Then world occlusion texture is blurred ● At different amounts for each level ● So that vertical walls can cast/darken ambient light at the crevices with the ground ● This fakes horizontal bleeding of world occlusion
  • 122. Applying World Occlusion For each pixel on the screen: 1.Compute the world position of the pixel 2.Find out in what depth layer of world occlusion this pixel is 3.Compute the distance to the corresponding value stored in the world occlusion texture 4.Use normalized result to blend between the low and high ambient colour values (same time as SSAO)
  • 124. World Occlusion (Optimization) ● Problems ● Drawing all objects 4 times is slow ● Applying it in full-screen is slow ● Solutions ● Don't generate world occlusion map every frame ● Artists tag certain objects as World Occlusion contributors ● Layer heights are controlled by artists per region ● Use a half-res render texture when applying
  • 125. SSAO ● A lot of trials and errors ● Toy Story 3(game) way: way too noisy ● Improved version of Crytek way: noisy co-planar surface ● Simplified volumetric SSAO: too many samples ● Our final approach was rather simple ● Depth-only comparison ● Circular neighbour samples: 16 for X360, 9 for PS3 ● No filtering of any kind
  • 126. SSAO
  • 127. References ● [Timothy11] FXAA: http://timothylottes.blogspot.com/2011/03/nvidia-fxaa.html ● [Aras09] Deferred Cascade Shadow Maps http://aras-p.info/blog/2009/11/04/deferred-cascaded-shadow-maps/ ● [Wolf08] Light Pre-Pass renderer: http://diaryofagraphicsprogrammer.blogspot.com/2008/03/light-pre-pass- renderer.html ● [Val07] Deferred Rendering in Killzone 2: http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf ● [Jeremy05] Using Lookup Tables to Accerlate Color Transformations: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html
  • 128. Acknowledgements ● Space Marine rendering programmers: ● Ian Thomson ● Karl Schmidt ● Rod Reddekopp ● Angelo Pesce ● Space Marine artists for producing amazing content and pushing us to do more work!
  • 129. Got Questions? ● Pope Kim ● blindrenderer@gmail.com ● Twitter – Korean: BlindRendererKR – English: BlindRenderer ● Daniel Barerro ● daniel.barrero@gmail.com