Jump to content
  • Advertisement
Sign in to follow this  
spong3bob

Error with cubemap

This topic is 3554 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! for my water i am creating an environmental cubemap.. it works but not 100% as there are little wholes in my cubemap.. ---------------------------------------------------------------------------
LPDIRECT3DSURFACE9 pBackBuffer, pZBuffer;
		D3DXMATRIX matProjSave, matViewSave;
		Device->GetTransform(D3DTS_VIEW,       &matViewSave) ;
		Device->GetTransform(D3DTS_PROJECTION, &matProjSave);

		Device->GetRenderTarget(0,&pBackBuffer);
		Device->GetDepthStencilSurface(&pZBuffer);

		D3DXMATRIX matProj;
		D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/2, 1.0f, 0.5f, 1000.0f);
		Device->SetTransform(D3DTS_PROJECTION, &matProj);

		// Loop through the six faces of the cube map
		for(uint i=0; i<6; i++)
		{
			// Standard view that will be overridden below
			Point vEnvEyePt = p;
			Point vLookatPt, vUpVec;

			switch(i)
			{
				case D3DCUBEMAP_FACE_POSITIVE_X:
					vLookatPt = p+Point(1.0f, 0.0f, 0.0f);
					vUpVec    = Point(0.0f, 1.0f, 0.0f);
					break;
				case D3DCUBEMAP_FACE_NEGATIVE_X:
					vLookatPt = p+Point(-1.0f, 0.0f, 0.0f);
					vUpVec    = Point( 0.0f, 1.0f, 0.0f);
					break;
				case D3DCUBEMAP_FACE_POSITIVE_Y:
					vLookatPt = p+Point(0.0f, 1.0f, 0.0f);
					vUpVec    = Point(0.0f, 0.0f,-1.0f);
					break;
				case D3DCUBEMAP_FACE_NEGATIVE_Y:
					vLookatPt = p+Point(0.0f,-1.0f, 0.0f);
					vUpVec    = Point(0.0f, 0.0f, 1.0f);
					break;
				case D3DCUBEMAP_FACE_POSITIVE_Z:
					vLookatPt = p+Point( 0.0f, 0.0f, 1.0f);
					vUpVec    = Point( 0.0f, 1.0f, 0.0f);
					break;
				case D3DCUBEMAP_FACE_NEGATIVE_Z:
					vLookatPt = p+Point(0.0f, 0.0f,-1.0f);
					vUpVec    = Point(0.0f, 1.0f, 0.0f);
					break;
			}

			D3DXMATRIX matView;
			D3DXMatrixLookAtLH(&matView, &vEnvEyePt, &vLookatPt, &vUpVec);
			Device->SetTransform(D3DTS_VIEW, &matView);

			LPDIRECT3DSURFACE9 pFace;
			CubeMap->GetCubeMapSurface((D3DCUBEMAP_FACES)i, 0, &pFace);
			Device->SetRenderTarget (0,pFace);
			Device->SetDepthStencilSurface(pZBuffer);
			Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,0,255), 1.0f, 0);
			Device->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,0,255), 1.0f, 0);
			pFace->Release();
			Device->BeginScene();
			Camera* cam = new Camera(vEnvEyePt, vLookatPt);
			if (terrain)
			{
				//terrain->Render(Device, cam);
			}
			if(sky)
			{
				sky->Render(Device, cam);
			}
			Device->EndScene();
-------------------------------------------------------------------------- thats how i create my cubemap... http://spong3bob.sp.funpic.de/error.jpg here you can see what i mean (i clear it with pink color :D) i really got no idea what could be the problem (if you want to see the shader of my water or of the sky-rendering plz tell me)

Share this post


Link to post
Share on other sites
Advertisement
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!