Volumetric Global Illumination at Treyarch.pptx
- Количество слайдов: 81
Volumetric Global Illumination At Treyarch JT Hooker Treyarch Senior Graphics Engineer Advances in Real-Time Rendering course, SIGGRAPH 2016
Volumetric Global Illumination • • GI in volume texture Lean texture data IBL baked from probes Convex blend shapes Advances in Real-Time Rendering course, SIGGRAPH 2016
Presentation Order Where we started Evolution along the way Where we ended up Advances in Real-Time Rendering course, SIGGRAPH 2016
Traditional Approach: Lightmaps Could be ok, but… Advances in Real-Time Rendering course, SIGGRAPH 2016
Lightmap Downsides §Works poorly on detailed or intersecting geometry Advances in Real-Time Rendering course, SIGGRAPH 2016
Lightmap Downsides §Doesn’t work at all on dynamic geometry Advances in Real-Time Rendering course, SIGGRAPH 2016
Lightmap Downsides §Software ray-tracing and shading takes forever Advances in Real-Time Rendering course, SIGGRAPH 2016
Lightmap Downsides §Results not visible in world editor Advances in Real-Time Rendering course, SIGGRAPH 2016
Process of Invention §Deferred Renderer §Reflections already present §So how do we apply deferred GI? Advances in Real-Time Rendering course, SIGGRAPH 2016
Reflection Probes as Diffuse Data • Higher Mips: convolved specular [DROBOT 13] • Lowest Mip: diffuse irradiance • Real time IBL Advances in Real-Time Rendering course, SIGGRAPH 2016
Occlusion Is A Problem Advances in Real-Time Rendering course, SIGGRAPH 2016
Visibility Is A Problem • Where the probe doesn’t see • Looks like shadows Advances in Real-Time Rendering course, SIGGRAPH 2016
Irradiance Volume [TATARCHUK 05] Advances in Real-Time Rendering course, SIGGRAPH 2016
Render a Reflection Probe Per Voxel? 138 Volumes × 403 Voxels × 6 Faces ÷ 60 FPS ÷ 60 Seconds = 14, 720 Minutes (≈ 10 Days) Advances in Real-Time Rendering course, SIGGRAPH 2016
Collect Colors From Reflection Probes • Re-project cube maps • Combine to fill holes [BUEHLER 01] Advances in Real-Time Rendering course, SIGGRAPH 2016
In Practice • 4096 rays per voxel • 15 neighbors considered • Missed rays are inpainted Advances in Real-Time Rendering course, SIGGRAPH 2016
Re-Project From Existing Probes Advances in Real-Time Rendering course, SIGGRAPH 2016
Reprojection §Neighbor candidates sorted based on distance §What about spec? Advances in Real-Time Rendering course, SIGGRAPH 2016
Reprojection §Angle and distance to surface defines a solid angle in the cube map Advances in Real-Time Rendering course, SIGGRAPH 2016
Reprojection §Sample area validated against depth pyramid §If visible appropriate mip sampled Advances in Real-Time Rendering course, SIGGRAPH 2016
Reprojection Caluclation Advances in Real-Time Rendering course, SIGGRAPH 2016
Reprojection Calculation dist. From. Unit. Cube = √( 1 + u 2 + v 2 ); // Compensation for cube-map shape. angle. Of. Voxel = 4 * PI / num. Samples; // Solid angle from voxel. in. Sqrt = 1 + dist. From. Voxel 2 * angle. Of. Voxel * ( angle. Of. Voxel – 4 PI ) / ( 4 * PI 2 * dist. From. Probe 2 ); angle. Of. Probe = 2 PI * ( 1 – √in. Sqrt ); // Solid angle from reflection probe. cube. Res = 1. 0 f / √( angle. Of. Probe * dist. From. Unit. Cube 3 ); // Resolution needed for sample. mip. Level = clamp( mip. Count – log 2( cube. Res ), 0, mip. Count ); // Mip level to use. return mip. Level; Advances in Real-Time Rendering course, SIGGRAPH 2016
Biggest Benefit • Hardware rendering • Re-render to get bounces • Only have to ray-trace and re-project once Advances in Real-Time Rendering course, SIGGRAPH 2016
Texture Encoding • Flat Color? Advances in Real-Time Rendering course, SIGGRAPH 2016
Texture Encoding • Ambient / Highlight / Direction? Advances in Real-Time Rendering course, SIGGRAPH 2016
Texture Encoding • Second Order Spherical Harmonic? Advances in Real-Time Rendering course, SIGGRAPH 2016
Texture Encoding • Ambient Cube! [MCTAGGART 04] • BC 6 H Compressed Advances in Real-Time Rendering course, SIGGRAPH 2016
Volume Texture Layout Advances in Real-Time Rendering course, SIGGRAPH 2016
Performance Benefits §Only 3 samples color = x. Volume. Sample. Level( coord ) * normal. x + y. Volume. Sample. Level( coord ) * normal. y + z. Volume. Sample. Level( coord ) * normal. z; §Hardware trilinear filtering §Evaluation: color[n] = normal 2 ∙ float 3( Xsample[n], Ysample[n], Zsample[n] ) Advances in Real-Time Rendering course, SIGGRAPH 2016
Light Leaking Is A Problem Advances in Real-Time Rendering course, SIGGRAPH 2016
Common Approach §Adjust trilinear Based on normal [SILVENNOINEN 15] §Our approach needs to be more reliable Advances in Real-Time Rendering course, SIGGRAPH 2016
More Voxel Data §Planes §Signed distance field §Bad artifacts Advances in Real-Time Rendering course, SIGGRAPH 2016
Solve With Shaping Advances in Real-Time Rendering course, SIGGRAPH 2016
Click To Size Boxes Advances in Real-Time Rendering course, SIGGRAPH 2016
Click To Add Boxes Auto-parent on creation Advances in Real-Time Rendering course, SIGGRAPH 2016
Voxels Near Walls Advances in Real-Time Rendering course, SIGGRAPH 2016
Consider Backfaces Advances in Real-Time Rendering course, SIGGRAPH 2016
Complex Room Shapes Advances in Real-Time Rendering course, SIGGRAPH 2016
Solution: Convex Shapes Advances in Real-Time Rendering course, SIGGRAPH 2016
Multiface Volumes Click to add and remove faces. Advances in Real-Time Rendering course, SIGGRAPH 2016
Multiface Volume Editing Drag / Cut / Slice / Rotate Advances in Real-Time Rendering course, SIGGRAPH 2016
Subtract Shapes CSG add Then subtract Advances in Real-Time Rendering course, SIGGRAPH 2016
Override Volumes Like priority Only two levels. Advances in Real-Time Rendering course, SIGGRAPH 2016
Runtime Implementation 1. Cull against volume AABB’s to build a list of volumes 2. Per pixel calculate attenuation on visible volumes § Convex hull CSG § Groups of six planes either extended, combined or subtracted Advances in Real-Time Rendering course, SIGGRAPH 2016
Example GI Volume struct Plane. Group { float 4 planes[6]; // Groups of six planes. bool subtractive; // Per group, specifies whether it adds or subtracts. bool finished; // Per group, whether it should be combined with the previous. } struct GIvolume { Plane. Group *groups; } // Blends, or “feather”, are pre-multiplied into the plane definition. planes[i]. xyz = plane. Normal; planes[i]. w = plane. Offset; planes[i] /= blend. Width; // Blend width is a scalar for how wide the blend is. Advances in Real-Time Rendering course, SIGGRAPH 2016
Group Size? [6]+[6+6+…? [6]+[4+4+. . . ? [4]+[4+4+…? [8]+[2+2+…? Advances in Real-Time Rendering course, SIGGRAPH 2016
Shader Example attenuation = 0; group. Atten = 1; for ( int group = 0; group < num. Groups; group++) { group. Atten *= saturate( dot( planes[group][0]. xyz, pos group. Atten *= saturate( dot( planes[group][1]. xyz, pos group. Atten *= saturate( dot( planes[group][2]. xyz, pos group. Atten *= saturate( dot( planes[group][3]. xyz, pos group. Atten *= saturate( dot( planes[group][4]. xyz, pos group. Atten *= saturate( dot( planes[group][5]. xyz, pos if( finished[group] ) { if( subtractive[group] ) attenuation = max( attenuation, group. Atten ); else attenuation *= 1. 0 f - group. Atten; group. Atten = 1; } } return saturate( attenuation ); Advances in Real-Time Rendering course, SIGGRAPH 2016 ) ) ) + + + planes[group][0]. w planes[group][1]. w planes[group][2]. w planes[group][3]. w planes[group][4]. w planes[group][5]. w ); ); );
Why Not K-DOPs? X KDOP – k-sided Discrete Oriented Polytope Pairs of planes or slabs Instead of individual planes Advances in Real-Time Rendering course, SIGGRAPH 2016
Runtime Implementation 3. Sample three ambient cube values depending on normal 4. Blend results between all volumes Advances in Real-Time Rendering course, SIGGRAPH 2016
Challenges Advances in Real-Time Rendering course, SIGGRAPH 2016
Problem: Geo Within Voxels Advances in Real-Time Rendering course, SIGGRAPH 2016
Solution: Smart Centers Advances in Real-Time Rendering course, SIGGRAPH 2016
Invalidate Near Geometry Advances in Real-Time Rendering course, SIGGRAPH 2016
Empty Space Skip Advances in Real-Time Rendering course, SIGGRAPH 2016
Problem: Seams Advances in Real-Time Rendering course, SIGGRAPH 2016
Solution: Volume Smoothing Advances in Real-Time Rendering course, SIGGRAPH 2016
Careful Lighting Artistry Advances in Real-Time Rendering course, SIGGRAPH 2016
Auto Volumes? “Do-Everything Button” Advances in Real-Time Rendering course, SIGGRAPH 2016
Debug Tools Volume Blending And Density Volume Overdraw Per Tile Advances in Real-Time Rendering course, SIGGRAPH 2016
Reflections Advances in Real-Time Rendering course, SIGGRAPH 2016
Reflection Planes [LAGARDE 12] Advances in Real-Time Rendering course, SIGGRAPH 2016
Clever Artistry Advances in Real-Time Rendering course, SIGGRAPH 2016
Reflection Plane Parallax float reflection. Mip = ( 1 – gloss ) * num. Mips; // as things get rougher “fade off” parallax correction // by pushing out intersection planes float min. Dist = saturate( ( reflection. Mip – 2. 5 ) / ( num. Mips – 2. 5 ) ) * 100; distance. To. Plane = max( abs( distance. To. Plane ), min. Dist ); float intersection. Dist = abs( distance. To. Plane / -dot( direction, plane. xyz ) ); Advances in Real-Time Rendering course, SIGGRAPH 2016
Parallax Fade Out Advances in Real-Time Rendering course, SIGGRAPH 2016
Reflection Brightness Correction [LAZAROV 13] Advances in Real-Time Rendering course, SIGGRAPH 2016
Reflection Brightness Correction Advances in Real-Time Rendering course, SIGGRAPH 2016
Brightness Correction float maximum. Spec. Value = max 3( 1. 26816, § Max specular brightness is just a guess based on angle and gloss 9. 13681 * exp 2( 6. 85741 - 2 * mip ) * n. Dot. V, § The light mostly probably came from a certain direction and area * n. Dot. V ); 9. 70809 * exp 2( 7. 085 - mip - 0. 403181 * mip 2) § This defines a cone of a certain size § Actual numbers determined experimentally § We know the diffuse light is a function of what’s in the specular map float adjusted. Max. Spec = diffuse. GILum * maximum. Spec. Value; § Assume a maximum specular brightness that created this diffuse brightness float 3 spec. Lum = luminance( cube. Map. Sample ); § Adjust the sampled specular against theoretical maximum float 3 reflection = cube. Map. Sample * adjusted. Max. Spec / ( adjusted. Max. Spec + speculum ); Advances in Real-Time Rendering course, SIGGRAPH 2016
Pros: 1. As good or better quality than light maps Advances in Real-Time Rendering course, SIGGRAPH 2016
Pros: 2. Less than 2 ms for reflections and GI Advances in Real-Time Rendering course, SIGGRAPH 2016
Pros: 3. Works on all geometry Advances in Real-Time Rendering course, SIGGRAPH 2016
Pros: 4. Less baking time with incremental baking Advances in Real-Time Rendering course, SIGGRAPH 2016
Pros: 5. Baking is done in editor Advances in Real-Time Rendering course, SIGGRAPH 2016
Pros: 6. Moving and changing GI Advances in Real-Time Rendering course, SIGGRAPH 2016
Pros: 7. Loose connection between light and geo Advances in Real-Time Rendering course, SIGGRAPH 2016
Cons: 1. Takes set up time Advances in Real-Time Rendering course, SIGGRAPH 2016
Cons: 2. Training is hard Advances in Real-Time Rendering course, SIGGRAPH 2016
Cons: 3. Either lower resolution or more memory use in game Advances in Real-Time Rendering course, SIGGRAPH 2016
Cons: 4. Need beefy dev machines (48 Gb RAM and 12 Gb VRAM) Advances in Real-Time Rendering course, SIGGRAPH 2016
Cons: 5. Development challenges Advances in Real-Time Rendering course, SIGGRAPH 2016
Special Thanks Treyarch: Dimitar Lazarov – Original Idea Kevin Myers – Baking Code Everyone Else at Treyarch Activision Central Tech: Peter-Pike Sloan – Lots of Math Josiah Manson – Light Bake Features Angelo Pesce – Reflection Solutions Advances in Real-Time Rendering course, SIGGRAPH 2016
References § [DROBOT 13] DROBOT, M. , 2013. Lighting Killzone: Shadow Fall, Digital Dragons § [TATARCHUCK 05] TATARCHUK, N. , 2005. Irradiance Volumes for Games, GDC Europe § [BUEHLER 01] BUEHLER, C. , BOSSE, M. , MCMILLAN, L. , GORTLER, S. , COHEN, M. , 2001. Unstructured Lumigraph Rendering, SIGGRAPH § [MCTAGGART 04] MCTAGGART, G. , 2004. Half-Life Developers Conference 2 / Valve Source Shading, Game § [SILVENNOINEN 15] SILVENNOINEN, A. , TIMONEN, V. , 2015. Multi-Scale in Quantum Break, SIGGRAPH Global Illumination § [LAGARDE 12] LAGARDE, S. , ZANUTTINI, A. , 2012. Local Parallax-corrected Cubemaps, SIGGRAPH § [LAZAROV 13] LAZAROV, D. , 2013. Getting SIGGRAPH Image-based Lighting With More Physical in Call of Duty: Black Ops II, Advances in Real-Time Rendering course, SIGGRAPH 2016
Volumetric Global Illumination at Treyarch.pptx