CParticleRenderer Billboard

From PopcornFX
Jump to: navigation, search

Billboard renderer Last update: v1.10.0 - Main page : Particle renderers Particle renderers


This is the most used particle renderer. It displays the particles as textured sprites.
It has various options to control how the particles are displayed, rotated, scaled, which texture is mapped on them, etc...
This renderer is supported in all of our public engine integrations.


Billboard renderer Node properties

Field name Default value Description
Billboard renderer Material
UserData <empty> User string. You can write anything there to provide more information to your game than what's available in the standard renderer node properties.
BillboardingMaterial Additive
  • Additive
  • Additive_NoAlpha
  • Additive_Soft
  • AlphaBlend
  • AlphaBlend_Soft
  • AlphaBlend_Lighting
  • AlphaBlend_SoftLighting
  • AlphaBlend_Distortion
  • AlphaBlend_Additive_Soft
  • AlphaBlend_Additive_SoftLighting
Diffuse <empty> Path to the texture that should be used for the diffuse color
Normal <empty> Path to the texture that should be used for normalmap, for lit materials (optional)
AtlasDefinition <empty> Path to a .pkat file containing the coordinates of the sub-rects in the atlas
AlphaRemapper
<empty>

Path to the texture used to remap the Diffuse's alpha. Pseudo-shader looks like: newAlpha AlphaRemapper.sample(float2(Diffuse_color.a, AlphaCursorField)).r;

SoftAnimationBlending false If active, the renderer will use the fractional part of 'TextureID' to blend between the two adjacent atlas sub-images
CastShadow false v1.9.0 If active, particles will cast shadows (NOT IMPLEMENTED in the PopcornFX Editor!)
Billboard renderer Geometry
DrawOrder 0 Rendering order index of the particle. Defines the order in which the particles are rendered. Smaller values will be rendered first.
BillboardMode ScreenAlignedQuad
  • ScreenPoint : Deprecated, do not use
  • ScreenAlignedQuad
  • ViewposAlignedQuad
  • ScreenAlignedTriangle : Deprecated, do not use
  • VelocityAxisAligned
  • VelocityCapsuleAlign
  • VelocitySpheroidalAlign
  • PlanarAlignedQuad
VFlipUVs false If enabled, the texture UVs will be flipped vertically
ConstantRadius 0 constant radius added to the particle size.
AspectRatio 1 Billboard aspect ratio. Ratio of 'X' over 'Y'. 'Y = X / AspectRatio'. For example, a width of 1.0 and a ratio of 2.0 will produce a height of 0.5. A width of 0.8 and a ratio of 0.4444 will produce a height of 1.8
PositionField Position v1.7.0 Name of the float3 particle field to be used as the billboard position.
SizeField Size Name of the float OR float2 particle field containing the particle's billboard size (radius), in world units. the 'ConstantRadius' field is added to the size to compute the final billboard size. if the SizeField isn't found in the particle fields, only the constant radius is used.
ColorField Color Name of the float4 particle field containing the RGBA color of the particle. if it's not found inside the particle fields, a white color will be used.
TextureIDField TextureID Name of the float particle field containing the index of the atlas sub-rect that should be used for this particle. if no atlas, this field is ignored. if the field doesn't exist but an atlas is present, the sub-rect 0 is used
AlphaCursorField LifeRatio v1.9.0 Name of the particle field used to index the Y/V axis of the AlphaRemapper texture.

Must be a float between [0, 1]. Pseudo-shader looks like: newAlpha AlphaRemapper.sample(float2(Diffuse_color.a, AlphaCursorField)).r;

RotationField Rotation v1.7.0 Name of the float particle field to be used as the billboard rotation angle.
AxisField Velocity Name of the float3 particle field containing the axis the billboarder should use for axial billboarding
Axis2Field <empty> Name of the float3 particle field containing the second billboarding axis for planar billboards
AxisScale 0.1 Axis scale factor used by axial billboarders. for example, if a particle is billboarded along its velocity vector, and the velocity has a magnitude of 15 units, and the axis scale is set to 0.1, the billboard will have a length of 1.5 units.
SoftnessDistance 1.0 v1.9.0 fade distance of soft-particles. only taken into account if a '_Soft' material is selected

for example, a value of 5.0 means the billboard pixels will start fading when the scene depth is closer than 5 world units to the billboard plane.

Billboard renderer Lighting
NormalsBendingFactor 0.5 Controls how much the billboard normals will be 'bent' with respect to the plane normal.

0 means no bending, normals are equal to the plane normal.
1 means fully bent, normals lie on the plane and point outwards, away from the billboard center

NormalsWrapFactor 0.1 Material-specific, remaps the [-1,1] 'n dot l' of the lighting equation to ranges going from [-1,1] to [0,1]. A high value will give the effect of light bleeding through the billboard rim.
LightExponent 1 Material-specific, exponentiation of the lighting term
LightName GlobalLight Name of the light to use for lighting. by default, the particle editor creates a scene with a light named "GlobalLight"
LightScale {1,1,1} Material-specific, Multiplier applied to the incoming light
AmbientLight {0.1,0.1,0.1} Material-specific, Uniform ambient light
Billboard renderer layout


Billboard renderer Billboarding modes

ScreenAlignedQuad

4 vertices / 2 triangles per particle


A screen-aligned billboard has its plane parallel to the screen plane. Looking around and rotating the view camera change the billboard order, and if intersections with the world geometry are obvious, you will have the strange impression that the sprites "swim" around the screen. changing the camera position without touching its orientation won't change the billboard order.


