a ray tracing deep dive
play

A RAY TRACING DEEP DIVE Holger Gruen (NVIDIA), Jon Story (NVIDIA), - PowerPoint PPT Presentation

SHADOWS OF THE TOMB RAIDER A RAY TRACING DEEP DIVE Holger Gruen (NVIDIA), Jon Story (NVIDIA), Michiel Roza (Nixxes) 03/19/2019 www.nvidia.com/GTC Shadow of the Tomb Raider Shadows of the Tomb Raider Why ray traced shadows?


  1. DXR SHADERS Translucency Subtraction is order independent: ➢ Let each layer subtract 1/3 of the light ➢ Pixel in full shadow after 3 order independent hits WS Pixel 50

  2. DXR SHADERS Translucency void TranslucentAnyHit(…) { float alpha = GetHitAlpha(bary, PrimID); if( alpha >= g_fAlphaThreshold ) payload.visibility -= ( 1.0f / 3.0f ); if( payload.visibility < 0.01f ) { payload.visibility = 0.0f; AcceptHitAndEndSearch(); } else IgnoreHit(); } 51

  3. Opaque raytraced shadows 52

  4. Translucent raytraced shadows 53

  5. DXR SHADERS Mini Agenda • Noise / random number generation • Ray generation • Hit shaders • Adaptive raytracing • Translucency • TAA and jittering 54

  6. DXR SHADERS TAA + Jittering • Like many games SotTR uses jittered TAA • Each frame adds a ‘random’ subpixel offset to all geometry • Surprisingly this creates problems with flickering shadows! 55

  7. DXR SHADERS TAA + Jittering The red dots are the pixel • centers a 2x2 pixel grid • This is where rasterized geometry is sampled 56

  8. DXR SHADERS TAA + Jittering The intermediate positions Rasterizing a and the grid are shown to 3D quadrangle help understand how 3D positions change across the quad 57

  9. DXR SHADERS TAA + Jittering Jitter somewhat … 58

  10. DXR SHADERS TAA + Jittering • Jittering changes the WS position that is sampled at pixel centers It also changes the depth values at the pixel centers • • Jittering changes the reconstructed world space positions Shadow ray origins jitter as well 59

  11. DXR SHADERS TAA + Jittering Jittered ray positions are not problematic in general, but: • We typically shoot only one ray per pixel Which is equivalent to ‘point sampling‘ of the visibility signal • • Large areas of flat ground are problematic • Vertical jittering leads to large differences in WS positions Also visible with shadow maps but less because of SM filtering • 60

  12. VIDEO 61

  13. DXR SHADERS TAA + Jittering Solutions: 1. Currently we render an extra depth pass without jittering Use non-jittered depth to reconstruct WS ray origins • 2. Future: Render ddx/ddy(1/z_buffer_depth) with depth pass Reconstruct non-jittered depth • Use non-jittered depth to construct WS ray origins • 1/z-buffer-depth is linear in screen space • 62

  14. Shadow of the Tomb Raider “Shadows” of the Tomb Raider Why ray traced shadows? DXR shaders (ray generation) GameWorks spatial denoiser AGENDA DXR acceleration structure Integration in render pipeline Results Future work 63

  15. INPUT / OUTPUT Light Desc Params Visibility HitT GameWorks Spatial Denoiser Edward Liu & Jon Story Normals Depth 64

  16. ISOTROPIC KERNEL 65

  17. ANISOTROPIC KERNEL 66

  18. OVERLAPPING PENUMBRA #1 67

  19. OVERLAPPING PENUMBRA #2 68

  20. BLEEDING ARTIFACTS Need to detect depth boundaries 69

  21. CUSTOMIZED BOUNDARY DETECTION 70

  22. COULD WE DO LESS WORK? 71

  23. PENUMBRA MASK 72

  24. IMPORTANT FEATURES Half resolution denoising Drastically improves performance SOTTR uses this mode for ALL light types MSAA input Depth & Normal buffers supported Still only requires single sample Visibility & HitT buffers Produces MSAA shadow mask Sub-viewports supported for local light sources Just need to figure out screen area affected 73

  25. Shadow of the Tomb Raider “Shadows” of the Tomb Raider Why ray traced shadows? DXR shaders (ray generation) GameWorks spatial denoiser AGENDA DXR acceleration structure Integration in render pipeline Results Future work 74

  26. BLAS “a mesh” struct D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC { DXGI_FORMAT IndexFormat; DXGI_FORMAT VertexFormat; Vertex and index buffers for each geometry UINT IndexCount; UINT VertexCount; Straightforward for static geometry D3D12_GPU_VIRTUAL_ADDRESS IndexBuffer; D3D12_GPU_VIRTUAL_ADDRESS VertexBuffer; } 75

  27. BLAS #if ExportVertexBuffer RWStructuredBuffer<float3> OutVertexBuffer; What about skinned objects #endif VertexOutput main( and vertex animations? in VertexInput vi, uint vertID : SV_VertexID) { Each vertex needs to be fully transformed! VertexOutput vo; %ShaderGraph% Foundation Engine uses shader graphs #if ExportVertexBuffer OutVertexBuffer[vertID] = vo.OutPosition; Added a shader permutation in VS template for #endif exporting a transformed vertex buffer return vo; } Run a pass for all dynamic objects before building 76

  28. Skinning gone wrong: Inner demon ☺ 77

  29. BLAS Lara’s hair PureHair, an evolution of TressFX Simulates control points Renders strands of hair as camera facing quads Everything needs to be actual geometry in the AS Make the simplest cylinder possible for every strand 78

  30. BLAS Rebuild/refit strategy Two modes of updating dynamic BLASes in DXR: Rebuild, essentially “replacing” the old one (~ 100M tris/sec) Refit, for “small” model changes (~ 1000M tris/sec, 10x as fast!) Catch: ray trace performance might degrade! Top refitting throughput only for large enough workloads We chose to always refit BLAS unless # vertices change 79

  31. TLAS “A scene” struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS Static BLASes can be instanced { UINT NumDescs; D3D12_GPU_VIRTUAL_ADDRESS InstanceDescs; Always rebuilding TLAS seems to be fast enough } (<1ms) 80

  32. ACCELERATION STRUCTURE About LODs of meshes Every LOD level is stored in a separate BLAS Using LOD 0 for everything caused self-shadowing artifacts! Just use the same LOD we use for rendering What about LOD fading? Use “most visible” LOD 81

  33. Shadow of the Tomb Raider “Shadows” of the Tomb Raider Why ray traced shadows? DXR shaders (ray generation) GameWorks spatial denoiser AGENDA DXR acceleration structure Integration in render pipeline Results Future work 82

  34. RENDER PIPELINE Forward+ renderer Shadow map Shadow Forward Depth pass pass resolve opaque pass 83

  35. RENDER PIPELINE Now with ray traced shadows! Depth pass (Ray traced) Vertex Shadow map Forward Build AS Jittered/ Shadow transform pass opaque pass Non jittered resolve 84

  36. RENDER PIPELINE Now with ray tracing! 0.5ms 4ms 2ms 3ms 3ms 5ms Depth pass (Ray traced) Vertex Shadow map Forward Build AS Jittered/ Shadow transform pass opaque pass Non jittered resolve 85

  37. RENDER PIPELINE 0.5ms 4ms 2ms 3ms 3ms 5ms Depth pass (Ray traced) Vertex Shadow map Forward Build AS Jittered/ Shadow transform pass opaque pass Non jittered resolve Can run async with depth and shadow map passes! ☺ 86

  38. RENDER PIPELINE Async compute 0.5ms 2ms 3ms 5ms 3ms Depth pass Vertex (Ray traced) Forward opaque Jittered/ Shadow map pass Shadow resolve pass transform Non jittered Build AS 4ms completely hidden! 87

  39. WHY DO WE STILL NEED SHADOW MAPPING? Translucent rendering Translucent rendering has no depth write Can’t use shadow resolve pass! We cannot shoot rays from pixel shaders 88

  40. WHY DO WE STILL NEED SHADOW MAPPING? Performance! Updating entire scene full of dynamic objects costs up to 20ms of BLAS refits  AS culling using existing shadow map culling 89

  41. WHY DO WE STILL NEED SHADOW MAPPING? Performance! For directional lights: Replace only nearest cascades with ray traced shadows For local lights: Distance based fade to shadow map How do we choose these distances? 90

  42. ARTIST TOOLS Let lighting artists decide! 91

  43. Shadow of the Tomb Raider “Shadows” of the Tomb Raider Why ray traced shadows? DXR shaders (ray generation) GameWorks spatial denoiser AGENDA DXR acceleration structure Integration in render pipeline Results Future work 92

  44. No point light shadows 93

  45. Raytraced point light shadows 94

  46. Shadow mapped area light shadows 95

  47. Raytraced area light shadows 96

  48. Shadow mapped sun light shadows 97

  49. Raytraced sun light shadows 98

  50. Shadow of the Tomb Raider “Shadows” of the Tomb Raider Why ray traced shadows? DXR shaders (ray generation) GameWorks spatial denoiser AGENDA DXR acceleration structure Integration in render pipeline Results Future work 99

  51. FUTURE WORK Reconstruct non-jittered depth Ray traced shadows on translucent geometry Tessellation Content authoring with ray tracing in mind Use vertex transform pass for rasterization as well GI / Reflections / AO / … ? 100

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend