You are on page 1of 10

Unity Asset Store Link: https://www.assetstore.unity3d.com/en/#!

/content/33631

Particle Dissolve Shader Package is on sale in the Unity asset store for USD 5. The package
bundles 2 sets of assets, the dissolve shaders for particle system and particle effect library with
customized textrures. Please watch our web player demo (direct unity3d link) and give us feedback or
suggestion. If you want to include any particle effects which may suit the dissolve shader but not shown
in the demo, you can make the request too.

 Why should I buy this package?


Because with Unity’s built-in particle shaders, your ability of making particle effects with greater variety
is limited at using genuine animated textures which has the major drawback of enlarging your software
size tremendously. It is fine for triple A games, but not so for any game without that investment when
large software size could turn potential customers off.

The aim of Particle Dissolve Shader package is to offer a solution which helps elevate that variety
without introducing something drastically different to game development. Unity users can still use their
familiar particle engine and their existing particle effect library in pretty much the same way as before.
By simply replacing the shader of the existing particle material with our particle dissolve shader and
some tweak to particle emitter values, your old effect suddenly looks excitingly crisper without too much
decline of performance. Development team with limited resources can reserve the decision of trying out
brand new particle engine, because that requires more time and energy on learning something
completely new. Unity’s Shuriken particle system is basic but powerful and resource-friendly. You
probably have not yet use it thoroughly before bidding adieu.

You can definitely combine our particle dissolve shaders with other particle-related assets, the
possibility is endless. This package simply provides a valuable shortcut and new assets to your arsenal.
FAQs
 Do I need Unity Professional edition for this?
No. This entire package is developed with Unity “Personal” (loosely “free”) edition. The particle system
is part of the Personal edition feature. If you have Unity Professional edition, you can apply bloom or
heat haze effects on the particle effect to enhance the visual if needed. We do not, so these image
postprocessing effects are not in the particle effect library.

Unity Personal edition is not free if you make a great deal of money with it.

 What version of Unity is required?


Unity 5 or onwards. We started out with Unity 4, but once we moved on to 5, the shaders and prefabs
have been updated automatically by Unity, so they are not compatible with older versions. “Shader
feature switch” is a Unity 5 exclusive feature, but legacy shaders are included just in case.

 Can’t I just use the built-in cut out shaders for the same purpose?
Sorry but technically no. Neither the built-in Standard Shader nor legacy cut out shader accepts alpha
value from particle system to manipulate the cut out power.

 How is the performance on various platforms?


We have limited resources for testing, but dissolve shaders perform well at 60 FPS on up-to-date
platforms including mobile devices which are meant for playing latest graphics-intensive mobile games.
Devices (mobile or desktop without adequate display card) manufactured before 2011 generally
perform poorly (below 25 FPS in standard resolution), that is the whole reason for providing the
“mobile” particle effects. You can check the web player demo for testing performance in your computer.

Batching of SetPass (Draw) calls of particle dissolve shaders behave the same way as other Unity built-
in particle shaders. The cut out transition does not use “alpha testing” so it is viable to use dissolve
shaders on mobile device sparingly at decent frame rate.

Because particle dissolve shader is essentially transparency blending shader, which is known to
hamper performance significantly when used extensively on mobile platforms, any transparent or
dissolve particle effect activated in the mobile game is preferably one-off or not overlapping each other.
A brief moment of slight lag is better than a constant slowdown. You may try another approach for
rendering long-lasting effects (if they are abundant in the same shot) or the particle size and emission
rate should be decreased for fewer and smaller superimposition/overdraw of transparent geometries.

Package contents
Particle dissolve shaders: These use the alpha from the texture to cut out texture visibility. The cut
out transition can be controlled via “color(alpha) over lifetime” in the Unity default (Shuriken) particle
system for smooth transition. The shader is splitted into 2 variants: Additive and alpha blended. Both
shaders provide 5 variants in the form of parameters similar to the “Standard Shader” introduced in
Unity 5 in order to reduce loading time. Individual variant shaders are included in case you want to use
them in older Unity which does not support shader feature switch.
 “Soft dissolve” (or so-called “soft-edge”) fades the cut out transition smoother instead of sharply
for more realistic approach. (Not to be confused with the expensive “soft particle” which fades
out the intersection of the particle plane with other geometry.)
 “Opacity” provides a slider for changing the transparency of the whole texture. The process
takes place after the cut out. It is useful when you do not want the texture to appear “solid”. This
is the only way to directly control the general opacity of the texture because the alpha value
received from the particle system has already been used for cut out.
 “Soft rim” reduces the alpha value of each face of the mesh when it faces away from the camera
