Original Post
Hi,
currently I'm trying to implement bump mapping in a topdown game of mine.
Unfortunately the engine of this game is based on DirectX 8.1 so I'm forced to use ps.1.4 & vs.1.1 as shader model.
As you may or may not know ps.1.4 doesn't have functions like sqrt() or pow() so it's a real pain in the ass to implement the specular component of the blinn phong lighting model. To avoid these restrictions I decided to use a renormalization cubemap which is then used to renormalize the half vector which is passed from the vertex shader to the pixel shader.
The problem is that sampling the cubemap returns always black, thus (0, 0, 0, a). I create my cubemap on the fly as follows:
[source lang=cpp]
// Create the cube map and fill it
pDevice->CreateCubeTexture(512, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pNormalizationCubemap);
D3DXFillCubeTexture(m_pNormalizationCubemap, FillCubeMap, NULL);
// Fill callback
void FillCubeMap(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData)
{
// For testing purposes I set every texel to red
pOut->x = 1.0f; //pTexCoord->x * 0.5f + 0.5f;
pOut->y = 0.0f; //pTexCoord->y * 0.5f + 0.5f;
pOut->z = 0.0f //pTexCoord->z * 0.5f + 0.5f;
pOut->w = 0;
}
[/source]
Both functions return S_OK, I bind this texture to texture stage 2 with IDirect3DDevice8::SetTexture() which also returns S_OK and let the pixel shader sample it as follows:
[source]
texld r2, t2
mov r0, r2
[/source]
The primitives should now be rendered in bright red but instead everything is black, which means that the sampling returned black. But why?
I really have no idea what I'm doing wrong.
currently I'm trying to implement bump mapping in a topdown game of mine.
Unfortunately the engine of this game is based on DirectX 8.1 so I'm forced to use ps.1.4 & vs.1.1 as shader model.
As you may or may not know ps.1.4 doesn't have functions like sqrt() or pow() so it's a real pain in the ass to implement the specular component of the blinn phong lighting model. To avoid these restrictions I decided to use a renormalization cubemap which is then used to renormalize the half vector which is passed from the vertex shader to the pixel shader.
The problem is that sampling the cubemap returns always black, thus (0, 0, 0, a). I create my cubemap on the fly as follows:
[source lang=cpp]
// Create the cube map and fill it
pDevice->CreateCubeTexture(512, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &m_pNormalizationCubemap);
D3DXFillCubeTexture(m_pNormalizationCubemap, FillCubeMap, NULL);
// Fill callback
void FillCubeMap(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData)
{
// For testing purposes I set every texel to red
pOut->x = 1.0f; //pTexCoord->x * 0.5f + 0.5f;
pOut->y = 0.0f; //pTexCoord->y * 0.5f + 0.5f;
pOut->z = 0.0f //pTexCoord->z * 0.5f + 0.5f;
pOut->w = 0;
}
[/source]
Both functions return S_OK, I bind this texture to texture stage 2 with IDirect3DDevice8::SetTexture() which also returns S_OK and let the pixel shader sample it as follows:
[source]
texld r2, t2
mov r0, r2
[/source]
The primitives should now be rendered in bright red but instead everything is black, which means that the sampling returned black. But why?
I really have no idea what I'm doing wrong.