OGRE-Next
4.0.0unstable
Object-Oriented Graphics Rendering Engine
|
A new plugin called ParticleFX2 was built based on ParticleFX (from now on we'll refer to the latter as ParticleFX1).
In many ways it is backwards compatible with scripts written for ParticleFX, but there are a few differences. It is not meant to be a complete replacement, therefore it does not deprecate the older ParticleFX plugin.
Note that it is possible to use both ParticleFX1 & ParticleFX2 plugins at the same time.
local_space
.billboard_origin
.center
origin is currently supported. Although this can be improved in the future.ParticleSystemDef::clone
to clone the system definition and alter the definition.time_to_live
expires.ParticleSystemDef
can use ParticleSystemDef::setRenderQueueGroup
& ParticleSystemDef::setRenderQueueSubGroup
though.ParticleSystemManager2::setCameraPosition
, is very important for the simulation and the quota.Quota values need to be adjusted. The rationale is that the quota should reflect the maximum amount of particles the system supports and still maintain a reasonable framerate.
In PFX1, the particle count could blow out of proportions as the number of instances is potentially infinite. In PFX2, if the system can only simulate up to 10.000 particles before tanking performance, then the quota should be 10.000.
This also allows scaling to difference systems by having an Option presented to the user (e.g. Particle Count: Low, Medium, High)
Because the shared quota is a precious resource, every frame all instances are sorted by distance to camera.
The ones closer are given priority to emit. If the shared quota is exhausted, that means that far away instances won't be able to emit more. If they had emitted any particles in the past, those particles will eventually die when their time_to_live
expires.
Every frame you must call:
Only one camera position per SceneManager is supported. If rendering from multiple camera positions, consider using the most relevant position for the simulation.
This value does not control rendering. It's not instantaneous. It merely tells the simulation which systems should be prioritized for emission for this frame.
OgreNext currently supports alpha hashing to render transparents without having to care about render order.
Combined with alpha to coverage (A2C) it can produce very good results.
An advantage of alpha hashing + A2C is that it works fine with depth writes on.
The main downside however, is the "grainy" or "noisy" effect due to the nature of the effect.
The basic layman version is that when the alpha is 0.25, that means we simply (on average) render 1 pixel at 100% opacity and skip the rendering the next 3 pixels.
The material definition looks like this:
The key settings are:
alpha_hash
: Enables the setting in questionalpha_to_coverage
: Enables A2C only if the render target we're rendering to is MSAA. A2C will be combined with alpha hashing for a better quality. The Render Target must be MSAA to make use of this. Best results are with 4x MSAA.depth_write
: Normally transparents are recommended to disable depth writes. Thus an old material using alpha or additive blending may have it disabled. Remember to enable it back if you use alpha hashing.Alpha Blending (wrong sort):
Alpha Hashing:
Alpha Hashing + A2C (4x MSAA):
Note that the noise may look terrible but it quite different in motion. See Samples/2.0/ApiUsage/ParticleFX2
sample.
The Hlms implementation provide both blue noise and white noise implementations.
Blue Noise requires you include the file LDR_R_0.png
and during initialization time call:
When blue noise is not available, OgreNext will automatically fallback to a white noise implementation. Which one looks better is a bit subjective.
PFX2 relies on Math::UnitRandom
being thread safe.
If you've registered a custom random provider via Math::SetRandomValueProvider
, then make sure RandomValueProvider::getRandomUnit
is thread safe (e.g. use TLS).
scaler TBD