so you will not see the sharp angle of the texture. This is used solely for mesh particle. Do not
use this on billboard particle because it will fade out the billboard incorrectly at certain camera
angle. (This variant also comes with non-dissolve versions under the “particle softrim” shader
menu.)
 “For stretch billboard” is only meaningful when “soft rim” has already been enabled. Use this so
the stretch billboard particle will fade out alpha when you rotate the camera vertical to the
ground. Examples can be seen in the “fire basic” and “fire fuel” effects.
 “Edge” allows you to define a specific color of the dissolving edge. You can also load a gradient
texture for more vibrant transition.

Particle effect library: All particle effects in the “prefabs” folder are customized for dissolve shaders.
You can use them straightaway or modify them however you like. All effects are assembled with Unity
default particle system so there is no additional asset required. Each effect comes with 4 variants:
fallback, mobile, sharp and soft. “Sharp” uses the basic dissolve shader without any variant; “soft” uses
the soft dissolve variant; “fallback” uses Unity default mobile/particle alpha blended shaders. Although
you can change shader of the material yourself, few values of all 4 effect variants differ to various
extents for suiting the shader primarily used. Fallback variants are included in case transparency
transition is preferred over cut out.

Mobile variants are created with mobile platforms in mind so their emission rate and materials are all
stripped down to what we think are acceptable in terms of graphics and performance. Only built-in
mobile particle additive shader is used because it does not require an additional alpha channel of the
texture. (Dissolve shaders requires alpha channel from the texture and “alpha from grayscale” creates a
new alpha channel or replace the existing one, so it still adds pressure on performance). Particle
textures are all smaller and arranged in the same texture sheet for batching SetPass calls even more.
Here is the web player demo of the mobile particle effects.

Technical Instructions
 My texture looks weird with dissolve shader.
When using Dissolve shader, whether the texture is for additive or alpha blended, if your texture has
black background, you should check “alpha from grayscale” in the texture inspector. This will create a
black/grayish rim when using any alpha blended shader. Preferably, you should make the background
transparent without any trace of background color, then uncheck “alpha from grayscale” but enable
“alpha is transparency”.

 The cut out transition does not fade out smoothly at the end.
Firstly, make sure the texture does not have considerable area of the same highest brightness. You can
use eraser, smudge, blur or burn tools with low hardness in Photoshop or GIMP to dampen those
spots. Secondly, in the “color over lifetime” module, add one new alpha arrow just before the last zero-
alpha arrow. Then slide it away from the zero-alpha arrow and check the preview until you are satisfied

with the result.

 Some particle suddenly pops up in front of another particle.


This is a well-known issue with any non-additive alpha blending mode. Because dissolve shaders use
the same alpha blending mode, there is no way to fix that perfectly without alpha testing which kills
mobile devices. You have few options to avoid or alleviate the pop-up glitch, each with its pros and
cons. The most popular workaround is to use "sorting fudge" (lower/negative value makes the particle
more likely to appear before others) which is in the "renderer" module of the particle component. "Sort
mode" seems to only affect particles of the same system, but we usually set "by distance" anyway.
Starting from Unity 5, there is the "sorting layer" and "order in layer" options. Either way, using the sort
method means particles of one system (mostly) always appear before another particle system in close
proximity, this can be undesirable in some case.

Another workaround is to use no more than enough particles and avoid too many particles of multiple
emitters to stack together, even on up-to-date platforms. If your effect requires lot of alpha blending
particles to overlap each other, you are probably doing it wrong. You only stack multiple particle
emitters if pop-up is not too glaring (or like in our effects that most of them are covered by additive glow
texture on higher camera depth). If stacking is necessary and pop-up is getting too severe, use the sort
solution.

The last (but not least) option is to use additive blending mode only. Sadly the whole effect will look
unrealistic because ideally additive should be used on material which ONLY emits light. Flame in real
life emits AND receives light (so it is not quite realistic to use any unlit shader for flame material in the
first place). The body of flame turns dull (lit by the ambient light) or black when it no longer emits light.
Also additive objects do not look good on brighter background when stacked, you basically see nothing
but pristine white. Since all mobile variants of particle effects in the package use additive shader for the
sake of performance, your scene where the particle effect activates should have the brightness of
background lowered to underline the effect.

 Why should I care about SetPass (Draw) call?


