Blog

Particle Rendering, Lens Flares and other Changes

Jan 10

Written by:
Thursday, January 10, 2013  RssIcon

First, thank you to all users who have provided feedback via our forum or directly via email!

This post highlights the changes in the current release. The most important change is the addition of particle rendering and lens flares.

Particle-Rendering

Sun-Lens-Flare

Anamorphic-Lens-Flare

Examples: Particles, sun lens flares, anamorphic lens flare. (Click image to enlarge.)

For more detailed information on the new types, check out the API documentation.

Changes in Scene Graph

Three new types of scene nodes have been added:

SceneChanges

The Scene already automatically assigns scene nodes to groups (where a group is simply an integer ID used for filtering). The group IDs have been updated to work with the new scene node types.

Scene Nodes

The property SceneNode.IsVisible has been replaced by two new properties: SceneNode.IsEnabled and SceneNode.IsRenderable:

  • SceneNode.IsEnabled can be set to false to hide the scene node. Disabled scene nodes are ignored in scene queries (e.g. camera frustum queries) and do not show up in any query result. The flag is inherited in the scene graph; i.e. setting SceneNode.IsEnabled enables or disables the current node and all descendant nodes. The SceneNode.SceneChanged event now also fires if a node in the current subtree is enabled or disabled.
  • SceneNode.IsRenderable indicates whether a scene node can be rendered. The scene nodes BillboardNode, LensFlareNode, MeshNode, and ParticleSystemNode can be rendered. The other types, such as SceneNode, CameraNode, LightNode, and ModelNode are auxiliary nodes that cannot be rendered.

Scene Queries

  • The CameraFrustumQuery has a new property RenderableNodes where it collects all "renderable" scene nodes. The previous property CameraFrustumQuery.Meshes, which contained only MeshNodes, has been removed.
  • The property MeshNode.CastsShadows has been moved into the base class SceneNode.CastsShadows. The property can apply to more than just meshes. - Though, in the current release only meshes cast shadows.
  • ShadowCasterQuery, a new type of scene query, has been added. This scene query is used by the shadow map renderers to gather all shadow casting nodes (where SceneNode.CastsShadows == true).
  • The type of MeshQuery.Meshes was changed from List<MeshNodes> to List<SceneNode>.

Scene Node Renderers

A new base class SceneNodeRenderer was added. A scene node renderer is a renderer that handles one or more types of scene nodes.

New scene node renderers are:

  • SceneRenderer, which is a composite scene node renderer. (It can be used to treat a group of renderers as a single instance.)

SceneNodeRenderers

The already existing MeshRenderer is now derived from SceneNodeRenderer. Its interface has changed slightly. The enumeration MeshRendererOptions has been replaced by the new RenderOrder, which provides more control over the order in which scene nodes are drawn.

Custom Scene Nodes

The new architecture allows third-party developers to extend the scene graph and add new types of scene nodes and renderers.

See How To: Add a Custom Scene Node and GeneralSamples (file "Samples\DigitalRune.Graphics\GeneralSamples\GeneralSamples\Samples\Sample 09 - CustomSceneNodeSample.cs") for guidance.

Particle Rendering

To render particle effects, you need to integrate the new BillboardRenderer into the graphics pipeline. See DeferredLightSample (file "Samples\DigitalRune.Graphics\DeferredLightingSample\DeferredLightingSample\Graphics\DeferredLightingScreen.cs") for reference.

The ParticleSystemNode (DigitalRune Graphics) can be used to add a ParticleSystem (DigitalRune Particles) to the scene graph.

The particle rendering is already pretty capable:

  • Particles can be rendered as billboards or ribbons (a.k.a. “beams”, “lines”, “trails”).
  • The renderer supports instancing: I.e. a single particle system can be added multiple times to a scene. Each instance can be rendered with variations.
  • The ParticleSystemNode even supports nested particle systems.

But we haven’t yet added a sample that demonstrates all of the new capabilities. For now, please check the class documentation for details.

Another caveat: The particle effects demonstrated in the ParticleSample (folder "Samples\DigitalRune.Particles\ParticlesSample") cannot be used directly. DigitalRune Graphics uses some particle parameters differently than the ParticleSample. Ribbons are also handled differently. We will highlight the new particle parameters and differences in one of the next posts.

Texture Atlases, Tile Sets and 2D Animations

The PackedTexture has been added to support texture atlases and tile sets (including "sprite sheet animations").

PackedTexture

The PackedTexture can be used by

  • lens flares (lens flare elements can be packed into one texture atlas)
  • billboards and particles (images can be picked from texture atlas, images can be animated).

Models may use texture atlases, however they do not use the PackedTextures class at run-time. (DigitalRune Graphics makes no distinction whether a model texture is a regular texture or a texture atlas. It assumes that any UV coordinate changes are already baked into the model, or that the associated DirectX Effects handle the UV coordinate changes.)

Note that DigitalRune Graphics does not (yet) include a texture packer for creating texture atlases. For now, we recommend using the NVIDIA Texture Atlas Tool or similar third-party tools.

XNA Content Pipeline

We have added some major improvements to the DigitalRune model content processor:

To process a model you need to create a model description file and material definition files. We changed the file extension from .xml to .drmdl for models descriptions and .drmat for material definitions to prevent naming conflicts.

The model description file is used define how a model should be processed and to assign materials to submeshes. The last part is now optional: If no material is explicitly set in the model description, the model processor uses the texture names to find materials. So if a model as a texture Wood.png, the content processor automatically looks for Wood.drmat in the same folder.

Automatic Creation of Model Description and Material Definitions

Another important change is that the content processor will now create default model description and material definition files in case they are missing. So when you add a model to a content project and compile the project, the content processor creates default *.drmdl and *.drmat files, which you can then customize.

The ideal way to prepare models for use with the DigitalRune Engine is to use a model editor. We try to provide one in the future. But currently you need to manually provide the model description and material definition files. The new changes should make this process a bit simpler.

Please note, the format of these additional files is still the same, and the model processor also still supports files with the ".xml" extension. – If you have a running project, there is no need to rename all your *.xml files to *.drmdl and *.drmat.

Have a look at Models and Materials (Content Pipeline) for more details.

Other Changes

Some render artifacts which could be caused by the CameraMotionBlur have been removed.

The DebugRenderer now implements IDisposable. Dispose() can be called to explicitly release all resources allocated by the renderer.

We also found that DebugRenderer.Update() was not called in all samples. The method performs internal management and regular clean-ups. It should be called once per frame.

The DebugRenderer further had problems rendering TransformedShapes. Non-uniform scaling and rotations are now handled correctly.

Internal changes have made GraphicsHelper.GetMeshRenderer() obsolete. The method has been removed.

What's Next?

The documentation is currently lagging behind. The samples cover most, but not all features. This will be addressed in the future.

We are currently improving the particle rendering. The next release will support high-speed, off-screen particles and soft particles.

1 comment(s) so far...


Gravatar

Re: Particle Rendering, Lens Flares and other Changes

This is great! Thanks for making such a wonderful engine and constantly updating it! I got particles rendering in the last build of the graphics engine, but this makes for a much more elegant solution.

By Eric on   Friday, January 11, 2013

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 

Article Collection

A collection of the most useful blog articles can be found here:

Article Collection
(on Documentation page
)