- Home /
Why Shuriken "Color Over Lifetime" doesn't affect transparent materials?
Hi,
The question title is quite self-explanatory :) 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.
That's very interesting. I've never tried it before, but I just did the same thing in a test scene, and you're right. Now I'm curious too.
Answer by mgear · Jan 03, 2013 at 12:58 PM
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 on that code yet
Original thread: http://forum.unity3d.com/threads/164653-Why-Shuriken-quot-Color-Over-Lifetime-quot-doesn-t-affect-transparent-materials
It works great. Thanks mgear.
If anyone wants to use mgear's shader but with alpha support from shuriken, just change:
line 21: "float3 color;" to "fixed4 color;" line 31 to: fixed4 c = tex2D($$anonymous$$ainTex, IN.uv$$anonymous$$ainTex) * IN.color;
Answer by Jameslewood · Feb 07, 2014 at 09:40 PM
You can also try using Sprites/Default as the shader.