|
Features

Dynamic 2D Imposters:
A Simple, Efficient DirectX 9 Implementation
Taking Imposters Further
There are numerous ways in which the imposter system presented here can be improved.
Viewing Angle Tests
The sample code does not account for changes in orientation of the 3D object. To provide for this, the viewing angle test should be calculated in model-space rather than world-space. Then the test will take into account not only the camera viewing angle and model position, but also the orientation of the model. An even better test is to compare the angles between the vectors from the camera position to the near and far points on the object's bounding box. This test is more expensive but accounts for not only the camera viewing angle, but also the size, position, orientation, and distance of the object. This test is documented in Real-Time Rendering.
Calculating Texture Resolution at Runtime
For the sample code, I selected the imposter texture resolution offline and hard-coded it into the application. A more general purpose imposter system may want to calculate the texture resolution at runtime based on the size and distance of the 3D object and the resolution of the screen. Smaller and more distance objects will use a smaller texture resolution, larger and closer objects will use a larger texture resolution. Real-Time Rendering presents a useful formula for calculating texture resolution.
Supporting arbitrary imposter texture resolutions will help make imposters have better visual quality; however coding support for arbitrary texture resolutions is complicated and the code difficult to optimise. We don't want to make things harder for ourselves so I suggest a simpler approach. Select a number of discrete texture resolutions, for example 32x32, 64x64 and 128x128. Create a render texture for each discrete resolution. At runtime, compute the desired arbitrary resolution and then map this into one of the pre-defined discrete resolutions.
Load Balancing Imposter Regeneration
What happens when numerous imposters, or even worse all imposters, need to be regenerated in a single frame? The simple answer to this is to apply load balancing so that at most only X imposters are regenerated in a single frame. The value for X can be determined empirically or by some combination of machine specification and the amount of load being placed on it by the rest of the game. It is for this reason that, in the sample code, the code that tests for regeneration and the code that performs the regeneration are decoupled. By separating these phases, it is possible to test all imposters every frame to determine if they need regeneration, then, of those that require regeneration, only process X imposters.
Load balancing in this way introduces a problem. It is possible to have imposters that are marked as needing regeneration but are still waiting to be regenerated. At some point imposter error for the imposters that are awaiting regeneration may become too great and the illusion will break down. These errors can be quite obvious and may prevent users from becoming immersed in the scene. These effects are reduced somewhat by sorting imposters based on camera distance and the amount of time since their last regeneration. This allows the closest and oldest imposters to get first chance at regeneration. This does make the problem less noticeable; however there is still a chance that a user may be able see noticeable imposter error. For imposters where the error has become noticeable, the only option is to throw the imposter out completely and revert to the 3D object. This can be implemented as another viewing angle test. When the viewing angle becomes greater than the threshold the imposter alpha-fades back to the 3D object. The 3D object remains in place until the system catches up and has time to regenerate the imposter.
References and Further Reading
Real-Time Rendering: Real-Time Rendering, Tomas Moller and Eric Hanes
“Imposters: Adding Clutter”, in Game Programming Gems 2, Tom Forsyth
"Billboard Clouds for Extreme Model Simplification," Xavier Decorety, Gernot Schauflerz, François Silliony, and Julie Dorseyz
"Multi-layered impostors for accelerated rendering," Xavier Decorety, Gernot Schauflerz, François Silliony, and Julie Dorseyz
"Let There be Clouds! Fast, Realistic Cloud-Rendering in Microsoft Flight Simulator 2004: A Century of Flight", www.gamasutra.com, Niniane Wang
_____________________________________________________
|