A problem in landscaping display is the requirement to populate the landscape with content, not just the terrain surface. This a problem of managing exponential visibility (without recourse to fogging) and can only be properly realised with a combination of
Billboards are the easiest solution to projecting the image of thousands of similarly objects in 3D space, so long as you don’t get close enough to interact with the supposedly 3D object, and if that 3D object is symmetrical around its vertical axis.
In terms of tutorial Riemers is very accessible and presents a good visualisation of the technique.
However Riemer’s example soaks CPU as it requires a separate render call for each billboard, passing a CPU calculated dot product for the rotation angle between the camera and each billboard and making a separate call for each billboard.
A better option is to pre-calculate the four vectors of the billboard quad as a single point in space, and for a geographical area, compound all the billboard centre point vectors into a single VertexBuffer; and within the Vertex Shader you will transform each vertex to orient it to the camera.
You can then group all the billboards in a single geographical area into a single VertexBuffer which can then be rendered in a single call, trading vertex count for call count (a modern GPU can handle a lot of vertexes in a single call).
A bad billboard
Simple billboard of a cottage (converted from a Sketchup 8 Collada Export file). This looks OK from a distance, but suffers from
- Non-symmetrical vertical axis, meaning that it will really obviously change shape when it flips into 3D mesh mode.
- The viewer sees only one face of a complex object – which again will have a horrible transition when it moves to become a 3D mesh.
A good billboard
This tree is a much better example being almost symmetrical around the vertical axis, and its unlikely an observer would be able to tell the facing from afar.
Imposters are a midway house between Meshes and Billboards. These use the concept of a texture atlas of rotated views of a Mesh, rendered at compile time, and sampled at render time to provide a camera view specific Billboard based on the dot product of the camera to model world location.
I use an 8×8 texture up to 2048×2048 pixels to provide the widest range of possible angles.
An acceptable imposter
Although these trees look very similar when rotated and sampled onto a texture atlas, the benefits are more obvious with this cottage.
A nice imposter
Which not only has a rich variety of faces, but strikingly different colouration which would be very obvious if treated as a billboard.
Producing the texture atlas is a matter of introducing a step within your asset pipeline which renders your Mesh model to a Texture and rotates the mesh the required rotation, taking another snapshot at appropriate angles, merging them all onto a single large texture sheet.
These are the relatively easy part – a .X or other file containing a full 3D description of the triangle mesh required to render your object in 3D, including textures, bump maps etc. The problem with these is that they are large (typically 2k->50k triangles per object) and even if you share the same geometry, and therefore the same assets, for multiple instances of the same object, you still have to render it multiple times, and those draw calls soon add up to an unsustainable amount.
Close-in however, meshes are vital to providing a realistic impression.
The one important capability that a mesh gives you; is the ability to look down on your model – neither billboards or imposters are particularly good at that trick, even if they only ever orient towards the camera in the X,Z axis.
For all the models in my 3D landscape I manage the display of them according to distance from camera, transitioning between Billboard (where appropriate to the model) to Imposter and then to Mesh. I blend the transition so it overlaps, and hopefully hides any obvious transition effects.
This view shows all three techniques in effect; the grass are billboards, the distant tress are imposters and the close trees are meshes. The colour difference between the imposters and the trees is something I’m working on.
… to a full mesh
… though I’m not sure I’d want to stay the night…