CParticleSamplerProceduralTurbulence

From PopcornFX
Jump to: navigation, search

Particle sampler turbulence - Main page : Particle samplers Particle samplers


The procedural turbulence sampler allows you to sample an infinite 3D noisy turbulence field. It is useful to fake fluid movement, like particles of smoke, sparks, or ashes, flowing through a turbulent medium.
Although its primary purpose is to simulate an incompressible vector field, it can also be used as a generic 3D noise.

New v1.13.0 Since v1.13, the turbulence sampler allows to specify a non-procedural turbulence source: an .FGA vector-field file.
It can also now be bound as an attribute-sampler in the game engine, and overridden per-instance of an effect. See the VectorField backdrop VectorField backdrop.


Particle stream affected by a turbulence


Particle sampler turbulence Node properties

Field name Default value Description
Particle sampler turbulence General
SamplerName Auto-generated name Name of the sampler, published to the rest of the effect
SamplerDescription Empty Sampler Description (optional)
UserData Empty Use this if you need to pass custom data to your game engine's integration (custom PopcornFX SDK). If you're Using UE4 or Unity, you can ignore this.
Particle sampler turbulence DataSource
DataSource Procedural New v1.13.0 Specifies where the sampler fetches the vector-field data
  • Procedural : vector-field is defined by the procedural curl-noise turbulence parameters
  • External : sampler will load an external vector-field file (.fga)
VectorFieldResource <empty> New v1.13.0 (External only) : Path to the file containing the vector-field (.fga)
Particle sampler turbulence General
GlobalScale 1 Overall vector-field scale, scales both the Strength and the Wavelength properties
Strength 0.1 Turbulence strength, higher values produce larger forces.
WrapSide true New v1.13.0 (External only) : When enabled, the vector-field will wrap/repeat on its side axis, otherwise, it will be clamped
WrapUp true New v1.13.0 (External only) : When enabled, the vector-field will wrap/repeat on its up axis, otherwise, it will be clamped
WrapForward true New v1.13.0 (External only) : When enabled, the vector-field will wrap/repeat on its forward axis, otherwise, it will be clamped
WrapTime true New v1.13.0 (External only) : When enabled, the vector-field will wrap/repeat on its time axis, otherwise, it will be clamped
Filtering Trilinear New v1.13.0 (External only) : Filtering mode to be used when sampling
  • Point : Fastest interpolator. lowest quality. No filtering / interpolation
  • Trilinear : Interpolates between the 8 neighboring cells around the sampling point in 3D space
  • Quadrilinear : Interpolates between the 16 neighboring cells around the sampling point in 4D space
Wavelenght 0.5 (Procedural only) : Vector-field strength, higher values produce larger forces
Octaves 2 (Procedural only) : Number of noise layers blended together to produce the final noise
Lacunarity 0.5 (Procedural only) : Scale (zoom) factor between each noise octave.
Gain 0.5 (Procedural only) : Scale (intensity) factor between each noise octave.
Interpolator Cubic (Procedural only) :
  • Linear : Fastest interpolator. lowest quality. Turbulence abruptly changes values.
  • Cubic : Medium-quality interpolator.
  • Quintic : Best-quality interpolator. produces smooth continuous turbulence. Slower than Cubic.
Particle sampler turbulence Animation
TimeScale 0 (Procedural only) : Speed of the animated turbulence. 0 means no animation (TimeBase is still used), 1 means the animation loops every 1 second, 0.1 means the animation moves slower, and loops every 10 seconds.
TimeBase 0 (Procedural only) : Time offset into the animation
TimeRandomVariation 0.5 (Procedural only) : Allows individual turbulence vortices to animate at a different rate from one another. this is used as a coefficient to 'TimeScale'. 0 means the strict TimeScale is used. 0.5 means a timescale randomized between (TimeScale - 0.5 * TimeScale) and (TimeScale + 0.5 * TimeScale) is used.
Particle sampler turbulence Advanced
FlowFactor 1 (Procedural only) : Allows the user to smoothly choose an intermediate representation of the flow, between a divergence-free, and curl-free flow.
DivergenceFactor 0 (Procedural only) : Allows the user to smoothly choose an intermediate representation of the flow, between a divergence-free, and curl-free flow.
InitialSeed 1114229502 (Procedural only) : Initial seed that's used to randomize the noise
FastFakeFlow false (Procedural only) : For extra speed, check this. however, the flow's quality will be pretty poor.
DefaultSampledField Curl (Procedural only) : For fluid-like flow/turbulence, keep the default value: 'Curl'.
GainMultiplier 1 (Procedural only) : Multiplier applied to gain.

