Added SDK 0.28.0
Encapsulates a replaceable element of a particle system responsible for rendering the particles in the system.
This object may be shared amongst many ParticleSystems.
Note
This is a low-level particle system API.
The Technique to be used for rendering particle states on the GPU.
An object defining the parameters required by this specific renderer with their default values.
The ParticleSystem will produce a copy of this object with additional fields added defined in particles-common.cgh which should not be used by this object.
Summary
Create a ParticleGeometry object compatible with this renderer.
Syntax
var geometry = renderer.createGeometry({
graphicsDevice: GraphicsDevice,
maxParticles: 1024,
shared: false
});
Summary
This function will be called by ParticleEmitters when used in conjunction with the high level ParticleManager to transform archetype userData objects into the real userData integer value.
Syntax
var userData = renderer.createUserData(parameters);
Summary
This function will be called by ParticleEmitters, and should return a particle particle userData field, containing randomized seed values if appropriate.
Syntax
var userData = renderer.createUserDataSeed();
Summary
This function will be called by the high level ParticleManager to apply a constructed ParticleArchetype to this renderer.
This function should use the constructed archetype and other parameters to specify all parameters required on system.renderParameters object specific to this renderer.
Syntax
renderer.applyArchetype(textureManager, system, archetype, particleTextures);
Implementation of a ParticleRenderer.
Renders particles as textured quads that are either bill-boarded to face camera, aligned to face along direction of motion, or with a per-particle defined direction.
Particles are rendered based on the default particle animation texture definition, supporting animated rotation, color, scale and a flip-book animation of particle appearances.
On a per-particle basis, particles can opt-in to have their rotation, final orientation, alpha or scale randomized.
On a system wide basis, the amount of randomization can be controlled, and whether each randomization applied is fixed once the particle is created, or changes over the particles life time.
Particle userData storage used
Orientation of particle is controlled with bits [30,32) as a 2-bit integer with 0 specifying a bill-boarded orientation, 1 a velocity-aligned orientation, and 2 a custom orientation.
Custom orientations are specified with bits [0,8) and [8,16) specifying two normalized, spherical angles: theta in the high 8 bits representing values [0,pi) and phi in the low 8 bits representing values [0,2pi).
To randomize the rotation of particles, bit 29 should be set.
To randomize the scale of particles, bit 28 should be set.
To randomize the orientation of particles, bit 27 should be set.
To randomize the alpha of particles, bit 26 should be set.
Bits [16,24) specifies an 8-bit integer seed used to select a path in the noise texture.
Compatibility
The DefaultParticleRenderer is compatible with the DefaultParticleUpdater in the sense that their usages of each particles userData does not conflict.
The DefaultParticleRenderer is assumed when using the DefaultParticleEmitter object.
Additionally any particle animations must use the default system for ParticleBuilder.compile supporting animation of particles rotation, color and scale, and supporting flip-book animations of particle appearances.
Summary
Create a DefaultParticleRenderer object.
Syntax
var renderer = DefaultParticleRenderer.create(graphicsDevice, shaderManager, alpha);
Summary
Set up particles’ userData storage for creation.
Syntax
var userData = DefaultParticleRenderer.createUserData({
facing: "custom",
theta: 0.5,
phi: Math.PI,
randomizeOrientation: true,
randomizeRotation: true,
randomizeScale: true,
randomizeAlpha: true,
seed: seed
});
Note
The seed parameter should be ignored when creating userData values for ParticleArchetypes, as it is the responsibility of the emitter to initialize the seed to a random value for each emitted particle.
Summary
Set up extra shader parameters required to de-normalize attributes of the particles animations when rendering.
Syntax
renderer.setAnimationParameters(system, animationDefn);
The list of technique parameters exposed by the DefaultParticleRenderer. Unless otherwise stated these are the same as the parameters supported by a ParticleArchetype using this renderer.
noiseTexture
The noise Texture to be used for randomizing appearance of particles. This noise texture should be a 4-channel smooth noise such as textures/noise.dds present in the SDK.
The particles current age will be used to look up randomized values in the texture along a pseudo-random path, therefore a higher frequency noise texture will produce higher frequency fluctuations in the randomized values used to alter the particles appearances.
Vectors are extracted from the noise texture based on treating channels as encoded signed floats (As-per TextureEncode.encodeSignedFloat).
Default value is a procedural texture defined so that no randomization will occur (ParticleSystem.getDefaultNoiseTexture)
Note
For a ParticleArchetype, this field should be a string path to the texture to be retrieved from the TextureManager rather than a real Texture object.
randomizedOrientation (Default [0, 0])
A Vector2 defining the maximum amount of randomization applied to particles orientations in spherical coordinates.
randomizedScale (Default [0, 0])
A Vector2 defining the maximum amount of randomization applied to particles scale (width/height).
randomizedRotation (Default 0)
A number defining the maximum amount of randomization applied to particles spin-rotation.
randomizedAlpha (Default 0)
A number defining the maximum amount of randomization applied to particles alpha.
animatedOrientation (Default false)
A boolean flag defining whether the randomization of particle orientations is fixed, or animated over time.
If true then the randomization will change over time according to the noise texture, otherwise only an initial sample will be made to the noise texture fixing the randomization that is applied.
animatedScale (Default false)
A boolean flag defining whether the randomization of particle scales is fixed, or animated over time.
If true then the randomization will change over time according to the noise texture, otherwise only an initial sample will be made to the noise texture fixing the randomization that is applied.
animatedRotation (Default false)
A boolean flag defining whether the randomization of particle rotations is fixed, or animated over time.
If true then the randomization will change over time according to the noise texture, otherwise only an initial sample will be made to the noise texture fixing the randomization that is applied.
animatedAlpha (Default false)
A boolean flag defining whether the randomization of particle alphas is fixed, or animated over time.
If true then the randomization will change over time according to the noise texture, otherwise only an initial sample will be made to the noise texture fixing the randomization that is applied.
texture
The Texture object, with each animations flip-book of textures packed together.
Note
This parameter is not supported on a ParticleArchetype description.