PRTPerVertex Sample
Microsoft DirectX 9.0 SDK Update (October 2004)

PRTPerVertex Sample


Similar to the PRTPerVertex Sample, this sample demonstrates how to use ID3DXPRTEngine, a precomputed radiance transfer (PRT) simulator that uses low-order spherical harmonics (SH). The sample then demonstrates how to compress the results with clustered principal component analysis (CPCA) and view the compressed results with arbitrary lighting in real time with a vs_1_1 vertex shader.

SHPRTVertex sample screenshot

Path

Source:(SDK root)\Samples\C++\Direct3D\PRTPerVertex
Executable:(SDK root)\Samples\C++\Direct3D\Bin\PRTPerVertex.exe

Why This Sample Is Interesting

PRT using low-order SH basis functions has a number of advantages over typical diffuse (NL) lighting. Area light sources and global effects such as interreflections, soft shadows, self shadowing, and subsurface scattering can be rendered in real time after a precomputed light transport simulation. CPCA allows the results of the simulator to be compressed so the shader does not need as many constants or per-vertex data.

Overview

The basic idea is first to run a PRT simulator offline as part of the art content creation process and save the compressed results for later real-time use. The light transport simulator models global effects that would typically be very difficult to do in real time. The real-time engine evaluates the lights in terms of SH basis functions and sums them up into a single set of SH basis coefficients describing the entire lighting environment. It then uses a vertex shader to arrive at the vertex's diffuse color by combining the compressed simulator results and the lighting environment. Because the offline simulator did the work of computing the interreflections and soft shadows, this technique is visually impressive, efficient, and can be used for real-time lighting.

For more detail about the math behind PRT, CPCA, and SH, see PRT Equations and the following references.

Related Topics



© 2004 Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center.