漫射光贴图 (Direct3D 9)
当由光源照亮时,哑光表面会显示漫射光反射。 漫反射光的亮度取决于与光源的距离以及表面法线与光源方向矢量之间的角度。 光线计算模拟的漫射光线效果仅会产生常规效果。
你的应用程序可以使用纹理光线映射模拟更复杂的漫射光线。 为此,请将漫射光贴图添加到基本纹理,如以下 C++ 代码示例所示。
// This example assumes that d3dDevice is a valid pointer to an
// IDirect3DDevice9 interface.
// lptexBaseTexture is a valid pointer to a texture.
// lptexDiffuseLightMap is a valid pointer to a texture that contains
// RGB diffuse light map data.
// Set the base texture.
d3dDevice->SetTexture(0,lptexBaseTexture );
// Set the base texture operation and args.
d3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,
D3DTOP_MODULATE );
d3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE );
d3dDevice->SetTextureStageState(0,D3DTSS_COLORARG2, D3DTA_DIFFUSE );
// Set the diffuse light map.
d3dDevice->SetTexture(1,lptexDiffuseLightMap );
// Set the blend stage.
d3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE );
d3dDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
d3dDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT );
相关主题