**Part 4: Algorithm Explanation** [Dynamic Diffuse Global Illumination](index.html) 2019 April 16 Updated 2019 May 23
[ <== Previous Page: DDGI Overview](overview.html)Coming Soon: Implementation Details
This part of the DDGI article explains the algorithm in detail for industry programmers, researchers, and scientists seeking to implement it. This focuses on the mathematical concepts and opportunities for making your own design decisions and potential improvements for a minimal prototype implementation. The following part gives a checklist for steps for a full production DDGI implementation when integrating into an existing rendering system, with recommendations for the best practices we use with NVIDIA partners. ## Sampling DDGI supports efficient sampling of the irradiance field at _any_ point $X$ in a scene relative to a surface normal $\n$ by a single shader function[^shader]: `Color3 sampleDDGI(Point3 X, Vector3 n, DDGIVolume ddgi);` The `sampleDDGI` function can be called from anywhere. For example, a deferred-shading compute or full-screen pixel shader, rasterization forward shader, volumetric ray marcher, texture-space shading routine, or ray hit shader. Because DDGI encodes incoming light, shading simply involes modulating the sampled result by the scattering function (BSDF). Combined with a glossy term computed from an environment-map or by ray tracing, the net _outgoing_ light ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GLSL Radiance3 L = lerp(glossyLight, lambertianReflectivity * sampleDDGI(X, n, ddgi), fresnel); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [^shader]: I use macros to rename `vec3`/`float3` shader types to be self-documenting, so imagine `#define Color3 float3` and so on in some header file. All of the support code for our reference implementation is directly available in the [G3D Innovation Engine](https://casual-effects.com). ## Radial Gaussian Distance DDGI contains three terms that manage the visibility
[ <== Previous Page: DDGI Overview](overview.html)Coming Soon: Implementation Details
* * * * I wrote this blog article in collaboration with my colleagues [Zander Majercik](https://research.nvidia.com/person/zander-majercik) and [Adam Marrs](http://www.visualextract.com/) at NVIDIA.