|
As a consequence of this, we may
be able to increase resolution in the transparency calculation by normalizing
the alpha channel in the particle texture and globally modulate it with the
VolumeAlpha value.
This also allows us
to globally change the transparency of all the particles.
The alpha channel now defines the
deviation ratio from the mirror plane to the extents. The particle extents from the camera in real
world coordinates is defined as ParticleDepth -/+ DeviationExtent. The actual particle volume boundary is
defined as ParticleDepth -/+ TextureAlpha * DeviationExtent.
With these tools we are now able to
define a more accurate representation of the occluding properties of particles
with objects behind, within and in front of the particle.
I will calculate the
actual alpha value based on the previous derivation.
FarParticleDepth = ParticleDepth + TextureAlpha * DeviationExtent * 0.5;
NearParticleDepth = ParticleDepth - TextureAlpha * DeviationExtent * 0.5;
The average density calculation:
// Get the Environment Depth in terms of the volume, values we are interested
// in are in the range 0 to DeviationExtent.
Alpha = (EnvironmentDepth – ParticleDepth)/(DeviationExtent);
// Clamp the value to 0..1
Alpha = VolumeAlpha * Clamp( Alpha, 0.0, 1.0 );
// Get resultant pixel
OutputColour = Alpha * ParticleColour + (1.0 – Alpha) * SourceColour;
The density extent calculation:
// Get the Environment Depth in terms of the volume, values we are interested
// in are in the range 0 to DeviationExtent.
Range = (EnvironmentDepth – ParticleDepth)/(DeviationExtent);
// Scale this range based on the alpha value defined for the pixel
Range = Range * (1.0/ParticleAlpha);
// Normalize the value to -1..1
Alpha = Clamp( Range, -1.0, 1.0 ) * 0.5 + 0.5;
Alpha = Alpha * VolumeAlpha;
// Get resultant pixel
OutputColour = Alpha * ParticleColour + (1.0 – Alpha) * SourceColour;
These algorithms will perform the simple interpolation
method as has been performed in hardware for years for cases when no collision
occurs. For cases when the particle's
volume does collide with environmental geometry, this algorithm will ramp the
particle's contribution to the background contribution based on the amount of
the volume obscured by the background.
Fig 3. A screen grab from the chrome dragon engine using the average density method. (Using the exact same art as in Fig 1.)
Fig 4. A screen grab from the chrome dragon engine using the density extent method. (Using the exact same art as in Fig 1.)
One thing to keep in mind when implementing this particle
rendering method is that you are rendering a representation of a volume and
that the depth of the volume is most likely related to the other dimensions of
the particle. It is probably appropriate
that some function relating particle size to depth be defined on a per-particle
basis.
An
additional note about the density extent method is that the volumes will use
the alpha channel to define the extents of the volume on a per-pixel
basis. Unfortunately most art defining
particles to simulate volumes use a gradient method from the center of the
texture, which will define the volume roughly as a wedge shape.
As you can see in Fig 1, many of the
particles seem to have a kind of soft-aliased look to them with the unmodified
art. For this approach to have visual
merit, the source art may need to have the alpha component of the texture
defined with true volumetric properties.
This approach can be extended to:
- Encode
a deviation from the mirror plane into one of the channels of the texture. This allows the author to define an
alternate depth median, by specifying the mirror point as a deviation from
the original particle plane.
- Encode
volume normal information into the other 3 channels of the texture and
pass in the volume colour as uniform for the whole particle. This allows some real-time lighting
information to be rendered as part of this shader.
Current particle rendering methods for volumetric
particles in games are flawed, its acceptance will die out quickly and it is
fixable using shaders in current generation hardware.
What is more, the proposed modification to
existing rendering methods require few changes from the art department, adds a
small amount of registers to the shader, adds a small number of shader
instructions, and may not require significant changes to the existing rendering
engine in your game.
Most importantly,
the rendered particles will better represent the intended vision the artist
while allowing for the number of particles to be decreased in the process.
Bibliography
Spherical Billboards for Rendering Volumetric Data - ShaderX 5 - Thomas Umenhoffer, Laslo Szirmay-Kalos and Gabor Szijarto
Volumetric Post-Processing - Game Programming Gems 5 - Dominic Filion, Artificial Mind & Movement, and Sylvain Boissé, Motorola
OpenGL Shading Language (Orange Book) - Randi J. Rost
[EDITOR'S NOTE: This article was independently written and commissioned by Gamasutra's editors, since it was deemed of value to the community. Its publishing has been made possible by Intel, as a platform and vendor-agnostic part of Intel's Visual Computing microsite.]
|
I'm also interesting in learning more about "Baked" particle animations like the ones found in WOW. Is there a package out there that allows the particles system to be baked in?
My implementation uses the extinction factor to calculate the alpha value, which is a bit more physically based, and optionally also does a short ray-marching (for shadowing and non-homogeneous media). I called them 'thick particles'.
Unfortunately, from my experience, the default soft particles are usually preferable. At least in scenarios where the improved physical correctness isn't needed - and that includes almost all applications in games. Simply because they essentially do the same thing but are cheaper to render and easier to tweak for artists.