Click or drag to resize
DigitalRuneBillboards and Particles
Billboards (images and text)

A billboard is a textured polygon (usually a quad) used for drawing impostors, particles and other effects. The difference to a regular polygon is that the billboard can be automatically oriented during rendering. For example: A view plane-aligned billboard is always rendered parallel to the screen, the quad always faces the camera.

There are two types of billboards: ImageBillboards and TextBillboards.

Billboards are positioned using a BillboardNode. The BillboardOrientation defines how the billboard is rendered. This type provides definitions for the most common orientations.

DigitalRune.Graphics (Billboards)
Class Diagram: Billboards
Particles

Particle systems can be used to simulate complex effects, such as explosion, fire, or smoke. ParticleSystems are part of the DigitalRune Particles library. A ParticleSystemNode creates an instance of a particle system within a scene.

The particle system manager and the graphics manager can be run in parallel (multithreading). This complicates the use of particle effects: The game logic needs to explicitly synchronize the particle data and the render data by calling ParticleSystemNodeSynchronize explicitly in each frame! See ParticleSystemNode for more information.

DigitalRune.Graphics (Particles)
Class Diagram: Particles
Rendering billboards and particles

This section explains how to render billboards and particle effects using the BillboardRenderer.

BillboardRenderer

The BillboardRenderer is a SceneNodeRenderer that handles BillboardNodes and ParticleSystemNodes.

Billboards and particles may be rendered with or without depth test. The required depth-stencil state needs to be set before the renderer is called.

Example (C#)
// Render opaque objects here...

// Set required depth-stencil state.
graphicsDevice.DepthStencilState = DepthStencilState.DepthRead;

// Render a list of billboard and particle nodes.
billboardRenderer.Render(sceneNodes, context, RenderOrder.BackToFront);

The renderer automatically batches billboards and particles that use the same texture and renders them with a single draw call. The property BufferSize limits the number of billboards/particles that can be drawn with a single draw call.

Tip Tip

The BillboardRenderer batches billboards and particles based on their texture. It is therefore recommended to minimize the number of texture, for example by packing all billboard and particle images into a single texture (see Texture Atlases).

The BillboardRenderer can also render particles as ribbons (a.k.a. "beams", "lines", "trails"). See ParticleSystemNode for more information.

Soft particles

Billboards and particles are usually rendered as flat quads, which cause hard edges when they intersect with other geometry in the scene. "Soft particles" are rendered by performing a depth check in the pixel shader. Soft particles create smooth transitions when they intersect with other geometry.

Soft-Particles

Soft particles also fade out near the camera. That means, if the camera moves through a particle, the particle fades out smoothly (which reduces "popping" artifacts).

To enable rendering of soft particles set the property EnableSoftParticles to true. In addition, the depth buffer needs to be set in the render context (property GBuffer0).

For image billboards: The property ImageBillboardSoftness defines whether billboards are rendered "hard" or "soft".

For particle systems: The Softness parameter (a uniform particle parameter of type Single) defines whether particles are rendered "hard" or "soft".

The default softness is 0, which means that the billboard/particle shows hard edges. The value can be set to NaN (= automatic) or a fixed softness value. (The softness is basically the thickness of the particle in world space.)

High-speed, off-screen particles

Off-screen rendering is only available in HiDef profile. It can be turned on or off using BillboardRenderer.EnableOffscreenRendering.

Large amounts of particles covering the screen can cause a lot of overdraw. This can reduce the frame rate, if the game is limited by the GPU's fill rate. One solution to this problem is to render particles into a low-resolution off-screen buffer. After all particles are rendered, the low-resolution buffer is upsampled and combined with the scene render target. This reduces the amount of overdraw, at the expense of additional image processing overhead and image quality.

To enable off-screen rendering set the property EnableOffscreenRendering to true. In addition a low-resolution copy of the depth buffer (half width and height) needs to be stored in renderContext.Data[RenderContextKey.DepthBufferHalf].

Caution note Caution

When off-screen rendering is enabled the BillboardRenderer automatically switches render targets and invalidates the current depth-stencil buffer!

HDR rendering combined with off-screen rendering on the Xbox 360 is currently limited. It works for additively blended particles, but may cause artifacts when using alpha-blended particles. This is caused by the HdrBlendable format, which only has 2 bits for the alpha channel on the Xbox 360.