Help! D3DTA_DIFFUSE died!

Started by
9 comments, last by Nypyren 21 years, 7 months ago
After I messed around a bit more, I changed EMISSIVE back to DIFFUSEMATERIALSOURCE, and actually created a pure-white material like the MSDN tutorial for lighting shows... and everything works great.

I hate it when they don't have a "things you need to do in 8.1 that you didn't need in 8.0" section in there...


So anyway, everything seems to be working great.. lighting and all.

This is what I'm using *finally*


D3DLIGHT8 light;
ZeroMemory( &light, sizeof(D3DLIGHT8) );
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse = color;
light.Range = 1000.0f;
light.Direction = dir;
light.Attenuation0 = 1.0f;

device->SetLight(l, &light);
device->LightEnable(l, TRUE);
device->SetRenderState(D3DRS_LIGHTING, TRUE);
device->SetRenderState(D3DRS_AMBIENT, 0x00000000);


D3DMATERIAL8 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
mtrl.Diffuse.b = mtrl.Ambient.b = 1.0f;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
device->SetMaterial( &mtrl );


device->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1 );

device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

device->SetRenderState(D3DRS_TEXTUREFACTOR, 0xFFFFFFFF); // or whatever color to modulate the entire texture with

device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);

device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
device->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
device->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TFACTOR);

device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);

device->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
device->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
device->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);


device->SetRenderState(D3DRS_ZENABLE, true);
device->SetRenderState(D3DRS_NORMALIZENORMALS, true);


[edited by - Nypyren on September 3, 2002 2:27:37 PM]

This topic is closed to new replies.

Advertisement