Sign in to follow this  
djalexd

Update textures using SetRenderTarget

Recommended Posts

djalexd    127
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[i].displacement); // // Set the next texture as render target and the depth surface as NULL device->SetRenderTarget(0, level[i + 1].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.

Share this post


Link to post
Share on other sites
djalexd    127
I've moved that code before the rendering, so now I only have one BeginScene / EndScene, but I still encounter that problem. Can anybody help me?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this