Techniqueintro
Billboard
Also called billboarding.
Draw a textured quad that is rotated each frame to face the camera, used for particles, foliage and distant objects.
A billboard is a flat quad with a texture that is turned toward the camera each frame, so that a picture of a tree, a puff of smoke or a light glow looks the same from every side. The template has two holes, the rule that gives the facing direction and the rule that gives the up direction, and the common kinds of billboards differ only in these two rules. An impostor is a billboard whose texture is rendered from the real object at run time and refreshed when the view changes; a plain billboard uses a fixed texture made in advance.
In plain words
Cut a picture of a tree out of paper and hold it up in front of a friend. If you turn it so that it always faces them, they see a tree from wherever they stand, though there is only one flat sheet.
A billboard does the same on the screen. Each frame the program turns a small rectangle with a picture on it toward the camera and draws it. It is cheap, because the rectangle has only two triangles.
The rules for the turn decide what it looks like. A puff of smoke can turn in every direction. A tree must stay upright and only turn around its trunk, or it would tip over when the camera looks down at it.
When it applies
- The object looks about the same from all directions around some axis or point: smoke, fire, sparks, a glow around a light, a distant tree, or a text label.
- It covers few pixels, or it is fuzzy, so the lack of depth and of parallax inside it does not show.
- Many copies are drawn, so the saving over a mesh matters: a particle system with thousands of particles, or a forest.
- The texture has transparent parts, and the renderer can use an alpha test, or alpha blending in sorted order.
The template
The holes are the normal rule , which gives the unit vector that the quad faces, the up rule , which gives an approximate up vector, and the size of the quad, in world units.
BILLBOARD(p, N, U, s_x, s_y) ▷ p is the center of the quad- 1
n ← N(p) ▷ the facing direction, a unit vector - 2
u' ← U(n) ▷ an approximate up, not parallel to n - 3
r ← normalize(u' × n) ▷ the right vector - 4
u ← n × r ▷ the exact up, at a right angle to n and r - 5
corners ← p ± (s_x / 2) r ± (s_y / 2) u - 6
draw the quad with its texture, with the depth test, and with an alpha test or a sorted blend
The steps of the method are:
- Choose the kind of billboard, which fixes the rules and (see the table below), and the size of the quad.
- For each billboard, compute by line L1 and the approximate up by line L2.
- Make an orthonormal frame from them by lines L3 and L4. The vector is at a right angle to and , and is the part of that is at a right angle to , normalized.
- Place the four corners by line L5. This is often done in the vertex shader, with the center and a corner index per vertex.
- Draw by line L6. For blending, sort the billboards from back to front first.
| kind | normal rule | up rule |
|---|---|---|
| screen-aligned | minus the view direction of the camera, the same for all billboards | the up vector of the camera |
| viewpoint-oriented | , toward the eye | the world up |
| axial | with its part along the axis taken out, normalized | the axis , so that |
A screen-aligned billboard lies in a plane parallel to the image, so it shows its texture without any perspective distortion. A viewpoint-oriented one turns toward the eye itself, so a camera that only turns in place does not change it. An axial one turns only around its axis, which keeps a tree upright.
A walk-through. The eye is at , the world up is , and a quad has its center at , at the distance .
- Viewpoint-oriented: line L1 gives . Line L3 gives , and line L4 gives . The corners of line L5 are , , and . The quad leans back toward the eye, which is above it.
- Axial, with : line L1 gives , and as before, with . The corners are , , and . The quad stays upright.
The two normals differ by , the angle at which the eye looks down at the center. A tree texture drawn on the first quad would lean back by that angle; on the second it stays vertical, and the viewer sees it a little from above, which the texture does not show.
Classic examples
Particles. A particle system draws each particle of smoke, fire, dust or sparks as a small screen-aligned or viewpoint-oriented billboard, often with alpha blending in back to front order, or with an additive blend, which needs no sort. A rotation of the quad around by a random angle per particle hides the repeated texture.
Trees and grass. Distant trees are drawn as axial billboards around the vertical axis, often with two or three crossed quads in place of one so that the tree keeps some volume as the camera moves around it. This is a step of level of detail: the full mesh near the viewer, then a billboard far away.
Glows and flares. The halo around a light, a lens flare or the sun disk is a screen-aligned billboard, drawn with an additive blend and often without the depth test, but with a visibility test of the light.
Labels and icons. Text over a character or a map marker is a screen-aligned billboard, often with a size in pixels in place of world units, so that it can be read at any distance.
Impostors. An impostor renders a complex object into a texture and shows it on a billboard until the view has moved too far, then renders it again.
Variations
- Crossed quads. Two or three quads at fixed angles, with no turning at all, give a tree some volume from all horizontal directions and avoid the visible turn of a single quad.
- Soft particles. Fade the alpha of each pixel of a billboard by the difference between its depth and the depth already in the z-buffer, so that the hard line where a smoke quad cuts the ground goes away.
- Sprites in the hardware. Point sprites, and quads built in a geometry or vertex shader from one point per billboard, move steps 2 to 4 to the GPU.
- Normal-mapped billboards. A normal map on the quad lets the lights shade a billboard as if it had relief, which helps clouds and trees.
- Views from several directions. A set of textures rendered from several directions, chosen or blended by the direction to the eye, gives a billboard that changes with the view; this is the step toward impostors.
Pitfalls
- Up parallel to the normal. For a viewpoint-oriented billboard straight below the eye, the world up of line L2 is parallel to , and line L3 normalizes a zero vector. Choose another up, such as the up of the camera, when is small.
- The wrong kind for upright objects. If line L1 uses the screen-aligned or viewpoint-oriented rule for a tree, the tree tips over when the camera looks down at it, by in the walk-through. Use the axial rule.
- Screen-aligned quads that cut each other. With the screen-aligned rule of line L1, a turn of the camera turns all quads at once. Quads that are close together then cut through each other in new places, and the line where they cross moves. The viewpoint-oriented rule avoids this for a camera that only turns.
- Blending without a sort. If line L6 blends the billboards in the order in which they were made, a far quad drawn after a near one is hidden by the depth test, and its transparent edges show the background, not the near particle. Sort from back to front, or use an additive blend or an alpha test.
- A hard cut at the ground. With a plain depth test in line L6, a large smoke quad that meets the ground or a wall shows a straight line there. Use soft particles.
- A size in the wrong space. If line L5 uses a size in pixels for an object that should get smaller with distance, or a size in world units for a label that must be readable, the billboard has the wrong size on the screen.
Exercises
- Show that the vectors and of lines L3 and L4 are unit vectors, are at a right angle to each other and to , and that points to the same side of the plane of and as .
- For the walk-through, compute the corners of the screen-aligned billboard when the camera looks from at , with the camera up as close to as possible. Compare them with the viewpoint-oriented corners.
- A particle system draws 10,000 particles, each a quad of pixels on the screen, with blending. Count the pixels that the blending writes in one frame, and say why large overlapping particles are expensive even though each has only two triangles.
- Write the axial rule for an axis that is not vertical, for example for a beam of light along a direction . What happens when the eye lies on the line through along ?
- A tree is shown as two crossed quads at a right angle, with no turning. From how many horizontal directions does the viewer see a quad exactly edge-on, and how can the texture or a third quad hide this?
References
- Tomas Akenine-Möller, Eric Haines, Naty Hoffman, Angelo Pesce, Michał Iwanicki and Sébastien Hillaire, Real-Time Rendering, fourth edition, CRC Press, 2018, Chapter 13 (beyond polygons), the part on billboarding (screen-aligned, world-oriented and axial billboards, and particles) (general locator)
- David Luebke, Martin Reddy, Jonathan D. Cohen, Amitabh Varshney, Benjamin Watson and Robert Huebner, Level of Detail for 3D Graphics, Morgan Kaufmann, 2003, the parts on image-based representations of distant objects (general locator)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag NAW8AG Edit this page History Report an error Markdown