Debug Drawing

Learn how to use Debug Drawing to visualize elements of your Niagara systems.


Debug Drawing

When Debug Drawing is available on a module, clicking it shows you a visualization of that module. See the following example of Debug Drawing applied to a Sphere Location module.

Debug Drawing on a Sphere Location module

How to Enable Debug Drawing

In the Niagara Editor, when Debug Drawing is available you will see an icon show up on the module.

Not all modules have the Debug Drawing option available.

Debug Drawing icon in the stack

To enable Debug Drawing, click the box icon. You will now see a visualization in the viewport.

Enabling Multiple Debug Drawing Modules

You can enable as many Debug Drawing modules as you want. When you enable more than one, you will see each module output its own drawing.

For example, if you enable Debug Drawing on both a Box Location and a Sphere Location module, you will see a visualization for each.

Debug Drawing on both a Sphere and Box Location Module

The particles that are created here use a combination of both modules to determine the location. The visualizations show the individual modules to help you debug what the resultant effect looks like.

Types of Debug Drawing

There are two main types of Debug Drawing, Per Particle and Persistent. You can set up Per Particle visualizations to track the progress of each particle, updating frame-by-frame.

Persistent visualizations are drawn once and then persist from one frame to the next. Persistent drawings must be driven by parameters that are constants, either values on a function node or rapid iteration parameters. They cannot be drawn as the result of math operations, or graph operations. If Debug Drawing cannot deduce the compile tag for these parameters, it substitutes a default value.

The above visualizations of the Sphere Location module and the Box Location module are examples of Persistent visualizations. For an example of Per Particle visualization, you can see the example below of Debug Drawing on a Vortex Force module.

Debug Drawing on a Vertex Force module

Here we can see a line is being drawn on each particle to indicate the direction and magnitude of the Vortex Force that's being applied to that particle.

Adjusting Debug Drawing Settings

When you select any module that has Debug Drawing switched on, by default a Debug section is added at the bottom of the Selection Panel.

Debug Drawing options in the Selection Panel

In this example, you can adjust parameters such as the color, the length of the line drawn, and whether to draw the debug drawing for each particle or to skip particles. The types of debug options that you will see here depend on the type of Debug Drawing that has been set up.

How to Enable Debug Drawing on a Custom Module

To get a good idea of how to use Debug Drawing on a custom module, double-click a module that already has Debug Drawing in it to inspect how the script has been set up. For examples of Persistent drawings, see the Sphere Location and Box Location modules. For an example of a Per Particle setup, inspect the Vortex Force module.

When you add Debug Drawing to a module, it's a good idea to add it to the end of the script so that the debug interface is drawn after the rest of the script has completed.

As a basic flow, first you need to use Map Get to fetch a Debug Draw local parameter, as well as any inputs you might need to drive the drawing. For example, if you are going to draw a line, you will need the start and end points of the line. If you are going to draw a sphere, you will need the center position of the sphere and the radius.

What inputs you need exactly depends on what it is you're trying to visualize.

Debug Draw Workflow Diagram

For example, in the Vortex Force example, we use the following inputs.

Debug Draw in Map Get module

DebugDraw will add the Debug Draw interface to the module, giving the user the option to turn on and off Debug Draw from the System Overview.

ParticlesPosition will provide us with the position of the particles on that frame. VortexForceAmount gives us the value that has been set for the Vortex Force module. And then we let the user define the Debug Drawing's line color as well as the length of the line using custom inputs.

Once you have fetched the inputs you need, the values need to be converted into World space if they are in Local space. Engine Scale is used to convert from Localspace to Worldspace.

You can then connect the Debug Draw output pin to a Draw component. If you drag off from Debug Draw and release, you will see many options of different types of drawings to choose from.

Debug Draw pin

Notice that each type of drawing has a standard option and a persistent option. Standard drawings are used when you want the drawing to modify frame-per-frame as the particles are updating.

Persistent drawings are used for static drawings, when you want one drawing for the Niagara system as a whole. Persistent drawings can also be drawn without the system having any particles active at that given moment. This is why persistent drawings are great to use to draw static shapes, like in the example of the Sphere Location module.

Once you select the type of drawing you want to draw, you can connect the parameters this drawing needs to complete the drawing. This is an example of a simple DrawLine component:

Draw Line module

Connect the Debug Draw output pin from the Map Get node to the input pin for the DebugDrawInterface node. Then you can define your start and end positions for the line to be drawn. For example, you can set the ParticlePosition as the StartLocation. You can then let the user define the length of the line, and use VortexForce to set the vector defining the direction of the line. Combined together, the script looks like this.

Debug Draw script

In this example:

  • A is the Map Get node where we fetch the values that we need.

  • B is where we convert from Localspace to Worldspace.

  • C is how we determine the end point of the line by adding together the start position and the vector for the Vortex Force.

  • D is the Draw Line component that draws the Debug Drawing.

To take a closer look at this example, add a Vortex Force module to a Niagara system and then double-click the module to inspect the Niagara Script.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey