Lighting Equations (Windows CE 5.0)
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 vectorV
.V
1.V
2 is the dot product of vectorsV
1 andV
2.Norm(V)
is the vectorV
, normalized.P
1P
2 is the vector from pointP
1 to pointP
2.M-1
is the inverse of matrixM
.MT
is the transpose of matrixM
.V1/V2
is the vector where each component ofV1
is divided by the corresponding component ofV2
.V1*V2
is the vector where each component ofV1
is multiplied by the corresponding component ofV2
.
The following topics provide additional detail about the lighting equations.
See Also
Send Feedback on this topic to the authors