Skip to main content
Version: 5.x

VFX Collisions

This guide walks through the four collision sub-graphs released for VFX Editor. Each method has its own benefits and drawbacks, so read on to decide which works best for your effect.

Each of these examples can be found in the Asset Library.

Common Parameters

On CollisionSelects what the response to the collision will be: bounce, stop, or kill.
BouncinessHow much velocity is retained when the collider normal is parallel to the velocity vector, for example when dropping a ball straight down onto a flat surface.
FrictionHow much resistance is applied when the collider normal is orthogonal to the velocity vector, for example when sliding on a surface.
collisionCountNot a parameter, but a global custom attribute that is created by all collision subgraphs that tracks the number of per-particle collisions. This is an 8-bit attribute that can count up to 255 collisions. Note that for accurate integer comparisons (eg if collisionCount == 3), this attribute needs to be sent through a Floor node first.

Plane Collision

This computes a collision with an infinitely large analytical plane given a position and facing direction. Plane collisions are very accurate and stable even with fast moving plane positions and rotations. Since this is just a single plane, it lacks the flexibility of some other methods. For simple collisions however, especially for colliding with a ground plane, it can’t be beat. Accuracy: ⭐⭐⭐ Flexibility:

Displaces the particle to be on the positive side of the plane to avoid visual interpenetration artifacts. In most cases, this should be equal to the particle’s radius.

Plane Array Collision

The Plane Array sub-graph is almost identical to the regular Plane collision method, but instead of a single position and normal direction, you supply an array of positions and normals. This adds a bit more flexibility since you can create more complex collision shapes. Note that dynamic loops are not currently supported in VFX Editor, so if you supply arrays larger than 5 elements, you will need to change the number of loop node iterations inside this sub-graph. It is best to control the input arrays from a Script. Accuracy: ⭐⭐⭐ Flexibility: ⭐⭐

Depth Buffer Collision

This method uses the depth stencil target of a Camera to determine collisions. Essentially anything that can be rendered can be collided with using this technique including deforming geometry and skinned meshes such as Full Body and Face Mesh, and dynamically generated geometry such as the World Mesh. This makes it the most flexible method available. However, this method is less accurate than the other methods with a higher potential for particles to interpenetrate with animated geometry. Also, since it is sampling the depth buffer, no information exists for occluded geometry, so particles will simply fall through the back faces of objects. Accuracy:Flexibility: ⭐⭐⭐

Particles should avoid writing to the same depth buffer that they are reading from in order to minimize collision errors.
This method is intended to be combined with our Screen Space Normals asset, which can be found on the Asset Library

Distance - How far a particle can be from a depth sample before collision occurs.

SDF Collision

Signed Distance Fields (SDFs) store how far a sampled point is from the surface of an object. Lens Studio 4.7 includes an SDF Generator to create 3D SDF textures from any mesh.  The SDF Collision sub-graph uses an SDF texture to compute collisions. This method is very accurate, stable, and fast. While it allows for collisions with any 3d mesh and its related object-level transformations (scale, rotation, and translation), SDFs are not computed in real-time and do not work with deforming/skinned geometry or dynamically created meshes. SDF textures also contribute to the total lens size more than the other methods.  For more information, see the SDF Generator Guide. Accuracy: ⭐⭐⭐ Flexibility: ⭐⭐

SDF Threshold - At what SDF distance value a collision occurs. Usually this number will be around 0.5, which as close as possible to the surface of a mesh.

Was this page helpful?
Yes
No

AI-Powered Search