Skip to main content

Simulator

The Simulator shader is in control of updating the data of all Particles, it allows their position and velocity to react to different forces in real time and can also re-spawn particles under certain conditions.

This shader has to be used on the two Simulator GameObjects in the Quantum Particles prefabs.

If you want to change how the particles behave, interact, spawn or their movement patterns, this is the shader you will be working with.

Currently, every setup has two materials with this shader, one for each hand, this has a technical reason as at least two unique simulators are required, working in tandem, to make the simulation work.


Base Settings

Input Texture

Render Texture containing the particle input data.

DO NOT remove this texture or edit the settings, unless you know what you are doing, without it the simulation will not work and the particles might not move or show up at all.

EXCEPTION: if you want to change the amount of particles, follow this guide: Change Particle Amount.

Simulator ID

Integer containing the simulator ID, typically set to 0 for the left hand and 1 for the right hand.

DO NOT change this setting, unless you know what you are doing, otherwise the simulation will not work and the particles might not move or show up at all.

Simulator Count

Integer containing the number of simulators, typically set to 2 for all current setups.

DO NOT change this setting, unless you know what you are doing, otherwise some features might break or will not work as intended.

Simulation Speed

Float controlling the Speed of the simulation, typically set to 1.0 for normal speed. This value will be used as a multiplier for all time based calculations, this means you can change this value to slow down or speed up the simulation. Technically negative values will also work, but might have unexpected results.

Simulation Scale

Float controlling the Scale of the simulation, typically set to 1.0 for normal scale. This value will be used as a multiplier for all distance based calculations, this means you can scale up the simulation while keeping the same behavior for the particles. This could be used to scale the particles with your avatar if you want the effects to look the same relative to your avatar's size. Technically negative values will also work, but might have unexpected results.

Speed Loss

Float value in the Range [0.0, 1.0], used to control how much of the velocity is approximately lost every second of the simulation. A value of 1.0 means all speed will be lost over the span of a second, while a value of 0.0 means that speed will never be lost over time, this can have wild effects when forces keep acting on a particle and keep speeding them up, so choose carefully. Due to varying precision with different frame rates this value can slightly fluctuate in different situations and hardware.

Speed Limit

Float value in the Range [0.001, 1000.0], used to control the maximum speed a particle can have. This value is used to prevent particles from moving too fast and potentially breaking the simulation or flying out of range. After every simulation step the speed of a particle will be clamped to this value if it exceeds it, this will not affect the direction a particle can travel in, but particles traveling at the speed limit will react differently to forces.


Forces

Forces are what makes the particles act dynamically, they can be used to simulate attraction, repulsion, gravity, wind, drag, turbulence and many more effects. All forces can be toggled individually and have their own settings to control their strength and behavior.

The following settings are present for all forces:

Affect

Toggle between a force affecting the Position or the Velocity of a particle. When a force is applied to the Position of a particle it will always be moved exactly as the force direction and strength dictates and will stop moving if the strength is zero. When applied to the Velocity of a particle it will keep accelerating towards the force direction while the strength is larger than zero and keeps moving even if the force is no longer present.

Typically a force would act on the Velocity of a particle, but if the speed loss is too large they might not be able to move at all, in this case you could try to apply the force to the position instead. Use the Position setting with caution if multiple particles will be moved to the same spot they might no longer separate afterwards.

Field Strength

Float value in the Range [-100.0, 100.0], used as a basic multiplier for the force. Use this value if you want to for example make particles get attracted/repelled stronger/weaker.

Field Behavior

Toggle between a Uniform or Dynamic force field. A Uniform force field will have the same strength no matter the distance, while a Dynamic force field will use the following parameters to have a different strength dependent on distance.

The calculations for the Dynamic force field are roughly as follows: clamp(pow(particleDistance + offset, falloff) * strength, -maxAttraction, maxAttraction) and a graph showing the Force over Distance can be seen at the end of the force field settings.

Strength Falloff

Float value in the Range [-100.0, 100.0], used as an exponent for the distance based strength falloff. This means that for positive values the force will get stronger the further away a particle is from the source, while for negative values the force will get weaker the further away a particle is from the source. A value of 0.0 will result in a constant force field strength, which is basically the same as setting the Field Behavior to Uniform.

Distance Offset

Float value between 0.0 and 1.0, used to offset the distance calculation for the force field. This means that the force field will act as if the particles are further away from the source than they actually are. This is mainly useful if you don't want the flipped field strength behavior for distances below 1.0.

Force Limit

Float value in the Range [0.001, 1000.0], used to limit the maximum strength a force can have. This is NOT related or connected to the speed limit and will only affect the maximum effect this specific force can have on a particle.

Force over Distance Graph

This graph shows the strength of the force field over distance, the x-axis represents the distance from the source and the y-axis represents the strength of the force. Both axes will scale dynamically to show the fully possible strength range of the force depending on the force limit.

