2
\$\begingroup\$

I created a fire particle effect with the Particles/Additive (Soft) shader in Unity 5.2.2, and it looks fine against a dark background, like the editor background:

However, when I move it in front of a lighter background, it looks like this:

I think the additive property is blending with the background, is there a workaround to make the effect look like how it looks on a dark background, without using a different shader?

I've looked at this question: How can I achieve a good fire effect with alpha blending and particles? but I'm not sure how I would execute that in Unity.

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

There are 2 hacks I can think of with which you can acheive this.

  1. You can create an alpha-blended 'mask particle system' for every additive particle system you create. Render the mask particle system first and then on top of it, render the actual one. This way all the particles in the paricle system will be 'guarded' by the consistent underlying alpha blended particle from the variable backgorund.

    If you use unity's built-in particle system to create particles then you'll have to make sure that there isn't much randomness in the particle. Otherwise the mask will not be much identical to the real one and will create some 'unguarded' areas.

    If you are using your own particle system then for every particle in the system you'll have to create an identical particle in the 'mask-particle-system' which will follow the exact path of its corresponding real-particle. Then, render the mask-system and then the real one.

The mask-particle-system should preferably use the full-black version of the particle texture.

Fire particle

enter image description here

Fire particle mask

enter image description here You'll have to adjust the sorting layer order of the particle objects. This can done attaching the following script to all the particle systems. Set the layerOrder of mask system as 1 and that of real one as 2.

  `public int layerOrder;
    void Start () {
        ParticleSystem particleSys = GetComponent<ParticleSystem>();
        Renderer renderer = particleSys.GetComponent<Renderer>();  
        renderer.sortingOrder = layerOrder;
    }`

This is what I acheived this way.

No mask

Image without mask

With mask

Fire with mask

  1. The second method is to use a separate camera for rendering the particle systems. Anything that needs to be drawn over the fire particles also need to be rendered by this new camera. Things might get tricky this way. You might not be able to easily and properly position stuff rendered by the new camera in respective to the ones rendered by the older one.

Both of these methods will have their impact on performance. You'll have to choose the one which best suits your needs

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .