Particles have color different from the settings

Hi All!

I’m using particles in my game. Set everything in code like this:

var coinColor = GameManager.Instance.GetCoinColor();
var blowColor = new Color(coinColor.r / 255f, coinColor.g / 255f, coinColor.b / 255f, coinColor.a / 255f);
blow.startColor = blowColor;
var renderer = blow.GetComponent<ParticleSystemRenderer>();
renderer.material.SetColor("_TintColor", blowColor);
renderer.material.SetColor("_Color", blowColor);
renderer.material.SetColor("_EmissionColor", blowColor);

But the color of the particles is different from the color I want it to be. I can see that in the inspector too if I pause the game:

I want the particles to be light-green, but they are really yellow. The same problem with some other colors.
I decided to use Alpha Blended to solve this problem, because another shader has even more strange colors. But this shader sets the strange color too.

How can I solve the problem?
Thanks!

Changing shader to Alpha Blended Premultiply solved the problem, it seems. Sometimes Unity really confuses me…

1 Like

You’re setting the color on the material and the color on the particles which are multiplied together, plus the tint color is a 2x color meaning a middle grey color is “white” for the particle.

I would LOVE to see this added to the documentation of particle systems (and line renderers, etc). I can never figure out how Unity is combining the colour from the texture, the colour from the material, and the colour from the particle system to get its end result. It’s almost never what I expect.

Technically this has nothing to do with the particle system (or the line / trail renderer). That’s just how the included particle and Legacy shaders have been written to use the “Tint Color” material property. Further the particle system’s color isn’t gamma corrected so if you’re running in linear color space the particle color won’t match the color you see in the UI. Both of these can be fixed or changed with custom shaders, and indeed the way the particle color and material color is applied to the texture can be modified with the newer standard particle shaders, but they didn’t fix the gamma issue.