Unity [Particle] Alpha Dissolve? [[ShaderForge]]

unity
shaders

#1

Hey Folks, I’ve got a basic question here. Is Unity capable of doing Alpha Dissolve for its Particle system using ShaderForge?

I’ve been using Unreal Engine 4 lately and it dissolves per particle with something like a Dynamic Parameter. It’s a great way to fake flipbooks and have control.

I’m not sure if this is an available feature within Unity (ShaderForge). In my mind it’d dissolve every particle instead of individually since there isn’t a node for that.

Perhaps the particle system could send values from the alpha to the ShaderForge Material (some way of sending a 0-1 value to the slider)?

I saw an Alpha Dissolve Shader on the marketplace right here: https://www.assetstore.unity3d.com/en/#!/content/33631. My guess is it’s their own custom shader, but that is the desired result. I’ll most likely end up buying it, but it’d be more helpful to learn the method.

Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.

As with everything haha. Thanks.


#2

Sure it is!

Just set up a normal dissolveshader and drop in a vertex color node. The vert color grabs values from the particlesystem so you can use that to drive the dissolve over life.

In shader forge, when working with sprites, Vertex Color will behave like Particle Color in the Unreal material editor.

Happy dissolving!


#3

Hmmm, I haven’t opened Shader Forge in a while. I can’t remember, does it have a node/function that picks between a random range of numbers? If so, you could add, multiply, or a combination of both, with that range and alpha channel to control the dissolve and get some randomness that way. I’m sorry I can’t help more at the moment. I forget how spoiled I’ve been with Unreal materials and that dynamic parameter. If I can think of a better solution, I’ll post it.


#4

@Partikel Cool! That seems to work. I can literally use Diffuse (white to black) to control the LERP within the shader for opacity.

Is there a way to do this with R, G or B? I know it’s a component mask, but how does the “Color over Life” module target those values? In-case I wanted to do additional effects- i.e. fade in + dissolve out FX (Yea I could just use the RGB/A channels but then it’s colors can’t be controlled/altered).

I’m guessing that it’s not possible since there’s just one gradient and their all drawing from it. They do have a random gradient option (up to 2) but that would sample strangely.

@Travis Hey man, no problem! I think I’ve got it down. Yeah, good thing ShaderForge is like UE4 for Unity haha.

This works pretty well.


#5

I haven’t tried Unity 5.5 but I think they added support for that. If you are on an earlier version, the vertcolor is all you get I’m afraid :confused:


#6

@Partikel Ah gotcha. Welp, that should be enough for what I’m doing. I’ll check that out!


#7

Hi
I’m tried another way using shuriken vertex stream custom data.
Custom data can be used like unreal’s dynamic parameter.:grinning:
I created it using unity 5.6.0bata and shaderforge v1.34.
https://www.youtube.com/watch?v=3z534Zhb6_I


Unity Custom Stream and Shaderforge
#8

@frontakk Nice. I’ll give that a try. Thanks!


#9

You don’t need custom data to do alpha erosion. Just change the alpha formula. Normally its:
output.alpha = texture.a * vertexColor.a;

Change it to:
output.alpha = saturate(texture.a - (1- vertexColor.a));

and you are done.


#10

alpha offset is great…however it is best used strictly to dissolve edges, the ability to have both fade and offset is going to be ideal imo; there’s just times when you need your smoke ~50% opaque before you start dropping out edges


#11

Aye!
Smoothstep ftw.


#12

Well, you can still do this without custom parameters. Most of the times you have some kind of ColorTint parameter to tint the texture. You can use its alpha value and multiply the output alpha before doing alpha erosion. This way you have both alpha erosion and standard alpha fade. Unfortunately, the amount of alpha fade is dictated by material’s parameter so if you want dynamic control you need the custom vtx data.


#13

@michalpiatek I understand the concept but not how to apply what you’re saying (first comment w/ code). I haven’t tried this in Unity 5.6 yet I just upgraded. I’ll probably use frontakk’s technique then go from there. I’ll look into it soon. Thanks.
@Torbach Yea that would be the idea. For me it’d be Fade in > Dissolve out.
@William_Mauritzen :-/ Not sure what/where that is. I’ll have to look for it. XD


#14

Basically, instead of having a hard edge in your translucency, you give it two values to “smooth” between.
Then you animate the elevation of the values.


#15

Do you mean curves within the opacity? Yep! Haha. I use that type of curve alot.


#16

i’d re-arrange the maths for the nodes in forge
t.a + (v.a - 1)

vertex.alpha -> (rempap_simple) 0,1 becomes -1,0 -> (+) texture.alpha -> (clamp 0-1) -> opacity


#17

I’m going to second @frontakk about using data streams. It gives you other channels besides vertex color, especially if you actually want to use those colors in your particle system. I hadn’t tried using data streams with shader forge but that’s cool @frontakk got it to work! Here’s a bare bones example shader I made using the the “Random” parameter: https://drive.google.com/open?id=0Bw9eVM4WUuPOTDN5ZGo2WTFhYW8
“Random” could be used to have a random seed for a UV offset per particle for example. My example just gives a random color.

If you don’t need to really use vertex color for anything else, then to answer your other question, yes you can use the RGB values of vertex color (which is Start Color/Color over lifetime) effectively giving you 4 unique channels (RGBA) for custom control.


#18

@Torbach Yea that seems to work. Although I’d like to have some control over the noise.
@DedRed Ok. I’ll have to test that out some more.

I’ve been asking Sirhaian how to do his Alpha Dissolve/Threshold map trick that he used in his League VFX. It seems to work on his end but its really odd on mine. The values appear to go below 0 and refuse to be clamped.

https://youtu.be/pIwvTpIDrYc

[Sirhaian’s ShaderForge Setup]

Anyways, I used Torbach’s and Frontakk’s example to try and get the result. I’m close, but I only want the texture to show. Right now its multiplying it against the texture. I just want the noise to be the Dissolver.

The above video has it right, except when it fades to black (literally). If I could get the elements of above with the setup of below then that’d be perfect. I’m so close haha.

https://www.youtube.com/watch?v=o01EaNC9gSg&feature=youtu.be


#19

Awesome to see this! This is exactly the kind of effect we hoped people would use the Custom Data module for!


#20

Hey, is anyone here using Unity 2017 and having this problem? The custom vertex streams settings are missing. I tried reinstalling and it actually made the issue worse. It removed 90% of the menus and won’t update/add the settings.

Something odd is noticed is that if you upgraded your project and your particle system had custom vertex streams settings on it, it’ll work. But if you remove it, it cannot be added back.

Unity 5.6 doesn’t have this issue. Unfortunately I’ve updated my projects to 2017 and can’t downgrade them anymore. Any help would be great since it’s a pretty important aspect of Dissolve FX.