- Main page : Particle samplers
The spectrum sampler allows you to sample a realtime audio frequency spectrum. You can specify which audio channel group you wish to sample. It is useful to make the particles react to audio, and supports easy-to-use convolution to sample the spectrum a different levels-of-detail.
Inside the PopcornFX-Editor, you can use the following ChannelGroup names:
Each sound that plays inside a specific ChannelGroup can be sampled by specifying it or one of its parent channels (ie. FX_Master will allow you to sample all audio data playing inside the FX_Effect and FX_Collision channel groups). However, this is PopcornFX-Editor specific, so you need to refer to your target engine's implementation documentation.
for each sampler, the following functions are published to scripts:
float sample(float cursor, int sampleFilter); float sample(float cursor, float convolution, int sampleFilter, int convolutionFilter);
'cursor' is expected to be provided in the [0,1] range. If it overflows that range, the sampler will clamp the input cursors between 0.0 and 1.0
The second overload of the 'sample' function allows you to specify for each sample a convolution level.
the 'convolution' argument will be clamped to the [0,1] range.
- a value of 0.0 means the fully-detailed spectrum will be sampled.
- a value of 1.0 means the convolution filter has the width of the whole spectrum. that is, regardless of the given cursor, you will always get a single value, that will be equal to the average of all spectrum values.
- values in-between sample downscaled versions of the full-scale spectrum, and, depending on the value of the
'Convolution'attribute, additional filtering will be performed. Pretty much like what does the graphics card when sampling a texture between mipmap levels when trilinear texture filtering is activated.
'convolutionFilter' parameters are optional. If not explicitely given to the sample functions, their default values is equal to the 'Filter' and 'Convolution' attributes set in the spectrum sampler node.
Their values can be any of the following:
spectrumFilter.Point spectrumFilter.Linear spectrumFilter.Cubic
// will sample the spectrum named 'MySpectrum' with the default filtering mode, using the particle's LifeRatio as a sampling cursor float value = MySpectrum.sample(LifeRatio); // will sample the spectrum named 'MySpectrum' with the default filtering mode, at convolution level 0.5 float value = MySpectrum.sample(LifeRatio, 0.5f); // will sample the spectrum named 'MySpectrum' with cubic filtering, and no convolution float value = MySpectrum.sample(LifeRatio, spectrumFilter.Cubic); // will sample the spectrum named 'MySpectrum' with cubic filtering mode, at convolution level 0.5 float value = MySpectrum.sample(LifeRatio, 0.5f, spectrumFilter.Cubic);
Point sampling. direct sample fetch.
Cubic bezier interpolation.
Here is an example of what happens when changing the convolution level:
Convolution level = 0.0
Convolution level = 0.35
Convolution level = 0.68
Convolution level = 0.94