“ A bit more Deferred” - CryEngine 3 Martin Mittring – Lead Graphics Programmer Triangle Game Conference 2009
Crytek <ul><li>Main office: Germany Frankfurt </li></ul><ul><li>More studios:  Kiev, Budapest, Sofia, Nottingham, Seoul </...
<ul><li>32/64 Bit, WinXP/Vista, DX9/10, Multi CPU/GPU </li></ul><ul><li>WYSIWYP </li></ul><ul><li>ResourceCompiler Source ...
Goals after CryEngine 2 <ul><li>PS3 / XBox360 GPU, CPU, memory </li></ul><ul><li>Improve streaming </li></ul><ul><li>Impro...
What is the shader combination issue? <ul><li>Übershader is one shader with many features  (e.g. 0..4 lights, light types,...
Why Deferred Rendering? <ul><li>Rendering is a multi-dimensional query: View  x  Geometry  x  Material  x  Light </li></ul...
GBuffer in CryEngine 2 <ul><li>Minimal GBuffer (depth) </li></ul><ul><li>Slower Early Z pass when outputting linear depth ...
Deferred in CryEngine 2 <ul><li>Main use: Deferred shadows, Per pixel fog </li></ul><ul><li>Additionally: Soft Z clipped P...
Deferred Lighting in CryEngine 3 <ul><li>Passes: </li></ul><ul><ul><li>1) Forward GBuffer generation </li></ul></ul><ul><u...
Options for the light accumulation texture <ul><li>6 channels: Diffuse and Specular  </li></ul><ul><ul><li>two  7e3 7e3 7e...
Light accumulation texture in IBL <ul><li>The following pictures show lighting with Diffuse and Specular Cubemaps: </li></...
Storing normals in the GBuffer <ul><li>XYZ world space 8 bit: problematic with extreme reflections/specular 10 bit: good, ...
Alternative: VS Normal in 2 scalars -1..1 => -1..1 <ul><li>Normal to GBufffer: G= normalize( N .xy)*sqrt( N .z*0.5+0.5) </...
Improved SSAO (with normals) Video
Light rasterization in 2D  (Rectangle)  or 3D  (Convex Object) <ul><li>2D </li></ul><ul><ul><li>+ cheap WS position recons...
Deferred Light Types 1/3: <ul><li>Directional light optional with cloud shadows, multiple shadowmaps </li></ul><ul><li>Poi...
Deferred Light Types 2/3: Image Based Lighting (IBL) <ul><li>Light Probes are the high quality solution for distant light ...
Ambient without SSAO with hemispherical lighting
<ul><li>Bright ambient  SSAO </li></ul>Black ambient  Shadow casting light source  SSAO Grey ambient (hemispherical) Shado...
IBL ambient (Specular and Diffuse)  SSAO Video * brightened up for better display
Deferred Light Types 3/3: Real-time Dynamic Global Illumination <ul><li>Details will be presented at upcoming Siggraph 200...
<ul><li>black ambient </li></ul><ul><li>(to emphasize where GI </li></ul><ul><li>affects the image) </li></ul>color bleedi...
Global Illumination * brightened up for better display
Something missing? <ul><li>Transparency  => falling back to well known techniques: </li></ul><ul><ul><li>Per pixel global ...
References <ul><li>[Mittring07] “Finding Next Gen CryEngine2“ Siggraph 2007, Martin Mittring http://ati.amd.com/developer/...
 
 
Upcoming SlideShare
Loading in...5
×

A Bit More Deferred Cry Engine3

16,354

Published on

