Platform SDK: DirectX |
Vertices of type D3DVERTEX, D3DLVERTEX, and D3DTLVERTEX cannot contain both color and normal information. Because the default shading mode is Gouraud shading, which depends on both vertex color and normal information, Direct3D did not use vertex color in the lighting calculations.
With the introduction of the flexible vertex format in DirectX 5.0, vertices can contain both vertex color and vertex normal information. By default, Direct3D uses this information when it calculates lighting. If you want your application to disable the use of vertex color lighting information, invoke the IDirect3DDevice7::SetRenderState method and pass D3DRENDERSTATE_COLORVERTEX as the first parameter. Set the second parameter to FALSE to disable vertex color lighting, or TRUE to enable it.
If per-vertex color is enabled, applications can configure the source from which the system retrieves color information for a vertex. The D3DRENDERSTATE_DIFFUSEMATERIALSOURCE, D3DRENDERSTATE_SPECULARMATERIALSOURCE, D3DRENDERSTATE_AMBIENTMATERIALSOURCE, and D3DRENDERSTATE_EMISSIVEMATERIALSOURCE render states control color sources for the diffuse, specular, ambient, and emissive color component sources. Each of these states can be set to members of the D3DMATERIALCOLORSOURCE enumerated type, which defines constants that instruct the system to use the current material, diffuse color, or specular color as the source for the specified color component.
Vertices of type D3DVERTEX, D3DLVERTEX, and D3DTLVERTEX cannot contain both color and normal information. Because the default shading mode is Gouraud shading, which depends on both vertex color and normal information, Direct3D did not use vertex color in the lighting calculations.
When using flexible vertex formats, as opposed to the aforementioned vertex types, vertices can contain both vertex color and vertex normal information. By default, Direct3D uses this information when it calculates lighting. If you want your application to disable the use of vertex color lighting information, invoke the Direct3DDevice7.SetRenderState method and pass D3DRENDERSTATE_COLORVERTEX as the first parameter. Set the second parameter to False to disable vertex color lighting, or True to enable it.
If per-vertex color is enabled, applications can configure the source from which the system retrieves color information for a vertex. The D3DRENDERSTATE_DIFFUSEMATERIALSOURCE, D3DRENDERSTATE_SPECULARMATERIALSOURCE, D3DRENDERSTATE_AMBIENTMATERIALSOURCE, and D3DRENDERSTATE_EMISSIVEMATERIALSOURCE render states control color sources for the diffuse, specular, ambient, and emissive color component sources. Each of these states can be set to members of the CONST_D3DMATERIALCOLORSOURCE enumerated type, which defines constants that instruct the system to use the current material, diffuse color, or specular color as the source for the specified color component.