It is the cheapest billboard type to compute.


Billboard renderer : screen-aligned quad Billboard renderer : screen-aligned quad


ViewposAlignedQuad

4 vertices / 2 triangles per particle


A viewpos-aligned quad has its plane normal pointing towards the camera position. Unlike screen-aligned quads, looking around does not change the billboard geometry, and the sprites appear solidly anchored in the world's volume, without strange swimming artefacts. However, changing the camera position without touching its orientation will rotate the sprites, as they face towards the viewer's position.


Billboard renderer : viewpos-aligned quad Billboard renderer : viewpos-aligned quad


ScreenAlignedTriangle

3 vertices / 1 triangles per particle


This is mainly to be used if rendering is vertex-bound. Experimental.
Doesn't work well with texture atlases in the editor viewport unless there's enough empty space in the atlas. (Could be fixed using texkill in the shader when UVs are out of bounds)


Billboard renderer : screen-aligned triangle Billboard renderer : screen-aligned triangle


VelocityAxisAligned

4 vertices / 2 triangles per particle


This billboard mode's name can be a bit misleading, as it is not limited to velocity alignment. By default, the billboarding axis is set to the particle field 'Velocity', but you can actually supply any other axis through the 'AxisField' property of the billboarder.
The billboard's vertical axis at 'u = 0.5' is constrained to the axis 'AxisField'. The billboard rotates around that axis to try facing the camera.


This is the fastest axial billboarder, but artefacts start appearing when the axis becomes near perpendicular with the screen plane: the fact that the sprite is in fact a quad becomes pretty apparent, and at near perpendicular angles, as the quad is seen from the side, it can entirely disappear. see the images below.


Billboard renderer : velocity-axis aligned quad Billboard renderer : velocity-axis aligned quad


VelocitySpheroidalAlign

4 vertices / 2 triangles per particle

Like the other axial billboarders, this billboarder is not limited to Velocity alignment, and can use any other axis for billboarding.


Unlike the VelocityAxisAligned billboarding mode, this one doesn't suffer from the grazing-angle problem, where the particle appears to vanish when the billboarding axis becomes near-perpendicular with the screen plane.
Instead, this billboarder emulates a spheroid, and bounds the screenspace projection of the spheroid with a quad. This fixes the artifacts of the VelocityAxisAligned mode.
Note that in order to achieve this, the texture will appear to rotate unexpectedly if it is not rotation-invariant. For example: you will see this on a cloud texture, but not on a circular glow texture like the one used in the screenshots below.


Computational cost is almost the same as the VelocityAxisAligned mode, for the CPU billboarding implementations, on all the platforms.


Billboard renderer : velocity-spheroidal aligned quad Billboard renderer : velocity-spheroidal aligned quad


VelocityCapsuleAlign

6 vertices / 4 triangles per particle

Like the other axial billboarders, this billboarder is not limited to Velocity alignment, and can use any other axis for billboarding.


Particles rendered using this billboarder, like the VelocitySpheroidalAlign, won't seem to disappear at grazing angles.
Stretches the texture on its diagonal.


Computational cost is a bit higher than the other billboarders.


Billboard renderer : velocity-aligned capsule Billboard renderer : velocity-aligned capsule


PlanarAlignedQuad

4 vertices / 2 triangles per particle

Planar aligned billboarders use two axes for billboarding: like the axial billboarder, a main axis, lying on the plane, and the plane normal vector.

Billboard renderer : planar-aligned quad Billboard renderer : planar-aligned quad Billboard renderer : planar-aligned quad
'AxisField' = green vector

'Axis2Field' = red vector (plane normal)


Billboard renderer Builtin billboarding materials

We'll use the following naming conventions for 'SRC', 'A', and 'DST'

Billboard renderer Billboard renderer Billboard renderer Billboard renderer
SRC = texture color modulated by the particle color A = texture alpha modulated by the particle alpha DST = framebuffer color RG = distortion vectors, B = blur coefficient


Billboard renderer Additive SRC * A + DST (Linear Dodge in Photoshop)
Billboard renderer Additive_NoAlpha SRC + DST (Linear Dodge in Photoshop)
Billboard renderer Additive_Soft SRC * A * D + DST
Billboard renderer AlphaBlend SRC * A + DST * (1 - A) (normal Opaque blending in Photoshop)
Billboard renderer AlphaBlend_Soft SRC * A * D + DST * (1 - A * D)
Billboard renderer Distortion Distortion and blur need the corresponding PostFX activated, see the Editor overview page, button no.12
Billboard renderer AlphaBlend_Additive SRC + DST * (1 - A) (Premultiplied alpha)
Billboard renderer AlphaBlend_Additive_Soft SRC + DST * (1 - A * D) (Premultiplied alpha)


Note that for correct sorting to take place between alpha and additive particles, you'll probably want to use the premultiplied alpha mode (AlphaBlend_Additive).


Billboard renderer Atlas definitions

The atlas builder is used to create the atlas definition files.

It is a separate binary 'AtlasBuilder.exe', in the same directory as the main editor 'PK-Editor.exe'.


AtlasBuilder 01.png


Please see the Atlas builder page for more details.


Once loaded, atlas definition will have its sub-rects displayed by the billboard renderer in the 'ParticleNode Editor'. The sub-rects are displayed as red rectangles, with their ID displayed at their centers:

Billboard renderer Billboard renderer Billboard renderer
Default view, displays RGB colors Full view, after activating the alpha button per-channel view (here, just the Green channel)