ID3DXPRTEngine::ComputeDirectLightingSHGPU method

Uses the GPU to compute the direct lighting contribution to 3D objects where the source radiance is represented by a spherical harmonic (SH) approximation. Computing the lighting on the GPU will generally be much faster than on the CPU.

Syntax

HRESULT ComputeDirectLightingSHGPU(
  [in]      LPDIRECT3DDEVICE9 pDevice,
  [in]      UINT              Flags,
  [in]      UINT              Order,
  [in]      FLOAT             ZBias,
  [in]      FLOAT             ZAngleBias,
  [in, out] LPD3DXPRTBUFFER   pDataOut
);

Parameters

pDevice [in]

Type: LPDIRECT3DDEVICE9

Pointer to the IDirect3DDevice9 device object used to run the simulation on the GPU. The device must support ps_2_0 pixel shaders.

Note

Callback functions should not use the IDirect3DDevice9 device object used by the GPU simulator.

 

Flags [in]

Type: UINT

GPU simulation parameter that defines the resolution of the shadow z-buffer. Should be set to one of the constant values from D3DXSHGPUSIMOPT. To specifiy higher precision simulation, the D3DXSHGPUSIMOPT_HIGHQUALITY value may be combined with one of the D3DXSHGPUSIMOPT_SHADOWRESxxx values.

Order [in]

Type: UINT

Order of the SH evaluation. Must be in the range of D3DXSH_MINORDER to D3DXSH_MAXORDER, inclusive. The evaluation generates OrderĀ² coefficients. The degree of the evaluation is Order - 1.

ZBias [in]

Type: FLOAT

Bias in the normal direction.

ZAngleBias [in]

Type: FLOAT

Bias in the normal direction, scaled by one minus the cosine of the angle with the light ray.

pDataOut [in, out]

Type: LPD3DXPRTBUFFER

Pointer to an ID3DXPRTBuffer object. This buffer must have the proper number of color channels allocated for the simulation.

Return value

Type: HRESULT

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, E_OUTOFMEMORY.

Remarks

In this method, the albedo is not multiplied by the light signal, and only incoming light is integrated in the simulator. By not multiplying the albedo, you can model albedo variation at a finer scale than the source radiance, thereby yielding more accurate results from compression.

Call MultiplyAlbedo to multiply each precomputed radiance transfer (PRT) vector by the albedo.

Requirements

Requirement Value
Header
D3DX9Mesh.h
Library
D3dx9.lib

See also

ID3DXPRTEngine