2
\$\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\$
  • \$\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 '16 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 '16 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 '16 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 '16 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 '16 at 15:58
5
\$\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
    \$\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 '16 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.