3
\$\begingroup\$

I've got a particle system with Render Mode set to Mesh. Then I applied a material to it, which is just white with the default shader. Now I can't change the start color nor the color over lifetime etc. As far as I know that shouldn't happen, right? I'm using Unity 5.5.0f3

This is what my PS looks like with the material :

This is what I achieved with 3 particle systems with 3 different materials, but actually, I don't want these materials. Instead, I want to set the start color property of the particle system to apply some color. The material solution restricts me in terms of random start color and stuff like this.

\$\endgroup\$
6
  • \$\begingroup\$ Particle colour is introduced via vertex colours. The default particle material reads this vertex colour information, but the default mesh material does not. You just need to use a different material or create your own. \$\endgroup\$
    – DMGregory
    Dec 20, 2016 at 15:21
  • \$\begingroup\$ I use the default shader material actually. Or do I have to create a new mesh with this material applied? \$\endgroup\$
    – TobiasW
    Dec 20, 2016 at 15:32
  • \$\begingroup\$ Try to use one of the Particles materials on your mesh. The default materials in Unity ignore vertex colors. \$\endgroup\$
    – kolenda
    Dec 20, 2016 at 15:37
  • \$\begingroup\$ Okay, works with sprite and default particle material, but how can I make this just a simple voxel particle system .. \$\endgroup\$
    – TobiasW
    Dec 20, 2016 at 15:40
  • \$\begingroup\$ It sounds like you have a working solution. What do you mean by a "simple voxel particle system"? What's currently missing or not working the way you want it to? \$\endgroup\$
    – DMGregory
    Dec 20, 2016 at 15:58

3 Answers 3

7
\$\begingroup\$

I'm not sure why you say "The material solution restricts me in terms of random start color and stuff like this."

You can get random start colours into a material just fine. As I said in my first comment, all you need to do is use (or create) a material that uses the mesh's vertex colours.

For example, you can Create->Shader->Standard Surface Shader (since it appears you want lighting to apply to your meshes), and then make two small modifications:

    CGPROGRAM
    #pragma surface surf Standard fullforwardshadows
    #pragma target 3.0

    sampler2D _MainTex;

    struct Input {
        float2 uv_MainTex;

        // Modification 1: add a vertex colour parameter to the Input struct.
        float4 vertexColor : COLOR;
    };

    half _Glossiness;
    half _Metallic;
    fixed4 _Color;

    void surf (Input IN, inout SurfaceOutputStandard o) {           
        fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;

        // Modification 2: multiply the albedo by this vertex colour.            
        c *= IN.vertexColor;

        o.Albedo = c.rgb;           
        o.Metallic = _Metallic;
        o.Smoothness = _Glossiness;
        o.Alpha = c.a;
    }
    ENDCG

Create a material using this shader and assign it to your particle system. Now you can play with colours in the particle system as much as you want!

Animation of a particle system generating many different coloured cubes

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Since I'm not into shaders, this was not an obvious solution for me. Thanks for helping me out on this one! \$\endgroup\$
    – TobiasW
    Dec 22, 2016 at 8:04
1
\$\begingroup\$

(Sorry for my english, I'm not native) I had the same problem, and what i did was:

  1. Create New Material (i named my new material "ParticlePlane").

  2. Change the Shader in the new material. I assigned Particles/Standar Surface enter image description here

  3. Then in the particle system, in the Renderer module, in the Material property i put my new created material and that's all.

After doing those 3 things, the Color over lifetime module started to work correctly.

Hope it helps somebody.

Regards.

\$\endgroup\$
-2
\$\begingroup\$
GameObject _particle= Instantiate(Resources.Load("SplashDust")) as GameObject;

ParticleSystemRenderer _rend = _particle.GetComponentInChildren<ParticleSystemRenderer>();
_rend.material.color = Color.red;
\$\endgroup\$
1
  • \$\begingroup\$ Perhaps you'll want to add comments to the code as to why this works and solves the issue. \$\endgroup\$
    – Vaillancourt
    Mar 27, 2020 at 4:03

You must log in to answer this question.

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