Jump to content
  • Advertisement
Sign in to follow this  
Soul Reaver

[ps1.4] Cubemap not sampling properly

This topic is 2590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
I'd bite the bullet and upgrade to D3D9. The two versions of the API are incredibly similar (it may require no more than an hour or two of work) and this problem will just go away.

Share this post


Link to post
Share on other sites
Unfortunately that's not possible. I didn't develop the engine and it isn't open source, so changing the engine would mean rewriting the whole game as this engine offers much high level functionality.

Share this post


Link to post
Share on other sites
The first thing I would do would be to make sure that the cubemap is getting filled properly. I'm guessing PIX doesn't work with DX8? If not, you could just save out the cubemap as a .DDS and then look at it with DXTex to make sure it looks like what you're expecting.

Share this post


Link to post
Share on other sites

The first thing I would do would be to make sure that the cubemap is getting filled properly. I'm guessing PIX doesn't work with DX8? If not, you could just save out the cubemap as a .DDS and then look at it with DXTex to make sure it looks like what you're expecting.


I tried that and it looks like the cubemap is being filled like expected.
Are there any render or sampler states which could cause my problem? Maybe the engine screws that up without me knowing about it.

Share this post


Link to post
Share on other sites
I suppose border sampling mode could potentially screw you up if your texture coordinates are way off, but that's all I can think of off the top of my head.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!