Different color of particles when creating particle via code and node particle editor

I created particle via code and recreated it in node particle editor. I used the same colors for both. But they are different in result

via code https://playground.babylonjs.com/#FJYR0B#1

    partlcleEffect.color1 = BABYLON.Color4.FromInts(58, 89, 133, 255);

    partlcleEffect.color2 = BABYLON.Color4.FromInts(137, 175, 224, 255);

    partlcleEffect.colorDead = BABYLON.Color4.FromInts(137, 175, 224, 255);

via npe https://playground.babylonjs.com/#FJYR0B#2

in npe case there is violet color somehow. is it bug or i’m doing something wrong?

Thanks!

The equivalent NPE system is a little different to what you did as you also need a color update step. You can use the function ConvertToNodeParticleSystemSetAsync to see how your regular system would look in NPE.

In your case, you can see it in this playground:
fps drop test for https://forum.babylonjs.com/t/no-possibility-to-create-gpu-particle-system-via-node-particle-editor/62 | Babylon.js Playground

And this is the node graph:

but color of the converted particle system is still wrong in NPE

particle system

converted particle system to npe

there is a violet color which shouldn’t be there

I’ll keep investigating this! Monday is a holiday here, but I will look at this on Tuesday.

1 Like

So there was a bug on the conversion function, but NPE was generating colors correctly:

[NPE] Using Lerp instead of Random for initial color by VicenteCartas · Pull Request #17914 · BabylonJS/Babylon.js

The issue for the initial playground and the conversion function was that they were using a random between two colors, which can do things like produce the violet. While thinParticleSystem what it does is to lerp between both colors. This PR updates the conversion function to Lerp instead of Random, and now the colors are fine.