Intro
Hello fellow artists!
I have embarked on the journey of learning VFX art since some months now. During these times I have created a lot of different shaders that i then used to make some of my effects. As the time went on, I started to spot more and more similarities between the different shaders. A few days ago, I have converged on a single shader that has allowed me to create this explosion effect.
Together with the kit, I have included a number of meshes with different types of UV unwrapping and pivots, which allowed me to create the different particle systems with the same spatial shader.
The shader
This master shader works for a variety of different particle types, from fully 3D particles with heightmaps and meshes, to billboard flipbooks. Most parameters are not meant to be used all together, for example panning the texture over the particle life doesn’t make much sense if particle animation is enabled.
Textures
This shader supports two separate textures for particles and different ways of mixing them. Additionally, the textures can be made to pan on different directions in the UV space.
mix mode
mix strategy for the textures. 0 means multiply, 1 means add.texture1
first color texturetexture1 offset
offset for the first texturetexture1 scale
scale for the first texturetexture1 pan direction
direction in which the first texture should pan, in UV spacetexture1 pan speed
speed of the panning for the first texturetexture2
second color texturetexture2 offset
offset for the second texturetexture2 scale
scale for the second texturetexture2 pan direction
direction in which the second texture should pan, in UV spacetexture2 pan speed
speed of the panning for the second texture
In the following image, from left to right
- Two textures, one panning, one static acting as a mask. Mix mode 0
- Same textures as the previous one, but with mix mode 1
- Two different panning textures, mix mode 0
- Two different panning textures, mix mode 1
Emission
One of the biggest features that I missed in the spatial material was the ability to animate the emission value over the life of the particle. The shader introduces two parameters to control emission.
emission energy
: the overall emission energy of the particlesemission over life
: a curve that describes how the emission behaves over the lifetime of the particle.
Alpha control
Fading alpha is cool but have you heard of alpha erosion?
There are multiple ways of doing it, and I tried to include the most common in the shader.
The behaviour of the shader is different depending wheter or not you have enabled the alpha erosion
property, which is on by default.
The behaviour of the alpha is driven by the COLOR
variable, which is assigned through the process shader with either a single color, or using a color gradient texture.
alpha
is the main alpha value of the shader to which another value is subtracted (or multiplied whenalpha erosion is off
. The particle cannot get more opaque thanalpha
dissolve texture
is the texture used as a mask to dissolve the particles. Won’t work well if the particle is animated.erosion smoothness
defines the value used later in the smoothstep. Should be 1 ifalpha erosion
isn’u used to avoid strange behaviour
From left to right, alpha erosion with low smoothness, alpha erossion with high smoothness, no alpha erosion.
Proximity fade
Proximity fade is used to avoid quads visibly clipping with opaque geometry in the scene.
use proximity fade
enable proximity fadeproximity fade distance
distance in world space to the object before the fading starts
Camera fade
Sometimes particles can look rather nasty if they are too close to the camera. Camera fade causes the particle to fade out when too close to the camera.
camera fade
enable fading based on camera distancedistance fade min
closes point where the particle is still marginally visibledistance fade max
distance above which the particle will be fully visible
Height amount
For effects such as smoke and other non-quad particles, sometimes a height map is required.
use heightmap
enable height and normalmapheight texture
heightmap of the particlenormal texture
normal map of the particle
Billboarding and rotation
The term “billboard” is used to refer to objects that always face the camera. In this shader it is a float instead of a boolean, so that the particle can be not billboard, full billboard, and a bit inbetween.
particle billboard blend
when set to 0, the particle rotation is fully substituted with the billboard rotationrotate y
workaround to rotate_y being hard to control in the process shader.
Particle animation
While there are very cool effects based on dissolve maps, sometimes they just don’t cut it (wink wink). These settings enable the usage of flipbook style animation.
use particle animation
enables the particle animationparticle anim h frames
the number of horizontal frames in the flipbookparticle anim v frames
the numger of vertical frames in the flipbookparticles anim loop
should the particle animation loopparticle animation resize
should the mesh be divided on the xy axis by the number of h and v frames.
On the left, a flipbook with particle animation resize
enabled.
On the right it is disabled, note the stretch of the image.