Custom scene renderers

To create a custom renderer, directly implement the ISceneRenderer or use a delegate through the DelegateSceneRenderer.

Implement an ISceneRenderer

The SceneRendererBase provides a default implementation of ISceneRenderer. It automatically binds the output defines on the renderer to the GraphicsDevice before calling the DrawCore method.

  1. [DataContract("MyCustomRenderer")]
  2. [Display("My Custom Renderer")]
  3. public sealed class MyCustomRenderer : SceneRendererBase
  4. {
  5. // Implements the DrawCore method
  6. protected override void DrawCore(RenderContext context, RenderFrame output)
  7. {
  8. // Access to the graphics device
  9. var graphicsDevice = context.GraphicsDevice;
  10. // Clears the currrent render target
  11. graphicsDevice.Clear(output.RenderTargets[0], Color.CornflowerBlue);
  12. // [...]
  13. }
  14. }

Use a delegate

To develop a renderer and attach it to a method directly, use DelegateSceneRenderer:

  1. var sceneRenderer = new DelegateSceneRenderer(
  2. (renderContext, frame) =>
  3. {
  4. // Access to the graphics device
  5. var graphicsDevice = context.GraphicsDevice;
  6. // Clears the currrent render target
  7. graphicsDevice.Clear(output.RenderTargets[0], Color.CornflowerBlue);
  8. // [...]
  9. });

See also