Original Post
I am getting some strange results trying to blend two textures together. Im am trying to blend one texture that is being loaded from a file and one that is created procedurally. Basically, that one loaded from the file is the base texture and the one created proc. is a light map. I am confused by many things,actually. For the light map, I set the base color to white and the shadows are obviously shades of gray. When I render just the light map, the results are correct. Combining this with the base texture should give me the base texture blended with the elevation shades, but it isnt working correctly. I may be fundementally misunderstanding this. I was going by the example in the DX SDK, but it is blending really funky. The result shows the shades of elevation, but only one color from the base texture is actually being shown. I am no doubt abusing the render state values, but here is code snip: Any help or advice would be appreciated.
//Alpha determines transparency
_device->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
_device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
//Set the light map texture
_device->SetTexture(0,_light_map);
//Set the base texture operation and args
_device->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
_device->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE);
_device->SetTextureStageState(0,D3DTSS_COLORARG2, D3DTA_DIFFUSE);
//Set the base texture
_device->SetTexture(1,_tex);
//Set the blend stage
_device->SetTextureStageState(1,D3DTSS_COLOROP, D3DTOP_MODULATE);
_device->SetTextureStageState(1,D3DTSS_COLORARG1, D3DTA_TEXTURE);
_device->SetTextureStageState(1,D3DTSS_COLORARG2, D3DTA_CURRENT);
//Enable blending
_device->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
hr =_device->DrawIndexedPrimitive(
D3DPT_TRIANGLELIST,
0,
0,
_numVertices,
0,
_numTriangles);
//Disable blending
_device->SetRenderState(D3DRS_ALPHABLENDENABLE,false);