I want to render triangles that have a color and lightmap. When I try this the triangle turns out black. Actually, 2 vertices are black and one is red. The red gets brighter when I change
D3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
to
D3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE2X);
and even brighter when I use MODULATE4X. The color I set for each vertex is green.
Here's my code:
//defining the FVF:
#define D3DFVF_TRANSFORMEDLIGHTMAPVERTEX (D3DFVF_XYZRHW | D3DFVF_TEX1 | D3DFVF_DIFFUSE)
//my struct:
struct TransformedLightMapVertex
{
FLOAT x, y, z, rhw, tu, tv;
DWORD color;
};
//rendering code:
D3DDevice->SetFVF(D3DFVF_TRANSFORMEDLIGHTMAPVERTEX);
D3DDevice->SetTexture(0, lightmap);
D3DDevice->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
D3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
D3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
D3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); //when I change this to modulate2x or modulate4x the red gets brighter
D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 1, &LightMapVertices[0], sizeof(TransformedLightMapVertex));
I'm guessing I'm just not using the correct flags in my calls to SetTextureStageState. The texture I'm using for my lightmap is a plain white bitmap.
Proceeding on a brutal rampage is the obvious choice.
[edited by - amish1234 on July 2, 2003 6:33:42 PM]