WARNING: Setting this above 1.0 will can produce unstable noise. Prefer tweaking gain in its [0,1] range and not using GainMultiplier

Turbulence sampler properties


The turbulence sampler will render a preview of the noise in the 'ParticleNode Editor' panel. This preview is a slice on the X/Y plane in the 3D noise. However, the synthesized noise is isotropic, so slices on other planes are equivalent.

You can:

  • zoom in/out this preview by using the 'zoom' slider.
  • change the field viewed by clicking on the drop-down on the left-side of the menu toolbar, next to the zoom slider. You can choose between 'Curl' and 'Potential'
  • change the preview size by right-clicking in the particle node editor, you'll have the choice between 256*256 and 640*320:


Turbulence preview : small Turbulence preview : large


Particle sampler turbulence Script bindings

for each sampler, the following is published to scripts:


float	sample(float3 location);
float	sampleCurl(float3 location);
float	samplePotential(float3 location);

the 'sample' function redirects to either 'sampleCurl' or 'samplePotential', depending on the value of the 'DefaultSampledField' attribute. By default, it samples the curl.


NOTE: as the procedural turbulence samplers sample an infinite turbulence field, the input location can be any position in 3D space, without bounds.
However, note that extremely large positions (1.0e+8 and above), or extremely large scales, might lead to imprecisions in the sampled results.


Particle sampler turbulence Examples

Basic particle grid using the turbulence sampler, with a capsule billboarder stretched along the velocity vector to visualize the flow field:

Particles in the flow field : capsule billboarder Particles in the flow field : Debug vectors
capsule billboarder debug velocity visualization


Here are the different interpolation modes (Linear, Cubic, Quintic), for each possible field (Curl, Potential, and FastFakeCurl (activated by checking the 'FastFakeFlow' checkbox)
Linear is the fastest, Quintic gives the smoothest movement when the sampler is used as a velocity field for particle movement, for example through the physics evolver.
between 'Curl' and 'FastFakeCurl', 'FastFakeCurl' is the fastest of the two, but gives the lowest quality turbulences.


Linear Cubic Quintic
Curl Curl-Linear Curl-Cubic Curl-Quintic
Potential Potential-Linear Potential-Cubic Potential-Quintic
FakeCurl FakeCurl-Linear FakeCurl-Cubic FakeCurl-Quintic


Here are a few examples, tweaking some parameters:


1 octave 3 octaves 6 octaves
Octaves: 1 Octaves: 3 Octaves: 6
Changing scale and strength Changing gain and lacunarity
Ocaves: 2
Scale: 0.1
Strength: 1.0
Octaves: 2
Lacunarity: 0.05
Gain: 0.02


Particle sampler turbulence Performance

This is one of the most expensive samplers. In order to maximize performance, there are a few things you should be aware of:


  • The 'Octaves' parameter is what impacts performance most. it is DIRECTLY related to the amount of work the sampler needs to do.
Double the number of octaves, it will double the time it takes to compute the turbulence.
Generally, two octaves are sufficient for most cases. you might even get away with a single one for particles that don't live very long.
However, the less octaves you have, the less varied the noise will be.
  • The interpolation type affects performance, but a lot less than the octave count.
Cubic should be enough for most uses. Use Quintinc if you want high-quality velocity fields and really smooth particle movement.
  • Sampling the 'Potential' field instead of the 'Curl' field is significantly faster, but you won't be able to get a velocity field out of it.
  • 'FastFakeFlow' is faster than 'Curl', but the quality is so impaired that it probably isn't worth it.
  • Using noise animation has a negligible impact on performance, you can use it whenever you like.