Summer Games University<br />Day 3: Graphics<br />
Now in color and realtime<br />28.07.2010<br />3<br />Image sources: Vergemce, Crytek<br />
Connecting the Engine<br />Let’s take a look on the interface an engine might have and find some good patterns on how to m...
Connecting the Graphics<br />First idea:<br />28.07.2010<br />5<br />Every gameobject has a Render() method<br />This is y...
Multithreading<br />28.07.2010<br />6<br />Thread<br />Gameobject<br />Render(…)<br />HUH?!!!<br />Thread<br />Render(…)<b...
Multithreading<br />28.07.2010<br />7<br />Rendering is a pipelined process<br />Only one Renderer<br />Random order resul...
Connecting the Graphics<br />Better: data driven architecture<br />Scene<br />28.07.2010<br />8<br />Gameobject<br />Extra...
Connecting the Graphics<br />28.07.2010<br />9<br />Render Part<br />Material<br />material<br />Geometry Part<br />geomet...
Connecting the Graphics<br />Multithreaded version<br />Scene<br />28.07.2010<br />10<br />Extractor<br />Gameobject<br />...
Connecting the Graphics<br />28.07.2010<br />11<br />Resource Handles: Make them double buffered as well!<br />Renderer<br...
Let’s leave the architecture for a while…<br />28.07.2010<br />12<br />Image source:  Mumbai, Elphinstone Mills Tower, sky...
…let’s do some graphics<br />28.07.2010<br />13<br />Geometry<br />Light<br />X?<br />Material<br />
Geometry<br />28.07.2010<br />14<br />Engine<br />3d modeling tool<br />
Lighting  Overview<br />28.07.2010<br />15<br />Dynamic<br />Static<br />Image sources (left to right): “Half Life 2” Valv...
Static Lighting<br />Prerenderedlightmaps stored in textures<br />28.07.2010<br />16<br />
Static Lighting<br />What about normalmaps and moving objects?<br />28.07.2010<br />17<br />You need special tools to do t...
Static Lighting<br />Simple solution for moving objects: Hemispherical ambient<br />28.07.2010<br />18<br />Looks great! (...
Dynamic Lighting<br />28.07.2010<br />19<br />Forward Shading / Rendering<br />Vertex Shader<br />Rasterizer<br />Pixel Sh...
Forward Shading / Rendering<br />28.07.2010<br />20<br />Problems?<br />10…100….<br />Vertex Shader<br />Rasterizer<br />P...
Forward Shading / Rendering<br />28.07.2010<br />21<br />4…8<br />Vertex Shader<br />Rasterizer<br />Pixel Shader<br />+<b...
Forward Shading / Rendering<br />28.07.2010<br />22<br />Problems?<br />geometry overhead<br />complexity O(G*L)<br />mate...
Dynamic Lighting<br />28.07.2010<br />23<br />Deferred Shading / Rendering<br />G-Buffer<br />pass 1:<br />geometry<br />p...
Deferred Shading / Rendering<br />28.07.2010<br />24<br />
Deferred Shading / Rendering<br />28.07.2010<br />25<br />Depth<br />Glossiness<br />R16G16F<br />Normal Z<br />Normal Y<b...
Deferred Shading / Rendering<br />Starcraft 2<br />28.07.2010<br />26<br />Emissive<br />R16G16B16A16F<br />Specular<br />...
Deferred Shading / Rendering<br />28.07.2010<br />27<br />Advantage<br />no geometry overhead<br />complexity O(G+L)<br />...
Deferred Shading / Rendering<br />28.07.2010<br />28<br />Disadvantage<br />high memory bandwidth<br />no transparent geom...
Light Prepass Rendering<br />28.07.2010<br />29<br />pass 1:<br />geometry<br />pass 3:<br />material<br />pass 2:<br />li...
Light Prepass Rendering<br />28.07.2010<br />30<br />Advantage<br />less memory bandwidth<br />any possible shading type<b...
Light Prepass Rendering<br />28.07.2010<br />31<br />Disadvantage<br />render geometry twice<br />again no transparent geo...
Who uses it?<br />28.07.2010<br />32<br />Forward Shading<br />Light Prepass<br />Deferred Shading<br />Image sources (lef...
Going one step further…<br />Deferred<br />+ no geometry overhead<br />- high memory bandwidth<br />- no transparent geome...
Going one step further…<br />28.07.2010<br />34<br />minimal G-Buffer as used for a light prepass renderer<br />Depth<br /...
Renderpipeline<br />28.07.2010<br />35<br />G-Buffer Pass<br />Light Pass<br />Final Light Pass<br />Depth/Glossiness<br /...
Demo<br />28.07.2010<br />36<br />
Transparent Geometry<br />Fallback to forward shading -> difficult to keep lighting consistent<br />28.07.2010<br />37<br ...
We still have no architecture for the renderer itself<br />28.07.2010<br />38<br />Image source: www.okhistory.org<br />
Renderer Architecture<br />28.07.2010<br />39<br />DX9 Render Device Wrapper<br />Render Pipeline<br />DX11 Render Device<...
Renderer Architecture<br />28.07.2010<br />40<br />Render Pipeline<br />GBuffer Pass<br />Light Pass<br />Pass List<br />R...
Renderer Architecture<br />Data driven again:<br />28.07.2010<br />41<br />Render Pipeline<br />Configuration<br />File<br />
Renderer Architecture<br />28.07.2010<br />42<br />{<br />rendertargets: [<br />		{rw:1, rh:1, f:10},<br />		{rw:1, rh:1, ...
Material<br />28.07.2010<br />43<br />Shader<br />
Material<br />28.07.2010<br />44<br />Shader Generation<br />…<br />float4 CombineStages(VS_OUTPUT Input)<br />{<br />  fl...
Material<br />28.07.2010<br />45<br />Shader Generation<br />
Demo<br />28.07.2010<br />46<br />
Optimizations<br />28.07.2010<br />47<br />Minimize State-Changes<br />Culling<br />Draw front-to-back<br />Instancing<br ...
28.07.2010<br />48<br />?<br />questions<br />clemenskern.de<br />
Upcoming SlideShare
Loading in …5
×

Summer Games University - Day 3

2,183 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
2,183
On SlideShare
0
From Embeds
0
Number of Embeds
882
Actions
Shares
0
Downloads
28
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Summer Games University - Day 3

  1. 1.
  2. 2. Summer Games University<br />Day 3: Graphics<br />
  3. 3. Now in color and realtime<br />28.07.2010<br />3<br />Image sources: Vergemce, Crytek<br />
  4. 4. Connecting the Engine<br />Let’s take a look on the interface an engine might have and find some good patterns on how to model them.<br />28.07.2010<br />4<br />Create a manager instance in the engine, which translates incoming data(Player Input, ..)<br />Read-only<br />Use a renderer to create a representation of required information(Graphics, Sound, ..)<br />Write-only<br />No generic pattern. You will have to integrate it into the architecture(Physics, ..)<br />Communication<br />
  5. 5. Connecting the Graphics<br />First idea:<br />28.07.2010<br />5<br />Every gameobject has a Render() method<br />This is your architecture then<br />Image source: marcinchady GDC Canada Behavior presentation<br />
  6. 6. Multithreading<br />28.07.2010<br />6<br />Thread<br />Gameobject<br />Render(…)<br />HUH?!!!<br />Thread<br />Render(…)<br />Gameobject<br />Thread<br />Render(…)<br />Gameobject<br />
  7. 7. Multithreading<br />28.07.2010<br />7<br />Rendering is a pipelined process<br />Only one Renderer<br />Random order results in many state changes<br />Defined Order<br />
  8. 8. Connecting the Graphics<br />Better: data driven architecture<br />Scene<br />28.07.2010<br />8<br />Gameobject<br />Extractor<br />Renderer<br />Gameobject<br />data<br />data<br />Camera<br />
  9. 9. Connecting the Graphics<br />28.07.2010<br />9<br />Render Part<br />Material<br />material<br />Geometry Part<br />geometry<br />Vertex Buffer<br />next<br />…<br />Matrix List<br />transformation<br />next<br />Render Part<br />Geometry Part<br />
  10. 10. Connecting the Graphics<br />Multithreaded version<br />Scene<br />28.07.2010<br />10<br />Extractor<br />Gameobject<br />Renderer<br />Gameobject<br />Buffer 1<br />Buffer 2<br />Camera<br />Render thread<br />Main thread<br />
  11. 11. Connecting the Graphics<br />28.07.2010<br />11<br />Resource Handles: Make them double buffered as well!<br />Renderer<br />Resource Handle<br />Active resource<br />Resource 1<br />Resource 2<br />Resource Loader<br />Writes to<br />Can be in its own thread to do resource streaming<br />
  12. 12. Let’s leave the architecture for a while…<br />28.07.2010<br />12<br />Image source: Mumbai, Elphinstone Mills Tower, skyscraperpage.com<br />
  13. 13. …let’s do some graphics<br />28.07.2010<br />13<br />Geometry<br />Light<br />X?<br />Material<br />
  14. 14. Geometry<br />28.07.2010<br />14<br />Engine<br />3d modeling tool<br />
  15. 15. Lighting Overview<br />28.07.2010<br />15<br />Dynamic<br />Static<br />Image sources (left to right): “Half Life 2” Valve, “Unreal Tournament 3” Epic Games, “GTA4” Rockstar, “Crysis 2” Crytek<br />
  16. 16. Static Lighting<br />Prerenderedlightmaps stored in textures<br />28.07.2010<br />16<br />
  17. 17. Static Lighting<br />What about normalmaps and moving objects?<br />28.07.2010<br />17<br />You need special tools to do this!<br />Source: “Half Life 2 Shading Paper” Valve (http://www.valvesoftware.com/publications/2004/GDC2004_Half-Life2_Shading.pdf)<br />
  18. 18. Static Lighting<br />Simple solution for moving objects: Hemispherical ambient<br />28.07.2010<br />18<br />Looks great! (except for the missing shadows…)<br />Huh, radioactive teapots?<br />
  19. 19. Dynamic Lighting<br />28.07.2010<br />19<br />Forward Shading / Rendering<br />Vertex Shader<br />Rasterizer<br />Pixel Shader<br />
  20. 20. Forward Shading / Rendering<br />28.07.2010<br />20<br />Problems?<br />10…100….<br />Vertex Shader<br />Rasterizer<br />Pixel Shader<br />
  21. 21. Forward Shading / Rendering<br />28.07.2010<br />21<br />4…8<br />Vertex Shader<br />Rasterizer<br />Pixel Shader<br />+<br />
  22. 22. Forward Shading / Rendering<br />28.07.2010<br />22<br />Problems?<br />geometry overhead<br />complexity O(G*L)<br />material-light combinations<br />unpredictable performance<br />
  23. 23. Dynamic Lighting<br />28.07.2010<br />23<br />Deferred Shading / Rendering<br />G-Buffer<br />pass 1:<br />geometry<br />pass 2:<br />light<br />
  24. 24. Deferred Shading / Rendering<br />28.07.2010<br />24<br />
  25. 25. Deferred Shading / Rendering<br />28.07.2010<br />25<br />Depth<br />Glossiness<br />R16G16F<br />Normal Z<br />Normal Y<br />Normal X<br />R10G10B10A2<br />Diffuse Color<br />Self Illum<br />R8G8B8A8<br />Velocity<br />Specular<br />ID<br />R8G8B8A8<br />*Depth and Normals are stored in Viewspace<br />
  26. 26. Deferred Shading / Rendering<br />Starcraft 2<br />28.07.2010<br />26<br />Emissive<br />R16G16B16A16F<br />Specular<br />R16G16B16A16F<br />Diffuse Color<br />AO<br />R16G16B16A16F<br />Normal<br />Depth<br />R16G16B16A16F<br />optional<br />Source: StarCraftII Effects & Techniques<br />
  27. 27. Deferred Shading / Rendering<br />28.07.2010<br />27<br />Advantage<br />no geometry overhead<br />complexity O(G+L)<br />no need for “ubershader”<br />
  28. 28. Deferred Shading / Rendering<br />28.07.2010<br />28<br />Disadvantage<br />high memory bandwidth<br />no transparent geometry<br />no native anti-aliasing<br />restricted to one shading-type (phong)<br />
  29. 29. Light Prepass Rendering<br />28.07.2010<br />29<br />pass 1:<br />geometry<br />pass 3:<br />material<br />pass 2:<br />light<br />
  30. 30. Light Prepass Rendering<br />28.07.2010<br />30<br />Advantage<br />less memory bandwidth<br />any possible shading type<br />native anti-aliasing<br />
  31. 31. Light Prepass Rendering<br />28.07.2010<br />31<br />Disadvantage<br />render geometry twice<br />again no transparent geometry<br />
  32. 32. Who uses it?<br />28.07.2010<br />32<br />Forward Shading<br />Light Prepass<br />Deferred Shading<br />Image sources (left to right): “Doom 3” id Software, “Crysis” Crytek, “Stalker” GSC, “Starcraft 2” Blizzard, “GTA4” Rockstar, “Crysis 2” Crytek<br />
  33. 33. Going one step further…<br />Deferred<br />+ no geometry overhead<br />- high memory bandwidth<br />- no transparent geometry<br />- no anti-aliasing<br />- only one shading type<br />28.07.2010<br />33<br />Light Prepass<br />- render geometry twice<br />+ less memory bandwidth<br />- no transparent geometry<br />+ anti-aliasing<br />+ any possible shading type<br />Take the advantages and mix both approaches together<br />
  34. 34. Going one step further…<br />28.07.2010<br />34<br />minimal G-Buffer as used for a light prepass renderer<br />Depth<br />Glossiness<br />R16G16<br />Normal Z<br />Normal Y<br />Normal X<br />R10G10B10A2<br />Diffuse Color<br />Self Illum<br />R8G8B8A8<br />Velocity<br />Specular<br />ID<br />R8G8B8A8<br />
  35. 35. Renderpipeline<br />28.07.2010<br />35<br />G-Buffer Pass<br />Light Pass<br />Final Light Pass<br />Depth/Glossiness<br />L-Buffer<br />(Final) Image<br />Normal<br />Color/Self Illum<br />Velocity/Spec/ID<br />+ less memory bandwith<br />+ all objects using phong shading in one geometry pass<br />+ can do other shading types, because we have a Light Buffer (need to be renderer twice)<br />- anti-aliasing (can be done as post process)<br />- transparent geometry <br />
  36. 36. Demo<br />28.07.2010<br />36<br />
  37. 37. Transparent Geometry<br />Fallback to forward shading -> difficult to keep lighting consistent<br />28.07.2010<br />37<br />Dithering only in L-Buffer<br />Dithering<br />Image sources: “GTA4” Rockstar, “Inferred Lighting” Paper Scott Kircher, Alan Lawrance<br />
  38. 38. We still have no architecture for the renderer itself<br />28.07.2010<br />38<br />Image source: www.okhistory.org<br />
  39. 39. Renderer Architecture<br />28.07.2010<br />39<br />DX9 Render Device Wrapper<br />Render Pipeline<br />DX11 Render Device<br />Wrapper<br />device.Draw(…)<br />PS3 Render Device<br />Wrapper<br />
  40. 40. Renderer Architecture<br />28.07.2010<br />40<br />Render Pipeline<br />GBuffer Pass<br />Light Pass<br />Pass List<br />RenderTarget List<br />HDR Pass<br />foreach (…)<br />{<br />PrepareRenderTargets();<br />pass.Execute(renderTargets); <br />}<br />Screen Pass<br />
  41. 41. Renderer Architecture<br />Data driven again:<br />28.07.2010<br />41<br />Render Pipeline<br />Configuration<br />File<br />
  42. 42. Renderer Architecture<br />28.07.2010<br />42<br />{<br />rendertargets: [<br /> {rw:1, rh:1, f:10},<br /> {rw:1, rh:1, f:3},<br /> {rw:1, rh:1, f:1},<br /> {rw:1, rh:1, f:1},<br /> …<br /> ],<br /> passes: {<br />GBufferPass: {<br />rt: [0, 1, 2, 3]<br /> },<br />AmbientOcclusionPass: {<br />rt: [0, 4, 5, 6]<br /> },<br />LightPass: {<br />rt: [0, 1, 2, 3, 6, 7, 8]<br /> },<br /> …<br /> }<br />}<br />
  43. 43. Material<br />28.07.2010<br />43<br />Shader<br />
  44. 44. Material<br />28.07.2010<br />44<br />Shader Generation<br />…<br />float4 CombineStages(VS_OUTPUT Input)<br />{<br /> float3 vColor = (float3) 0;<br /> float fOpacity = 1.0;<br /> // Diffuse stage<br /> #ifdef DIFFUSE<br /> float3 vDiffuse = GetDiffuse(Input);<br /> #ifdef DIFFUSE_TINT<br />vDiffuse *= DIFFUSE_TINT;<br /> #endif<br />vColor = vDiffuse;<br /> #endif<br /> // Diffuse lighting stage<br /> #ifdef LIGHTING_LIGHTMAP<br /> float3 vLighting = GetStaticLighting(Input);<br />vColor *= vLighting; <br /> #else<br /> #ifdef LIGHTING_DYNAMIC_LIGHTING<br /> float3 vLighting = GetDynamicLighting(Input);<br />vColor *= vLighting; <br /> #endif<br /> #endif<br />….<br /><material><br /> <shader><br /> <diffuse><br /> <map><br /> <source>materials/metal/base03.dds</source><br /> </map><br /> </diffuse><br /> <reflection fresnel="1.5"><br /> <map><br /> <source>materials/metal/env.dds</source><br /> <type>cube</type><br /> <amount>1.0</amount><br /> <saturation>0.2</saturation><br /> </map><br /> <map><br /> <source>materials/metal/base03.dds</source><br /> <channels>alpha</channels><br /> <type>mask</type><br /> </map><br /> </reflection><br /> </shader><br /></material><br />
  45. 45. Material<br />28.07.2010<br />45<br />Shader Generation<br />
  46. 46. Demo<br />28.07.2010<br />46<br />
  47. 47. Optimizations<br />28.07.2010<br />47<br />Minimize State-Changes<br />Culling<br />Draw front-to-back<br />Instancing<br />Shader optimizations<br />
  48. 48. 28.07.2010<br />48<br />?<br />questions<br />clemenskern.de<br />

×