"Why Shuriken ""Color Over Lifetime"" doesn't affect transparent materials?" (493957)

No one seems to know this at Unity Answers so I’ll try here:

Shuriken doesn’t affect color for transparent material. Why is this? At first, I thought that it changes _TintColor and not _Color so I changed that variable name in a transparent_diffuse shader. But it didn’t help.

It also does nothing to a common diffuse shader.

How does shuriken access particle colors? Is this a bug or is there some unavoidable limitation that I’m not aware of?

Thanks.

Not sure if I understood but it works here,
seems to affect vertex colors?

Shader "Transparent/DiffuseTest2" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}


SubShader {
	Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
	LOD 200

CGPROGRAM
#pragma surface surf Lambert alpha
#pragma vertex vert

sampler2D _MainTex;
fixed4 _Color;

struct Input {
	float2 uv_MainTex;
	float3 color;
};

void vert (inout appdata_full v, out Input o) {
  UNITY_INITIALIZE_OUTPUT(Input,o);
  o.color = v.color;
}

void surf (Input IN, inout SurfaceOutput o) {
	//fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
	fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * float4(IN.color.r,IN.color.g,IN.color.b,1);
	o.Albedo = c.rgb;
	o.Alpha = c.a;
}
ENDCG
}
}
  • _Color is not yet added to the c there

Thanks a lot mgear!

So it’s vertex color then. Didn’t think about that. I’m only starting to learn writing shaders.

That said, I tried to include alpha support by changing line 31 to:
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * float4(IN.color.r,IN.color.g,IN.color.b,IN.color.a);
or
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * float4(IN.color.rgba);

but it didn’t work. Guess I have much to learn yet :slight_smile:

Anyway, now that I know what the problem is, it’s just a matter of time that I’ll get to the effect that I want to achieve.

Thanks again!

PS If you wish, you can copy-paste your post as an answer here: Why Shuriken "Color Over Lifetime" doesn't affect transparent materials? - Questions & Answers - Unity Discussions so I can give proper credit. If you don’t post it in a few hours, I will and I’ll mention that it’s you who provided the answer. It’s just for people who search for this problem so that they can see the answer at UnityAnswers as well.

Oh I think I got it, it should be float4 color; in line 21. I’ll try it out now

Ok, it works.

So, for anyone who wants to use mgear’s shader but with alpha support from shuriken, just change:

line 21 to: float4 color;
line 31 to: fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * float4(IN.color.r,IN.color.g,IN.color.b,IN.color.a);

Nice!

I guess then could change:
float4 color;
to
fixed4 color;

and then do,
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color;

or try to add the _Color in too (not tested)
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * (_Color + IN.color);

Tested it, it works. Adding _Color can produce very nice additional effects. Thanx.