Particle System advanced shader issues

I’m currently working on porting a few Particle Systems from Unreal 3 to Unity 5. Some of these particle systems use rather complex materials for their particles. A good example would be two textures blended together with a panner on their UVs. This creates rather realistic fire.

I replicated this in Unity, but I ran into an annoying problem. All particles share the same material for each particle. So no matter the time a particle is spawned, its UV is panned exactly the same as a particle that’s about to die, rather than having a “reset” panner so to speak.

The rate of this emitter was 10 per sec, so I figured I could work around the problem by making 10 systems, each with an own material instance of the shader. However, it did not generate desirable results.

Eventually I sacrificed my Vertex Color to pass in Lifetime information (basically setting the R-channel from 0 to 1 in Color over Lifetime) into the shader, so I could make the panner change over the lifetime of a particle and this creates exactly the effect I want (each new particle starts with the same “look”). However, as said, I’m sacrificing my Vertex Color for that and while it works, it’s quite undesirable, as I can’t animate the color anymore now.

Would anyone know how I can workaround this problem in a better way? Is there a way I can pass more information onto the Vertex for use in my shader without sacrificing my Vertex Color slot? Or is there a way to force Unity to not share the same material-instance over all particles? Or is there an alternative way for me to setup my shader and particle system, while achieving the same visual result?

Unreal shares the same material instance across all particles too, that’s how real time particle systems work generally. The difference is Unreal allowed you to pass more information to the shader than just the color and position, you also had the extra float4 that could be used. That and their flipbook implementation handled smooth blending automatically unlike Unity’s.

For Unity the only solution is to pass the information via the color channel as you’re already doing. If you want to animate the color over time as well you’ll need to generate or author color ramp textures (1x16 or 1x32 uncompressed textures would suffice in most cases) and sample from them manually in the shader. You can also abuse the color system to create a random value to key from by setting the initial color between two constants like 255,255,255 and 255,0,255 and then have the green color be a constant 255 over lifetime. In the shader that’ll become a random value between 1.0 and 0.0.

Also, hi Lennard. :slight_smile:

1 Like

Please support my request on Feedback, this can be easily solved for the time being if the Particle object would just a have a .color2 that would be passed to the COLOR1 on the vertex structure.

https://feedback.unity3d.com/suggestions/for-the-upcoming-5-dot-3-update-please-expose-vertex-color-2-for-particles