Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Cubic Environ Mapping - Auto Texture Magic?

This topic is 5864 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

I''m trying to do a simple program using Cubic Environmental Mapping on a sphere and everything works well. However, one strange thing I notice is that if I do NOTHING but create the NORMAL CubicTexture as follows: m_pDevice->CreateCubeTexture(256,1,D3DUSAGE_RENDERTARGET, D3DFMT_R8G8B8, D3DPOOL_DEFAULT, &m_pCubeMap); and then DIRECTLY use this texture WITHOUT UPDATING OF ANY KIND to plug onto the Sphere as normal: m_pDevice->SetTexure->(0,&pCubeMap); I get a texture on the sphere representing ALL of my the INITIAL MESH objects in my world, with perfect cubic mapping. THIS IS CRAZY!! I don''t understand how this can happen when I NEVER touched the m_pCubeMap pointer from it''s initiation until I used it as a texture in the SetTexture() function. Furthermore, the cubic texture on the sphere is static (doesn''t reflect moving objects) and ONLY includes non-skin MESHES created with the D3DX utilities, not any triangles loaded directly, such as my parsed MD2 files. This even happens if I initiate it BEFORE loading any meshes. What gives with this? Does the CreateCubicTexture() function automatically take a static picture of all meshes at creation time at position 0,0,0 and fill in the texture? Is this happening to others? Tony

Share this post

Link to post
Share on other sites
Upon further investigation, this looks like something to do with clearing the stencil buffer I set up, but I can''t seem to figure it out. When I first run the program when logging on, the textue doesn''t appear. If I render to the cubemap texture and turn it back off, it still appears in the last frame of reference that I had my camera pointed towards. I''m clearing the Z and stencil buffers every frame, so I''m not sure what''s wrong.

******I set up my Cube Map, as follows....*****

m_pd3dDevice->CreateCubeTexture( 128, 1, D3DUSAGE_RENDERTARGET, m_d3dsdBackBuffer.Format, D3DPOOL_DEFAULT, &m_pCubeMap ) ;

And stencil surface......

m_pd3dDevice->CreateDepthStencilSurface(CUBBEMAP_RESOLUTION, CUBEMAP_RESOLUTION, D3DFMT_D16, D3DMULTISAMPLE_NONE, &m_pCubeFaceZBuffer) ;

*******Then set up the cubemap......******

LPDIRECT3DSURFACE8 pBackBuffer, pZBuffer;
m_pd3dDevice->GetRenderTarget( &pBackBuffer );
m_pd3dDevice->GetDepthStencilSurface( &pZBuffer );

for( DWORD i=0; i<6; i++ )
matView = D3DUtil_GetCubeMapViewMatrix( (D3DCUBEMAP_FACES)i );
D3DXMatrixMultiply( &matView, &matViewDir, &matView );
m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

m_pCubeMap->GetCubeMapSurface( (D3DCUBEMAP_FACES)i, 0, &m_pCubeMapFace );
m_pd3dDevice->SetRenderTarget( pCubeMapFace, m_pCubeFaceZBuffer);

m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, 0xffffffff, 1.0f, 0L );



m_pd3dDevice->SetRenderTarget( pBackBuffer, pZBuffer );

*****Then when I REALLY render to the screen, I clear the buffers again....******

m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, 0xffffffff, 1.0f, 0L );

Can anyone see what I''m doing wrong?


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!