Published in: Business, Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
16,354
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
362
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide
  • “ A bit more Deferred” – Deferred in the way of using the so called “deferred rendering” techniques
  • A Bit More Deferred Cry Engine3

    1. 1. “ A bit more Deferred” - CryEngine 3 Martin Mittring – Lead Graphics Programmer Triangle Game Conference 2009
    2. 2. Crytek <ul><li>Main office: Germany Frankfurt </li></ul><ul><li>More studios: Kiev, Budapest, Sofia, Nottingham, Seoul </li></ul><ul><li>English as company language </li></ul><ul><li>30+ nationalities </li></ul><ul><li>CryEngine 1: PC only (Far Cry …) </li></ul><ul><li>CryEngine 2: PC only (Crysis …) </li></ul><ul><li>CryEngine 3: PC, XBox360, PS3 (announced GDC09) </li></ul>
    3. 3. <ul><li>32/64 Bit, WinXP/Vista, DX9/10, Multi CPU/GPU </li></ul><ul><li>WYSIWYP </li></ul><ul><li>ResourceCompiler Source asset -> Platform specific </li></ul><ul><li>Direct Light: Shadow mapping </li></ul><ul><li>Indirect Light (AO): SSAO / RAM / ... </li></ul><ul><li>No precomputed lighting Production time saver, Memory, Consistency, Dynamic content </li></ul><ul><li>Übershaders </li></ul>[Mittring07]
    4. 4. Goals after CryEngine 2 <ul><li>PS3 / XBox360 GPU, CPU, memory </li></ul><ul><li>Improve streaming </li></ul><ul><li>Improve multithreading </li></ul><ul><li>Improve lighting </li></ul><ul><li>More predictable performance </li></ul><ul><li>Tackle the shader combination issue </li></ul>
    5. 5. What is the shader combination issue? <ul><li>Übershader is one shader with many features (e.g. 0..4 lights, light types, CM reflection, fog, detail texture, normalmap, specular texture) </li></ul><ul><li>Compiling all possible permutations is a memory, production and performance problem </li></ul><ul><li>Usual solutions: </li></ul><ul><ul><li>dynamic branching / separating into multiple passes / reducing combinations and accepting less functionality and less performance </li></ul></ul><ul><ul><li>Asynchronous shader compiling </li></ul></ul><ul><ul><li>Distributed Job System to compile the shader cache </li></ul></ul>
    6. 6. Why Deferred Rendering? <ul><li>Rendering is a multi-dimensional query: View x Geometry x Material x Light </li></ul><ul><li>Classic Forward Rendering: for each light render geometry from scene query with shader </li></ul><ul><li>Classic Deferred Rendering: render geometry from scene query outputting GBuffer render each light from scene query and shade with GBuffer </li></ul><ul><li>=> Decouples geometric complexity from lighting and shading => Helps on shader combination issue and predictable performance </li></ul>
    7. 7. GBuffer in CryEngine 2 <ul><li>Minimal GBuffer (depth) </li></ul><ul><li>Slower Early Z pass when outputting linear depth </li></ul><ul><li>Formats: </li></ul><ul><ul><li>R16 </li></ul></ul><ul><ul><li>R16G16 </li></ul></ul><ul><ul><li>R32 </li></ul></ul><ul><li>Proved to be very useful </li></ul>Z
    8. 8. Deferred in CryEngine 2 <ul><li>Main use: Deferred shadows, Per pixel fog </li></ul><ul><li>Additionally: Soft Z clipped Particles, Motion Blur, Beach/Ocean, EdgeAA, Sun Rays, SSAO, Fake lights, 2.5D TerrainAO </li></ul>SSAO ShadowMask
    9. 9. Deferred Lighting in CryEngine 3 <ul><li>Passes: </li></ul><ul><ul><li>1) Forward GBuffer generation </li></ul></ul><ul><ul><li>2) Deferred light accumulation into texture (Phong) </li></ul></ul><ul><ul><li>3) Forward shading with light accumulation texture => No deferred shading </li></ul></ul><ul><li>Deferred Lighting* + Multiple light primitives are possible + even Image Based Lighting (IBL) + easy to extend </li></ul><ul><li>Compared to Deferred Shading + Less bandwidth and memory problems (10MB EDRAM XBox360) + More flexibility on shading (besides Phong) </li></ul>Z (native) Normal Specular Power * [Geldreich09] aka Light Pre-Pass Renderer [Engel08]
    10. 10. Options for the light accumulation texture <ul><li>6 channels: Diffuse and Specular </li></ul><ul><ul><li>two 7e3 7e3 7e3, A16R16G16B16f or A8R8G8B8* </li></ul></ul><ul><li>4 channels: Diffuse and Specular strength </li></ul><ul><ul><li>a single A16R16G16B16f or A8R8G8B8* (specular approximated by diffuse*strength) </li></ul></ul><ul><ul><li>The following pictures show lighting with two differently coloured lights: </li></ul></ul>6 channels (correct) 4 channels (fast) * sRGB helps to distribute more details in dark areas
    11. 11. Light accumulation texture in IBL <ul><li>The following pictures show lighting with Diffuse and Specular Cubemaps: </li></ul><ul><li>Diffuse RGB Specular RGB High Quality (left) </li></ul><ul><li>Diffuse RGB Specular Strength Fast Rendering (right) </li></ul><ul><li>Difference often neglectable (depends on environment) </li></ul>
    12. 12. Storing normals in the GBuffer <ul><li>XYZ world space 8 bit: problematic with extreme reflections/specular 10 bit: good, but what about specular power and PS3 </li></ul><ul><li>Solving Quantization Artefacts Detail Normalmaps, Noise, Dither </li></ul><ul><li>XY view space (Z reconstruct) 8/10/16 bit, negate Z bit (perspective and normal mapping) </li></ul>[Lee09] [Lob09] => Problematic
    13. 13. Alternative: VS Normal in 2 scalars -1..1 => -1..1 <ul><li>Normal to GBufffer: G= normalize( N .xy)*sqrt( N .z*0.5+0.5) </li></ul><ul><li>GBuffer to Normal: N .z=length2( G .xy)*2-1 N .xy=normalize( G .xy)*sqrt(1- N .z* N .z) </li></ul><ul><li>+ more precision where it matters (bright part) </li></ul><ul><li>+ framebuffer blending friendly </li></ul><ul><li>+ no z reconstruction issues </li></ul><ul><li>wasted area </li></ul><ul><li>more ALU than WS </li></ul>=> still, WS normals are faster
    14. 14. Improved SSAO (with normals) Video
    15. 15. Light rasterization in 2D (Rectangle) or 3D (Convex Object) <ul><li>2D </li></ul><ul><ul><li>+ cheap WS position reconstruction (Interpolator+MAD) </li></ul></ul><ul><ul><li>+ Combining multiple lights </li></ul></ul><ul><ul><li>Stencil prepass (if not fullscreen) </li></ul></ul><ul><ul><li>Coarse blocks can be rejected based on z min/max </li></ul></ul><ul><li>3D </li></ul><ul><ul><li>+ Z buffer </li></ul></ul><ul><ul><li>+ tighter bounding object (less pixels to process) </li></ul></ul><ul><li>Depth bounds test (only on some HW) </li></ul>
    16. 16. Deferred Light Types 1/3: <ul><li>Directional light optional with cloud shadows, multiple shadowmaps </li></ul><ul><li>Point/Projector lights optional with projector texture </li></ul><ul><li>Procedural Caustics (before this was multi-pass, one drawcall for each object under water including terrain) </li></ul><ul><li>Interleaved Shadowmap lookups no extra memory less bandwidth needed no limits on shadow mask channel count </li></ul>
    17. 17. Deferred Light Types 2/3: Image Based Lighting (IBL) <ul><li>Light Probes are the high quality solution for distant light </li></ul><ul><li>Cubemaps allow efficient HDR lighting in real-time </li></ul><ul><li>Diffuse CM can be computed from specular CM </li></ul><ul><li>Mip adjusted lookup allows different specular power values </li></ul><ul><li>Improves shading in ambient lighting condition by adding normal dependent and specular lighting </li></ul><ul><li>Light Probes can be generated at specified level positions </li></ul><ul><li>Deferred Lighting allows blending of localized Light Probes </li></ul><ul><li>Looks even better with SSAO </li></ul>
    18. 18. Ambient without SSAO with hemispherical lighting
    19. 19. <ul><li>Bright ambient SSAO </li></ul>Black ambient Shadow casting light source SSAO Grey ambient (hemispherical) Shadow casting light source SSAO IBL ambient (Specular and Diffuse) Shadow casting light source SSAO
    20. 20. IBL ambient (Specular and Diffuse) SSAO Video * brightened up for better display
    21. 21. Deferred Light Types 3/3: Real-time Dynamic Global Illumination <ul><li>Details will be presented at upcoming Siggraph 2009 by Anton Kaplanyan who developed that at Crytek </li></ul><ul><li>Implemented and fast on XBox360, PS3 and PC </li></ul><ul><li>No precomputation </li></ul><ul><li>Fully dynamic (geometry, materials and lights) </li></ul><ul><li>Unified for static and dynamic objects </li></ul>
    22. 22. <ul><li>black ambient </li></ul><ul><li>(to emphasize where GI </li></ul><ul><li>affects the image) </li></ul>color bleeding bump without light fully dynamic real-time Global Illumination off Global Illumination on
    23. 23. Global Illumination * brightened up for better display
    24. 24. Something missing? <ul><li>Transparency => falling back to well known techniques: </li></ul><ul><ul><li>Per pixel global fog and fog volumes (deferred) </li></ul></ul><ul><ul><li>Back to front sorted alpha transparent objects </li></ul></ul><ul><ul><li>Volume texture clouds, Imposter clouds, Distance clouds </li></ul></ul><ul><ul><li>Particle systems avoiding per particle sorting </li></ul></ul><ul><li>Anti-aliasing => Nasty but possible </li></ul><ul><ul><li>EdgeAA, … </li></ul></ul><ul><li>... we work on it </li></ul>
    25. 25. References <ul><li>[Mittring07] “Finding Next Gen CryEngine2“ Siggraph 2007, Martin Mittring http://ati.amd.com/developer/gdc/2007/mittring-finding_nextgen_cryengine2(siggraph07).pdf </li></ul><ul><li>[Engel08] “The Light Pre-Pass Renderer“ ShaderX7, Wolfgang Engel http://diaryofagraphicsprogrammer.blogspot.com/2008/03/light-pre-pass-renderer.html </li></ul><ul><li>[Lee09a] “Prelighting“ Mark Lee http://www.insomniacgames.com/tech/articles/0209/files/prelighting.pdf </li></ul><ul><li>[Lee09b] “Pre-lighting in Resistance 2“ GDC 2009, Mark Lee http://www.gdconf.com/conference/Tutorial%20Handouts/200_insomniac/gdc09_insomniac_prelighting.pdf </li></ul><ul><li>[Geldreich09] ”Deferred Lighting and Shading” GDC 2009, Rich Geldreich, Matt Pritchard, John Brooks http://archive.gdconf.com/gdc_2004/pritchard_matt.ppt </li></ul><ul><li>[Shish05] “Deferred Shading in S.T.A.L.K.E.R.“ GPU Gems 2, Oles Shishkovtsov http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter09.html </li></ul><ul><li>[Lob09] S.T.A.L.K.E.R : Clear Sky – a showcase for Direct3D 10.0/1 GDC 2009, Igor A. Lobanchikov, Holger Gruen http://www.gdconf.com/conference/Tutorial%20Handouts/100_Advanced%20Visual%20Effects%20with%20Direct3D/100_Handout%202.pdf </li></ul><ul><li>[Valient07] “Deferred Rendering in Killzone 2“ Develop Conference 2007, Michal Valient http:// www.guerrilla-games.com / publications /dr_kz2_rsx_dev07.pdf </li></ul>Slides should be soon at http://www.crytek.com/technology/presentations Special thanks to all the passionate people at Crytek
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×