Expand Minimize

D3DXSHEvalHemisphereLight function

Evaluates a light that is a linear interpolation between two colors over the sphere.

Syntax


HRESULT D3DXSHEvalHemisphereLight(
  _In_  UINT Order,
  _In_  const D3DXVECTOR3 *pDir,
  _In_  D3DXCOLOR Top,
  _In_  D3DXCOLOR Bottom,
  _In_  FLOAT *pROut,
  _In_  FLOAT *pGOut,
  _In_  FLOAT *pBOut
);

Parameters

Order [in]

Type: UINT

Order of the spherical harmonic (SH) evaluation. Must be in the range of D3DXSH_MINORDER to D3DXSH_MAXORDER, inclusive. The evaluation generates Order2 coefficients. The degree of the evaluation is Order - 1.

pDir [in]

Type: const D3DXVECTOR3*

Pointer to the (x, y, z) hemisphere axis direction vector in which to evaluate the SH basis functions. See Remarks.

Top [in]

Type: D3DXCOLOR

The sky color.

Bottom [in]

Type: D3DXCOLOR

The ground color.

pROut [in]

Type: FLOAT*

Pointer to the output SH vector for the red component.

pGOut [in]

Type: FLOAT*

Pointer to the output SH vector for the green component.

pBOut [in]

Type: FLOAT*

Pointer to the output SH vector for the blue component.

Return value

Type: HRESULT

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be: D3DERR_INVALIDCALL.

Remarks

The interpolation is done linearly between the two points, not over the surface of the sphere (that is, if the axis was (0,0,1) it is linear in Z, not in the azimuthal angle). The resulting spherical lighting function is normalized so that a point on a perfectly diffuse surface with no shadowing and a normal pointed in the direction pDir would result in exit radiance with a value of 1 (if the top color was white and the bottom color was black). This is a very simple model where Top represents the intensity of the "sky" and Bottom represents the intensity of the "ground."

On the sphere with unit radius, as shown in the following illustration, direction can be specified simply with theta, the angle about the z-axis in the right-handed direction, and phi, the angle from z.

Illustration of a sphere with unit radius

The following equations show the relationship between Cartesian (x, y, z) and spherical (theta, phi) coordinates on the unit sphere. The angle theta varies over the range of 0 to 2 pi, while phi varies from 0 to pi.

Equations of the relationship between Cartesian and spherical coordinates

Requirements

Header

D3dx9math.h

Library

D3dx9.lib

See also

Precomputed Radiance Transfer (Direct3D 9)

 

 

Community Additions

ADD
Show:
© 2014 Microsoft