Is there any simple solution for this?
Use vertex colors.
–Eric
can you provide more information please?
Unity sprites use vertex colors, for example; the shader uses vertex colors to tint objects instead of having the color tied to the material.
–Eric
Look it up, it has been discussed before. Eric’s advice is sound, vertex colors is the way to go.
i have 3d objects not sprites…sorry i am not into shaders too much, can default diffuse shader could be used in that way or something else need to be used?
You can use meshes, but you’ll need to write your own shader that uses the vertex colors. It’s not that hard, there have been a couple of shaders that do that floating around.
Here’s a shader that shows vertex colors and nothing else :
Shader "Vertex Color" {
Properties {
}
SubShader {
Tags { "RenderType"="Opaque" "Queue"="Geometry" }
Pass {
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
struct v2f
{
fixed4 color : COLOR;
half4 pos : SV_POSITION;
};
v2f vert(appdata_full v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.color = v.color;
return o;
}
fixed4 frag(v2f In) : COLOR
{
fixed4 c = fixed4(1,1,1,1);
c.rgb *= In.color.rgb;
return c;
}
ENDCG
}
}
}
I don’t know if it will be helpful.
If you are using 3DS Max for the models you can do this:
Other packages like Maya or Blender have the same features. You only need to select a shader in Unity that support vertex color.
Sprites are 3D objects; the exact same principles apply.
–Eric