Using Particle Collision Mode for Distance Fields

Choose your OS:

DFParticleBanner.png

Particle collision in games can be limited when relying on Scene Depth, which can only use what is within the camera view for collision. Scene Depth isn't very accurate at some angles for particles that have longer lifetimes or that are used over a large area. You can use the scene's Distance FieldsNEW! for the particle's Collision Mode, which enables your visual effects to use whole-scene collision using your Static Mesh's Distance Field representation.

The Distance Field Collision Mode offers more reliable collision mode than Scene Depth. However, the Global Distance Field is lower resolution, so you may find that particles pass through thin objects and sharp corners are rounded. In return for this lower resolution, collision with Distance Fields runs very efficiently; its performance cost is about the same as using Scene Depth collision.

In this guide, you'll learn how to enable the Collision Mode for Distance Fields in your Particle System.

Steps

This feature requires that Generate Mesh Distance Fields be enabled in your Project Settings in the Rendering section. For more information visit the Distance FieldsNEW! page.

  1. In your Content Browser, locate and open any Particle System or create a new one if you do not have one readily available.

    ContentBrowser.png

    Content Examples provides some ready-made Particle Systems that would be useful. The P_GPU_particles_collision2 asset from Content Examples is a good example to use as a starting point with minimal setup.

  2. Double-click on your selected Particle System to open the Cascade Particle Editor .

    Cascade.png

  1. Once Cascade Particle Editor opens, right-click in the empty space and from the module list, select Type Data > New GPU Sprites.

    AddGPUmodule.png

  2. Right-click again in the empty space and from the module list, select Collision > Collision(Scene Depth).

    AddCollisionModule.png

  3. Select the Collision(Scene Depth) module. Navigate to the Details panel and next to Collision Mode, use the drop-down to select Distance Field.

    DetailsPanelCollisionMode.png

    Distance Field particle collision is a Shader Model 5 (SM5) feature, so on hardware that doesn't support SM5, the particles will automatically fall back to use Scene Depth Collision instead.

End Result

Now that you've learned how to enable your Particle Systems to use the Collision Mode for Distance Fields, your particle will be able to collide with the entire scene without relying on Scene Depth. This affords you the flexibility in the types of visual effects and lifetimes of those effects that you create, whether they cover a large area or are localized to a small one.

In this example using Distance Fields for particle collision, the particles are always blocked by any surface that has a generated Distance Field regardless whether it is visible within the camera view.

As a comparison for Scene Depth particle collision, as the camera moves forward under the tree, the top portions of the tree are outside of the camera view which means that scene depth no longer blocks particles that are falling from outside of the screen.

Tags