Read the official manual for explanation. The more calls issued in one scene, the greater demand on
performance. Normally rendering 1 object in the scene requires 1 call. However, each particle emitter
usually results in 1 single call no matter how many particles emitted.
To batch calls (helps reduce resultant calls) when rendering multiple billboard particle emitters, you use
the exact same material rendered by the same camera. If you have different billboard textures which
use the same shader (e.g. particle/additive), arrange them in the same texture sheet (ideally the texture
sheet dimension should remain as a square). Now create a material which loads this texture sheet and
all emitters should use this single material for batching. Enable “texture sheet animation” module in the
particle component. Set the correct division of tiles and then use “whole sheet” and set “constant”
of “frame over time” to locate the desired tile of texture. Index 0 means the first upper-left tile in the
texture sheet, the next tile is the one on right. When the first row ends, it turns to the lower next row and
continues the counting from left. In a 4×4 texture sheet, the last bottom-right tile is indexed 15 instead
of 16. You can further subdivide the texture sheet which has already been divided into larger tiles for
including more smaller particle textures, you just set greater division in “texture sheet animation”
module and use different counting of tiles as shown in the “particle texture sheet” in the package. Tiles
of particle texture sheet are usually square instead of rectangular for easier division and counting.

SetPass calls are issued separately per camera, so only billboard particle emitters rendered by the
same camera can be batched. Certain scripts mounted on the particle system prefab also prevents
batching.
SetPass call of mesh particle can never be batched (not to mention “texture sheet animation” module
does not work on mesh particle) even if it shares material with other emitters, so mesh particle should
be used on mobile devices sparingly.

 How to reduce the texture file size?


In the texture inspector, you can simply set smaller “max size” than the original dimension of the texture
and then click "apply". Enabling compression also helps.

You can also edit out the variations in the texture sheets like “flame”, “smoke” and “water”. For
example, if you reduce “flame” texture from 4×4 (16 tiles, 1024×1024 px) to only 2×2 (4 tiles, 512×512
px), then change the values in "texture sheet animation" module of particle system to X=2, Y=2 and
"frame over time" to 0 and 3.

If you have trimmed the texture sheet with only 1 tile left, you can remove or uncheck the "texture sheet
animation" module. But it is better to merge it with other remaining particle textures which use the same
shader into one single texture sheet for batching calls.

 The amount of particles differs between preview and play modes.


This issue occurs in effects like explosion because they use “sub emitters” module to control emission
of the “slave” emitters for cohesive animation. Particles in the preview will appear a lot more than in the
play mode. Nothing we can do to fix that. You should always refer to the play mode as your final result.

Speaking of sub emitters, you do not have to place the slave emitters as a child prefab under their
respective “master” emitter, which is the default setting if you create new sub emitter in that module.
Not least because it prevents you from editing the slave emitter in the project browser when it is in the
third or greater descendent prefab of its top ancestor.

 What’s with that always-on-top glow?


The glow in the effect library are mostly in the TransparentFX layer. In the demonstration scene, this
layer is solely rendered by a different “fx camera” as a child prefab to the main camera with higher
depth than the main one.
This is for forcing the glow always being rendered before everything else without worrying about alpha
sort not doing its job properly (yes, this happens occasionally) and avoiding intersection between the
glow billboard and other objects like the ground and ceiling. The idea is similar to lens flare but the glow
can be controlled via particle system. The drawback is obviously that the glow will still cover other
unintended diffuse objects which are before the glow. The workaround is to decrease the farthest point
of clipping plane of the fx camera (40 in the demo scene), but the particle will disappear suddenly when
it is out of range. In an open area, this presents little issue. but in a narrow space, you may change the
glow layer from TransparentFX to “default”. The sorting fudge of the glow particle emitter has already
been set properly so it should always appear before other particle emitters of the same effect.

Still rendering glow particles on higher camera depth is unrealistic because the additive glow will stack
(assuming you are not using just 1 glow particle) at certain camera angle, it causes the alpha blending
textures behind the glow to lose most of their definition. “Fire fuel” effect in the package use the softrim
stretch variant to solve this issue but this workaround is not suitable for any effect whose position is not
fixed like “Flamethrower”.

“Fire basic” uses actual lens flare instead of glow particle because the effect is quite static. This method
is more suitable in narrow space because the glow will fade smoothly when interacting with diffuse
objects. In an open (unpopulated) area, the glow will look oversized when the camera moves away
from the source of lens flare because it does not scale down its size as other objects shrink in view
(apparently not an issue if you cap the camera zoom out distance from the field and turn off camera
rotation like in most dota games). This can be partially fixed by adjusting the clipping plane of the
camera which contains “Flare Layer”. This component has been moved to the fx camera for better
organization in the demo scene.

