Error with cubemap

Started by
-1 comments, last by spong3bob 15 years, 5 months ago
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)

This topic is closed to new replies.

Advertisement