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.
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.
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 modemix strategy for the textures. 0 means multiply, 1 means add.
texture1first color texture
texture1 offsetoffset for the first texture
texture1 scalescale for the first texture
texture1 pan directiondirection in which the first texture should pan, in UV space
texture1 pan speedspeed of the panning for the first texture
texture2second color texture
texture2 offsetoffset for the second texture
texture2 scalescale for the second texture
texture2 pan directiondirection in which the second texture should pan, in UV space
texture2 pan speedspeed 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
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 particles
emission over life: a curve that describes how the emission behaves over the lifetime of the particle.
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.
alphais the main alpha value of the shader to which another value is subtracted (or multiplied when
alpha erosion is off. The particle cannot get more opaque than
dissolve textureis the texture used as a mask to dissolve the particles. Won’t work well if the particle is animated.
erosion smoothnessdefines the value used later in the smoothstep. Should be 1 if
alpha erosionisn’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 is used to avoid quads visibly clipping with opaque geometry in the scene.
use proximity fadeenable proximity fade
proximity fade distancedistance in world space to the object before the fading starts
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 fadeenable fading based on camera distance
distance fade mincloses point where the particle is still marginally visible
distance fade maxdistance above which the particle will be fully visible
For effects such as smoke and other non-quad particles, sometimes a height map is required.
use heightmapenable height and normalmap
height textureheightmap of the particle
normal texturenormal 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 blendwhen set to 0, the particle rotation is fully substituted with the billboard rotation
rotate yworkaround to rotate_y being hard to control in the process shader.
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 animationenables the particle animation
particle anim h framesthe number of horizontal frames in the flipbook
particle anim v framesthe numger of vertical frames in the flipbook
particles anim loopshould the particle animation loop
particle animation resizeshould 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.