Click or drag to resize
DigitalRuneBillboardRenderer Class
Renders billboards and particles.
Inheritance Hierarchy

Namespace: DigitalRune.Graphics.Rendering
Assembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax
public class BillboardRenderer : SceneNodeRenderer

The BillboardRenderer type exposes the following members.

Constructors
  NameDescription
Public methodBillboardRenderer(IGraphicsService, Int32)
Initializes a new instance of the BillboardRenderer class.
Public methodBillboardRenderer(IGraphicsService, Int32, SpriteFont)
Initializes a new instance of the BillboardRenderer class.
Top
Methods
  NameDescription
Public methodCanRender
Determines whether this renderer can handle the specified scene node.
(Overrides SceneNodeRendererCanRender(SceneNode, RenderContext).)
Public methodDispose
Releases all resources used by an instance of the SceneNodeRenderer class.
(Inherited from SceneNodeRenderer.)
Protected methodDispose(Boolean)
Releases the unmanaged resources used by an instance of the SceneNodeRenderer class and optionally releases the managed resources.
(Overrides SceneNodeRendererDispose(Boolean).)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRender(SceneNode, RenderContext)
Renders the specified scene node.
(Inherited from SceneNodeRenderer.)
Public methodRender(IListSceneNode, RenderContext)
Renders the specified scene nodes.
(Inherited from SceneNodeRenderer.)
Public methodRender(IListSceneNode, RenderContext, RenderOrder)
Renders the specified scene nodes.
(Overrides SceneNodeRendererRender(IListSceneNode, RenderContext, RenderOrder).)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Fields
  NameDescription
Public fieldStatic memberMaxBufferSize
The maximum buffer size (number of billboards).
Top
Properties
  NameDescription
Public propertyBufferSize
Gets the size of the buffer (number of billboards).
Public propertyDepthThreshold
Gets or sets the depth threshold used for edge detection when upsampling the off-screen buffer.
Public propertyEnableOffscreenRendering
Gets or sets a value indicating whether off-screen rendering is enabled. (Requires HiDef profile.)
Public propertyEnableSoftParticles
Gets or sets a value indicating whether soft particles are enabled. (Requires HiDef profile.)
Public propertyFarBias Obsolete.
Gets or sets the bias factor used to bias the camera near plane when the z-buffer is reconstructed. (Only used when EnableOffscreenRendering is set.)
Public propertyIsDisposed
Gets a value indicating whether this instance has been disposed of.
(Inherited from SceneNodeRenderer.)
Public propertyNearBias Obsolete.
Gets or sets the factor used to bias the camera near plane when the z-buffer is reconstructed. (Only used when EnableOffscreenRendering is set.)
Public propertyOrder
Gets the draw order of this scene node renderer.
(Inherited from SceneNodeRenderer.)
Public propertyUpsamplingFilter Obsolete.
Gets or sets the upsampling filter that is used for combining the off-screen buffer with the scene.
Public propertyUpsamplingMode
Gets or sets the upsampling filter that is used for combining the off-screen buffer with the scene.
Top
Remarks

The BillboardRenderer is a scene node renderer which handles BillboardNodes and ParticleSystemNodes.

Particle systems need to have certain particle parameters for rendering. If a required particle parameter is missing, the particle system is ignored by the renderer! See ParticleSystemNode for more information.

Buffer Size: The renderer batches billboards and particles using an internal buffer. The property BufferSize limits the number of billboards/particles that can be drawn with a single draw call.

Render States: The BillboardRenderer changes the following render states of the graphics device.

  • The appropriate BlendState is set depending on the type of billboards/particles.
  • Culling is disabled in the RasterizerState. Billboards/particles are rendered "two-sided".
  • When using HiDef profile with soft particles the DepthStencilState is set to None (= depth-reads and depth-writes are disabled).

    When using Reach profile or HiDef profile (without soft particles) the DepthStencilState is not changed. The DepthStencilState should be set explicitly before rendering billboards/particles. In most cases depth-writes should be disabled, for example:

    C#
    graphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
    billboardRenderer.Render(nodes, context);

Soft Particles (require HiDef profile):
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 an explicit depth test in the pixel shader. Soft particles fade out near the camera and create smooth transitions when they intersect with other geometry.

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

For image billboards: The Softness property 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".

High-Speed, Off-Screen Particles (require HiDef profile):
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. 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 . In addition a low-resolution copy of the depth buffer (half width and height) needs to be stored in renderContext.Data[RenderContextKey.DepthBufferHalf].

In XNA off-screen rendering clears the current back buffer. If necessary the renderer will automatically rebuild the back buffer including the depth buffer. For the rebuild step it will use the same parameters (e.g. near and far bias) as the current RebuildZBufferRenderer stored in renderContext.Data[RenderContextKey.RebuildZBufferRenderer].

Caution note Caution
When off-screen rendering is enabled the BillboardRenderer automatically switches render targets and invalidates the current depth-stencil buffer.
See Also