*** This page is very out of date ***
This feature has been partly implemented by Fossi as a part of the Summer of Code. This page details the integration into 1.2. Ticket is #245
General
Basically the idea is to replace a complex object with a single polygon when the object is far away. To have an accurate representation of that object we can use a procedural texture on which we render the object and then use that procedural texture instead of the real object. For an excellent introduction to how imposters work and to see an example of how this trick is used with awesome results, please see this page on realtime cloud rendering.
Currently only the simplest case is implemented, replacing only one single object. it renders a mesh object on a procedural texture, draws that onto a billboard and updates both when the viewing angle gets to big. This technique is fully automated and doesn't require any special LOD support in mesh object implementations. It is the engine that controls it.
Implementation
The following parts are involved in creating and using Imposters:
- iImposter provides an API to set the various options
- csMeshWrapper implements the above interface
- csImposterMesh represents imposted geometry
- csImposterProcTex represents the texture that is used
- The loader reads options from the XML and set them on the meshes
When the system is used, the developer needs to:
- Set the imposter variables via csMeshWrapper or with the <imposter> tag in the mesh xml syntax from the worldfile
The engine then uses imposters internally to render the mesh:
- On GetRenderMesh() the csMeshWrapper decides whether the Mesh should be replaced with an imposter.
- If this is the case it checks if there is already a csImposterMesh which is used internally by the engine
- If the imposter needs updating, it is placed into a internal list for rendering before the next frame, since rendering to texture destroys the frontbuffer on some hardware.
Improvements:
The current implementation could be improved through a number of features:
- It should also be possible to set this flag on factories so that you can set the flag ones on a tree factory (for example) and all meshes created from that tree will inherit the imposter information automatically. (currently in progress)
- update checking
The current angle checking has a flaw because it combines the anglechecking of the object and the camera. Thus if you move around the mesh, always looking at it's center, the update won't be triggered.(fixed by jorrit)- Animation of the object is only taken into account if it changes it's facing. this could be enhanced with some timebased regeneration for animated objects.
- Lighting conditions change aren't taken into account.
- On update, the old imposter should in most cases be shown instead of the real object. Currently this isn't the case as the readyFlag is set to false on regenerating the imposter. This looks strange and can cause quite some load.
- Imposter cache. When an imposter texture hasn't been used for a while we should reuse it for another imposter. Currently the imposter won't be freed after it has been used until the object is destroyed.
- Calculate the imposter texture size automatically depending on the size of the billboard onscreen.
- Closely linked to the point above, drawing several imposters on one texture would help to speed up the imposters a lot since it saves rendertarget switching which is one of the most expensive operations involved.
- Load balance imposter rerendering. At the moment all updated imposters will be rerendered the next frame. Since all billboards face the camera its likely that they will request to be updated during a short amount of frames causing a noticable bump in the fps. This could be smoothed out.
- In case of objects where factories contain the geometry (like 3D sprites) it would be nice to be able to (optionally) reuse the same procedural texture for different models at once. So the engine needs a way to detect that. This can be useful for forests where the chance is big that many trees can reuse the same imposter texture.
- Imposting a group of objects is slightly more complicated, but it could be used to replace a number of trees with a single imposter in the distance. This feature might be handled by parenting meshes to a null mesh which does the imposting. This is also needed to be able to imposter hierarchical meshes like the example trees in terrainf (tree.lib)
- Imposter portals