Again, if you have Unity Pro, just replace the glow and lens flare with bloom effect for more realistic
visual.

Tips
 My effect does not simulate with other effects under the same prefab.
If you want all particle effects under the same ancestral prefab to simulate together in the preview
mode, add a particle system component to that ancestral prefab but remove or uncheck all its modules
and Voila! Be careful not to add the legacy particle component instead.

 Speed, velocity or force?


Shuriken provides 3 different parameters for controlling particle motion for a very good reason:
Interaction. It does not matter if the effect will not be moved around. However, for effects like firearm
smoke or flamethrower whose emitters are supposed to move and rotate drastically, you will need
these parameters to simulate different stages of particle motion.

For instance, the flamethrower effect first ejects particles aligned to the direction of the emitter, so you
set positive “start speed” and “simulation space” to “world”. Then the particles will rise upward due to
the heat, so you enable either “velocity over lifetime” or “force over lifetime” modules and set positive Y
value and their simulation space to “world”. That way the particles will always rise upward no matter
which direction the emitter is facing at.

“Force” will dampen the original motion while “velocity” does not, so for gradual rising you only need
constant value for force but curve for velocity. Velocity is useful if you just want the change of motion
kicks in instantly without delay. For simulation of Brownian motion, enable “force over lifetime” module,
change its value type to “random between 2 constants/curves”, set the motion range and check
the “randomize” box.

 Stretch billboard particles do not act as intended...


If the texture is going to be used in stretch billboard particle emitter, that texture should be facing
leftward. Assuming the original texture is facing upward at 0° on normal billboard, the texture should be
rotated counterclockwise by 90° in external graphic editor first for stretch billboard. Counterintuitive, I
concur.

 Brightness and smoke of fire


“Clean” fire is brighter and creates fewer dark smoke, or vice versa. The cleanness is mainly
determined by the carbon dioxide produced during burning due to the carbon content of the substance
being burnt and the amount of oxygen present.

 Color of flame
Please read the Wikipedia article and stop making blue flame because rumor says that blue flame is
always hotter than red/yellow, this is not entirely false but terribly inaccurate.

 Glow
Glow is the result of light beams being absorbed and refracted by elements before reaching the retina
of eye or camera. Glow is more prominent in dusty, humid or hazy environment, otherwise the glow is
smaller and sharper. Window, cornea and lens which are impure are also factors of bigger and blurry
glow. By the way, the skylight is one gigantic glow of the sun thanks to the atmosphere of our dear
Earth. Because there is not enough air to refract the sunlight (or the closest starlight scientifically) in
vacuum space, the vacant background of space is pitch black.

Contacts
 About Us
We are Moonflower Carnivore and we provide game assets like particle effects and simple shaders.
Please like our Facebook page and rate our packages in Unity Asset Store if you like our work!

 Got Problems/Comments?
You can go to our Facebook page and leave comments or send us messages. Also you can email us at
moonflowercarnivore@gmail.com
Any feedback and suggestions are always welcomed. You can also make requests too.
Terms of Use
Disclaimer: This section only summerizes a portion of Unity’s Asset Store Terms of Service and End
User License Agreement (EULA). It does not override the agreement detailed in Unity’s website if there
is contradiction between the two.

This asset published by Moonflower Carnivore (the licensor) is intended to be only distributed publicly
in your (the end user’s) electronic game and interactive media, in the form of an executable which
cannot be modified in Unity editor again.

You are free to use and modify this asset if you obtain this asset legally via Unity Asset Store firsthand
and distribute your executable containing this asset legally.

You are not allowed to publicly reproduce, distribute, sublicense, rent, lease or lend this asset, either
untouched or retouched, or any resource included in this asset for commercial or non-commercial
purposes.

If you obtain this asset secondhand, not via Unity Asset Store firsthand, you are not authorized to use
this asset, unless you obtain this asset legally via Unity Asset Store again.

Per EULA, sharing this asset to other computers is only allowed:


(...) provided that these computers are either all (i) physically located at a single physical location
("Site") belonging to END-USER, or (ii) laptops belonging to END-USER which have been made
available by END-USER to its employees that are employed at the same Site provided all such
computers have appropriately licensed Unity software installed.

If you really want to include any single content of our assets in your own asset to be sold commercially,
you must email us to negotiate a separate contract for permission.

Special Thanks
 Martin Palko
It is from this guy’s blog that we learn how to optimize our shaders in a similar fashion as Standard
Shader of Unity 5. Prior to that, shader variants were handled by countless confusing sub-shaders.

You might also like