Original Post
Joined: 23 Sep 2006 Posts: 1 PostPosted: Sat Sep 23, 2006 10:00 pm Post subject: Bump Mapping Reply with quote After about the last 4 hours of trying to understand bump maping im getting nothing but a black vertexbuffer. this is in direct x if anyone knows it. setting up my light vector is as follows
dwTFactor = VectorToRGB(&light);
m_Graphics.GetDeviceCOM()->SetRenderState(D3DRS_TEXTUREFACTOR, dwTFactor);
m_Graphics.GetDeviceCOM()->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3);
m_Graphics.GetDeviceCOM()->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_Graphics.GetDeviceCOM()->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
m_Graphics.GetDeviceCOM()->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_Graphics.GetDeviceCOM()->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
m_Graphics.GetDeviceCOM()->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_Graphics.SetTexture(0, &tBump);
m_Graphics.SetTexture(1, &tTex);
DWORD VectorToRGB(D3DXVECTOR3* NormalVector)
{
DWORD dwR = (DWORD) (127 * NormalVector->x +128);
DWORD dwG = (DWORD) (127 * NormalVector->y +128);
DWORD dwB = (DWORD) (127 * NormalVector->z +128);
return (DWORD) (0xff000000 + (dwR << 16) + (dwG << 8) + dwB);
}
DWORD dwTFactor;
D3DXVECTOR3 light(0.0f, 0.0f, 1.0f);