Share via


Lighting Equations (Windows Embedded CE 6.0)

1/6/2010

Microsoft® Direct3D® Mobile models illumination with equations that approximate the physics light. The lighting equations utilize the currently enabled lights, the current material parameters, the position of the viewer and the position of the vertex that is to be lit.

These equations describe a camera space implementation of Direct3D Mobile lighting. It is up to the driver implementation to decide which space to do lighting in, so long as the reformulation of the lighting equations produces the same results as the formulation listed in this section.

Notation

The following table shows the variables used in the lighting equations for vertex positions and properties.

Parameter Default Value Type Description

Pe

(0,0,0)

D3DMVECTOR

Camera position in camera space.

Po

N/A

D3DMVECTOR

Position of current model origin (0,0,0,1) in the camera space, which is the fourth row of Mwv.

Mw

Identity

D3DMMATRIX

The current world matrix.

Mv

Identity

D3DMMATRIX

The current view matrix.

Mwv

Identity

D3DMMATRIX

The product of Mv and Mw.

La

(0,0,0,0)

D3DMCOLORVALUE

Global ambient color from the D3DMRS_AMBIENT render state (see D3DMRENDERSTATETYPE).

V

Not applicable

D3DMVECTOR

Vertex position in camera space.

N

Not applicable

D3DMVECTOR

Normalized vertex normal in camera space.

Vcd

0xFFFFFFFF (White)

D3DMCOLORVALUE

Vertex Diffuse Color.

Vcs

0x00000000 (Black)

D3DMCOLORVALUE

Vertex Specular Color.

Atten

(0,0,0,0)

D3DMCOLORVALUE

Light Attenuation.

The following table shows the variables used in the lighting equations for material properties.

Parameter Default Value Type Description

Ma

Not applicable

D3DMCOLORVALUE

Ambient color of the material.

Md

Not applicable

D3DMCOLORVALUE

Diffuse color of the material.

Ms

Not applicable

D3DMCOLORVALUE

Specular color of the material.

Mp

0.0

Float

Specular power exponent of the material.

The following table shows the variables used in the lighting equations for the properties of light i. These variables correspond to the members of the D3DMLIGHT structure passed in calls to IDirect3DMobileDevice::SetLight.

Parameter Default Value Type Description

Lpi

(0,0,0)

D3DMVECTOR

Light position in camera space.

Ldi

(0,0,1)

D3DMVECTOR

Light direction in camera space.

Lri

0.0

float

Light range distance.

Lcai

(0,0,0,0)

D3DMCOLORVALUE

Ambient color.

Lcsi

(0,0,0,0)

D3DMCOLORVALUE

Specular color.

Lci

(1,1,1,0)

D3DMCOLORVALUE

Diffuse color.

LAtt0i

0.0

float

Linear Attenuation Factor.

LAtt1i

0.0

float

Squared Attenuation Factor.

LAtt2i

0.0

float

Exponential Attenuation Factor.

The following list show the mathematical notations used to describe the lighting equations.

  • ||V|| is the length of vector V.
  • V1.V2 is the dot product of vectors V1 and V2.
  • Norm(V) is the vector V, normalized.
  • P1P2 is the vector from point P1 to point P2.
  • M-1 is the inverse of matrix M.
  • MT is the transpose of matrix M.
  • V1/V2 is the vector where each component of V1 is divided by the corresponding component of V2.
  • V1*V2 is the vector where each component of V1 is multiplied by the corresponding component of V2.

The following topics provide additional detail about the lighting equations.

See Also

Concepts

Lighting