Original Post
recently implemented a water effect using a shader, and rendering a reflection map to a texture. my frame rate is fine when first running, but then dips after a while. I removed the water but kept in the part where it renders to a texture and the problem persists so I'm thinking its to do with that.
Heres my method
The texture im rendering to is 256x256. I am rendering a fairly big scene, a terrain 256x256 verts, but the framerate is absolutely fine without running the above method. and even when it is running the method it starts off fine. I dunno what im doing wrong. can anyone help? cheers
Heres my method
D3DXVECTOR3 oldCamPos= currentCamera->GetPosition();
float oldCamXRotation = currentCamera->GetRotation().x;
currentCamera->SetRotation(D3DXVECTOR3( - oldCamXRotation, currentCamera->GetRotation().y,currentCamera->GetRotation().x));
float newCamHeight = oldCamPos.y -((oldCamPos.y-(8.9*5))*2);
currentCamera->SetPosition(D3DXVECTOR3(oldCamPos.x,newCamHeight,oldCamPos.z));
//################################## RENDERING TO TEXTURE
//set render target
device->SetRenderTarget(0,pRenderSurface);
//############################ CLEAR
device->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
//################//now draw scene
device->BeginScene();
device->SetTransform( D3DTS_VIEW, ¤tCamera->GetViewMatrix() );
device->SetTransform( D3DTS_PROJECTION, &matProjection );
//render skydome with no zbuffer
device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
skydome->Render(device);
//re enable z buffer to draw everything else.
//device->SetRenderState(D3DRS_ZWRITEENABLE , D3DZB_TRUE);
device->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
//##########CLIPPING
D3DXMATRIXA16 matrix = myTerrain->GetWorldMatrix() * currentCamera->GetViewMatrix()* matProjection ;
D3DXMatrixInverse(&matrix, NULL, &matrix); // second parameter is an out parameter for the determinant
D3DXMatrixTranspose(&matrix, &matrix);
D3DXPLANE viewSpacePlane;
D3DXPlaneTransform(&viewSpacePlane, &plane, &matrix);
planearray[0] = viewSpacePlane.a;
planearray[1] = viewSpacePlane.b;
planearray[2] = viewSpacePlane.c;
planearray[3] = viewSpacePlane.d;
device->SetClipPlane(0, planearray);
device->SetRenderState( D3DRS_CLIPPLANEENABLE, D3DCLIPPLANE0 );
//draw terrain
myTerrain->Render(device);
device->EndScene();
currentCamera->SetPosition(oldCamPos);
currentCamera->SetRotation(D3DXVECTOR3(oldCamXRotation,currentCamera->GetRotation().y,currentCamera->GetRotation().x));
The texture im rendering to is 256x256. I am rendering a fairly big scene, a terrain 256x256 verts, but the framerate is absolutely fine without running the above method. and even when it is running the method it starts off fine. I dunno what im doing wrong. can anyone help? cheers