Sign in to follow this  
JAIHANUMAN

Render an Mesh into an Texture

Recommended Posts

I have some complex objects in my Environment(say complex tree)......when the user moves far away fom the object.....i doesnt want to render that object,instead i am planning to Render that complex object into an Texture and render the texture and display it.........i have no idea how to proceed....so can anyone suggest me how to proceed.....

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
the keywords your looking for is "Imposter"

An imposter is when you render a mesh to a texture to save bandwidth.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
the keywords your looking for is "Imposter"

An imposter is when you render a mesh to a texture to save bandwidth.

Share this post


Link to post
Share on other sites
Well things you need to do is :
- Create texture
- Fetch the textures surface
- Set this surface as rendering target when you need to render your things to texture, remember to take a copy of the old renderer target.
- Then set the old renderer target back.
- Render a fullscreen quad with this texture in to the right place (at background).
- Render the rest of your scene as it is.

Share this post


Link to post
Share on other sites
To render to a texture you'd want to do something like the following:

LPDIRECT3DSURFACE9 lpD3DsOrig;
m_lpD3DDevice->GetRenderTarget(0, &lpD3DsOrig); // Save the original render target
m_lpD3DDevice->SetRenderTarget(0, lpD3DsRenderTarget); // Set renderer to our surface
// Render your mesh
m_lpD3DDevice->SetRenderTarget(0, lpD3DsOrig); // Restore the original render target

Share this post


Link to post
Share on other sites
Decide what texture you wish to use (one way is to run your program, take a screenshot of your mesh, and use that). Once you've got your image, remember to specify the transparent part of the image for loading purposes, either by specifying alpha within the image, or using one colour and then specifying that colour as the colour key when loading.

Then create a quad, set the texture/image to it, and use the billbaord technique so the quad is always facing the camera. With the transparent parts of the texture specified, it looks pretty good. Create a quad for every mesh that gets to far away from the camera, and you should have a result.

You can then use some kind of alpha blending to fade the texture in/out for an extra effect as it gets even further away from the camera.

If you want the texture to animate, then you should be able to use the same method, but with extra textures obviously.

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