Diffusa ljuskartor (Direct3D 9)
När de belyses av en ljuskälla visar matta ytor diffus ljusreflektion. Ljusstyrkan hos diffust ljus beror på avståndet från ljuskällan och vinkeln mellan ytans normala och ljuskällans riktningsvektor. De diffusa ljuseffekter som simuleras av belysningsberäkningar ger endast allmänna effekter.
Programmet kan simulera mer komplex diffus belysning med texturljuskartor. Gör detta genom att lägga till den diffusa ljuskartan i basstrukturen, som du ser i följande C++-kodexempel.
// 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 );
Relaterade ämnen