Tim Hobson

Distance Field Particle Collison

​In this How-to we will explore setting up a simple snow particle that will use Mesh Distance Fields for collision of the Particle system rather than the default Scene Depth which is limited to the camera view. The advantage of using Distance Fields as particle collision is that it is not limited to the cameras view with its collision. This can provide much more accurate collision model when using this type of effect.

Particle Setup: Creating a Basic Snow Material

1. ​In the Content Browser click the Add New button and select Material.
2. ​Name the newly created Material M_Snow and then double-click to open it up.
3. Re-create the following Material Graph.
Set the following properties by selecting the Main Material Node:
  • Blend Mode: Translucent
  • Shading Model: Unlit
  • Responsive AA: Enabled

Creating a Snow Particle System

1. ​In the Content Browser click the Add New button and select a Particle System. Name the newly created Particle System P_DF_Snow.
2. ​Now double-click to open the Particle System in the Cascade Editor.
3. ​Click anywhere in the empty area to the right of the Emitter so that you do not have an emitter selected. This will give you access to the base property Details panel for the Particle System.
With the Details panel visible, set the following values:
Property Value
Particle System
Warmup Time 25.0
Bounds
Use Fixed Relative Bounds TRUE (Checked)
Fixed Relative Bounding Box
Min
X: -3500
Y: -3500
Z: -3500
Max
X: 3500
Y: 3500
Z: 3500
​​You can view the bounds of the particle system by clicking the Bounds button in the tool bar.

Adding Modules to the Emitter

1. ​Before we begin adding new Modules to our Emitter start by right-clicking on Color Over Life and choosing Delete. This module will not be needed for this Particle System.
2. ​We will now need to add several new Modules to our Emitter. You can do this by right-clicking in the black space of the Emitter not occupied by a Module to bring up the Module list.
Reference the table on the right to add the following modules from the location listed.
List Location Module Name Module Image
Type Data GPU Sprites
Color Scale Color/Life
Location Cylinder
Acceleration Const Acceleration
Collision Collision
​​When adding the Collision Module you will notice that it is red and displaying a warning message. 
 
3. ​When complete your Emitter should now look like this:

Setting Module Properties

For the following Modules apply the properties and values via the Details panel once you have selected each Module.

Required

Property Value
Emitter
Material M_Snow
Screen Alignment PSA_Rectangle

Spawn

​In this module you can adjust how many particles are used for the scene by changing the value for Constant.
Property Value
Spawn
Constant 5000

Lifetime

​In this module the values set will set a range for the lifetime of the particle that is spawned by using a minimum and maximum value.
Property Value
Lifetime
Distribution

Min 10

Max 20

Initial Size

​This module allows you to set the initial size of a particle when it spawned. In this example the particles have a minimum and maximum size range.
Property Value
Size
Start Size
Max
X: 10
Y: 10
Z: 10
Min
X: 5
Y: 5
Z: 5

Initial Velocity

​In this module you can set the velocity of the particles that are spawned. The Z value for Max and Min control the direction that the snow particle will fall.
Property Value
Velocity
Start Velocity
Max
X: 50
Y: 50
Z: -100
Min
X: -50
Y: -50
Z: -75

Initial Color

There are no changes needed for this module.

Scale Color/life

This module will scale the color of the particle over the its lifetime so that it will fade out after it has collided and stoped.

1. Click the Add (+) button one (1) time to add an additional element under in the Color Scale Over Life > Distribution Constant Curve Points. By default there are two (2) Points already added with the module.
2. ​Adjust the following values for each element.
Property Value
Color
Distribution Distribution Vector Constant Curve
Points
Element 0
In Val 0.0
Out Val
R: 1
G: 1
B: 1
Element 1
In Val 0.8
Out Val
R: 1
G: 1
B: 1
Element 2
In Val 1.0
3. ​In the Cascade Viewport your Particle Simulation should look similar to this with a cone shape:

Cylinder

​In this module the particle system will use a value for the radius of the cylinder. This will spawn the particle system more evenly over a larger radius rather than a cone that spreads out.
Property Value
Location
Start Radius 1000
​After setting the radius for the cylinder you will now have a more consistent dispersal area for the particles to spawn. You can use larger values to have a larger disperal area.

Const Acceleration

​This module adds velocity to the particle that is spawned and is the only type of acceleration available for GPU Sprite particls.
Property Value
Particle Module Acceleration Constant
Acceleration

X: 0

Y: 0

Z: -25

Collision

​In this module you will be able to set the type of collision that the particle will use, whether it is Scene Depth or Distance Field along with parameters that tell the particle how to respond upon collision as well.
Property Value
Collision
Resillence Scale Over Life
Friction 1.0
Response Stop
Collision Mode Distance Field
1. ​Now that your modules are setup, we can close the Particle System window. Then in your scene you simply need to drag in your Particle System from the Content Browser and place it above the area you want to.
2. ​You should now have a scene that uses the Distance Field meshes of your assets as the collision for the GPU particles.

Comparison of Scene Depth vs. Distance Field Collision

​When it comes to selecting the collision method for your particle system you will have the option of Scene Depth or Distance Field. When using Scene Depth this method will limit your particles collision to that which is only visible on the screen, however when using a mesh distance field as collision the particle system will not be limited to the scene view.

Scene Depth Collision

​In this example you will see that when the camera is moved below the floor static mesh placed above the trees, when the camera is looking up the mesh will block the snow particle, but when looking back at the trees the mesh cannot block the particles that collide out of the view of the scene.

Distance Field Collision

​In this example you will see that it does not matter what is in the cameras view. The floor static mesh placed above the trees will block any particle from coming through the mesh distance field.

Conclusion

​At this point you should now be comfortable enough to set up distance field collision for any particle systems you need for your games with minimal effort. You should also see the benefits of using this method if you have already enabled distance fields for your project. There is no extra overhead for performance cost and the added benefit here is that you can add extra realism to your scene in comparison to Scene Depth collision.