The red lines represent the current sample point, for which the values will be displayed at the top right of the graph (D=Distance, F=Force). By double-clicking on the graph you can set a new sample point, which will update the red lines and corresponding values at the top right.


Attraction

Attraction Mode

Position

Vector3 containing the position of the point to attract particles to. This position is relative to the simulator GameObject and in local space.


Directional

Shape Mode

Direction

Vector3 containing the direction of the force. The length of this vector is irrelevant, only the direction will be used, so a vector like (0.0, 1.0, 0.0) will have the same effect as (0.0, 1000.0, 0.0).

Space

Toggle between World and Local space for the direction of the force. In World space the direction will be relative to the world, while in Local space the direction will be relative to the simulator GameObject.


Rotational

Rotation Axis

Vector3 containing the axis of rotation for the force. The length of this vector is irrelevant, only the direction will be used, so a vector like (0.0, 1.0, 0.0) will have the same effect as (0.0, 1000.0, 0.0).

Inwards Angle

Float value in the Range [-1.0, 1.0], used to control the angle of rotation for the force. This is NOT the angle of rotation, but instead controls how much the particles will be rotated towards the axis of rotation and the direction (clockwise for positive and counter-clockwise for negative values). A value of -1.0 or 1.0 will rotate the particles fully towards the axis.

Distance Factor

Float value in the Range [0.0, 1.0], used to determine how much the distance from the axis of rotation will affect the rotation. A value of 0.0 will result in no distance based scaling, while a value of 1.0 will have the distance multiplied with the rotation strength.

Distance From

Toggle between the Point or the Axis of rotation for the distance calculation. When set to Point the distance will be calculated from the position of the simulator GameObject, while when set to Axis the distance will be calculated from the axis of rotation.

Space

Toggle between World and Local space for the direction of the force. In World space the direction will be relative to the world, while in Local space the direction will be relative to the simulator GameObject.


Turbulence

The Turbulence force can be used to create chaotic movement patterns for the particles and introduce some natural randomness to the simulation.

Density

Vector3 containing the density of the turbulence. This value controls how much the Turbulence will change over a given area, a higher value will result in more chaotic movement, while a lower value will result in more uniform movement.

Panning

Vector3 containing the panning of the turbulence. This value controls how and in what direction the Turbulence will move over time, a higher value will result in faster movement.

Time Dependent

Checkbox to toggle if the Turbulence should be time dependent. When enabled the Turbulence will change over time, while when disabled the Turbulence will be static.

Change Speed

Float used to control how fast the Turbulence will change over time.

Space

Toggle between World and Local space for the direction of the force. In World space the direction will be relative to the world, while in Local space the direction will be relative to the simulator GameObject.


Drag

The Drag force can be used to drag the particles around using the simulator GameObjects movement.

When combined with a Uniform field of strength 1.0 and both positional and rotational drag, this can be used grab and move particles around as if they were attached to the simulator GameObject.

Drag Mode

Only the positional change of the simulator GameObject will be used to drag the particles around.


Particle Spawning

In the Particle Spawning section you can control how particles are spawned, this includes where they are spawned, how they move and how long they live. The Quantum Particles system will always have a fixed amount of particles, so it would be more accurate to say that particles are re-spawned rather than spawned. Even after a particle "dies" it will still be part of the simulation, but might be invisible depending on the visualizer settings. This is why in the following some values can be set to Keep, which means that the value will be kept from the previous particle life cycle.

Data Sources

You can either use a Single Texture for all particle data or use Multiple Sources for different data types like position, velocity, age and life.

Shape Texture (Single Texture Mode)

Shape Texture or Render Texture containing all the data for the particles to be spawned.


Position Source

All position sources are relative to the simulator GameObject and in local space, except for the Texture which can be toggled between local and world space.

Position will be kept from the previous particle life cycle.


Velocity Source

Velocity will be kept from the previous particle life cycle.


Starting Age Source

Age will be kept from the previous particle life cycle.


Lifetime Source

Lifetime will be kept from the previous particle life cycle.


Particle Re-Spawn Check

All particles will be checked every frame.

Respawn Conditions

Particles will always be re-spawned, no matter the state they are in.

Position Conditions

The position of the particles will not be checked.

Velocity Conditions

The velocity of the particles will not be checked.

Age Conditions

The age of the particles will not be checked.

Infinite Lifetime

Checkbox to toggle if particles with an infinite lifetime should be re-spawned. This might be necessary when particles have never been re-spawned before.


Sampling Offset

This setting controls how the data for the particles is sampled from the input textures.

No offset will be used for sampling the data.

Inherit Movement

Particles will not inherit any movement from the simulator GameObject.


Random Seed

Float value used as a seed for the random number generator. This value will only affect the random number generator for the particle spawning.

Better Quality Noise

Checkbox to toggle if the noise used for the particle spawning should be of better quality. When enabled the noise will be of better quality, but will be slightly slower to calculate.

Time Dependent Noise

Checkbox to toggle if the noise used for the particle spawning should be time dependent. When enabled the noise will change over time, while when disabled the noise will stay the same.