Update textures using SetRenderTarget
I'm working on the terrain rendering technique which involves displacement mapping. I have a couple of textures that are, logically, the mip-map of the terrain. Now, I have to update them all, from the biggest to the smallest, and to do so I do the following:
device->GetRenderTarget(0, &oldRT);
device->GetDepthStencilSurface(&oldDSS);
device->BeginScene();
for (i = 0; i < levels - 1; i++)
{
//
// Set the current texture as displacement map
device->SetTexture(D3DVERTEXSAMPLER0, level.displacement);
//
// Set the next texture as render target and the depth surface as NULL
device->SetRenderTarget(0, level.displacement);
device->SetDepthStencilSurface(NULL);
//
// Render a 2D quad that updates the texture (no Clear)
}
device->EndScene();
device->SetRenderTarget(0, oldRT);
device->SetDepthStencilSurface(oldDSS);
This is achieved in the Update function that is called before Render function.
However, when I move through the world (so the Update is called), the terrain disappears until I stop moving; then the terrain appears again, like nothing had happened. I don't know why this happens, can anyone help me? My updating textures are 32bit floating point if this is of any importance.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement