Ambient Lighting = Ca*[Ga + sum(Atti*Spoti*Lai)]
Where:
| Parameter | Default value | Type | Description |
|---|---|---|---|
| Ca | (0,0,0,0) | D3DCOLORVALUE | Material ambient color |
| Ga | (0,0,0,0) | D3DCOLORVALUE | Global ambient color |
| Atteni | (0,0,0,0) | D3DCOLORVALUE | Light attenuation of the ith light. See Attenuation and Spotlight Factor (Direct3D 9). |
| Spoti | (0,0,0,0) | D3DVECTOR | Spotlight factor of the ith light. See Attenuation and Spotlight Factor (Direct3D 9). |
| sum | N/A | N/A | Sum of the ambient light |
| Lai | (0,0,0,0) | D3DVECTOR | Light ambient color of the ith light |
Diffuse Lighting = sum[Cd*Ld*(N.Ldir)*Atten*Spot]
| Parameter | Default value | Type | Description |
|---|---|---|---|
| sum | N/A | N/A | Summation of each light's diffuse component. |
| Cd | (0,0,0,0) | D3DCOLORVALUE | Diffuse color. |
| Ld | (0,0,0,0) | D3DCOLORVALUE | Light diffuse color. |
| N | N/A | D3DVECTOR | Vertex normal |
| Ldir | N/A | D3DVECTOR | Direction vector from object vertex to the light. |
| Atten | N/A | FLOAT | Light attenuation. See Attenuation and Spotlight Factor (Direct3D 9). |
| Spot | N/A | FLOAT | Spotlight factor. See Attenuation and Spotlight Factor (Direct3D 9). |
| Specular Lighting = Cs * sum[Ls * (N • H)P * Atten * Spot] |
The following table identifies the variables, their types, and their ranges.
| Parameter | Default value | Type | Description |
|---|---|---|---|
| Cs | (0,0,0,0) | D3DCOLORVALUE | Specular color. |
| sum | N/A | N/A | Summation of each light's specular component. |
| N | N/A | D3DVECTOR | Vertex normal. |
| H | N/A | D3DVECTOR | Half way vector. See the section on the halfway vector. |
| P | 0.0 | FLOAT | Specular reflection power. Range is 0 to +infinity |
| Ls | (0,0,0,0) | D3DCOLORVALUE | Light specular color. |
| Atten | N/A | FLOAT | Light attenuation value. See Attenuation and Spotlight Factor (Direct3D 9). |
| Spot | N/A | FLOAT | Spotlight factor. See Attenuation and Spotlight Factor (Direct3D 9). |
|
float4x4 matViewProjection; struct VS_INPUT struct VS_OUTPUT float4 PointLighting(float3 position, float3 normal VS_OUTPUT vs_main( VS_INPUT Input ) Output.Position = mul( Input.Position, matViewProjection ); return( Output ); |
本文详细介绍了Direct3D9中使用的光照模型,包括环境光、漫反射光和镜面反射光的计算公式及其参数说明。通过具体实例展示了如何在顶点着色器中实现点光源照明效果。
3377

被折叠的 条评论
为什么被折叠?



