Hi all,
i’m approching unity development, so sorry if my question is so noob.
I’m looking for a simple shader that have a solid color as option.
I’m actually using this
Shader"SolidColor" {
Properties { _Color (“Color”, Color) = (1,1,1) }
SubShader { Color [_Color] Pass {} }
}
But this have a little problem… it doesn’t receive shadows. Does anyone have a link to a simple shader ( it will run on mobile platform so lighter is better) like the color one but that receive shadows ?
Many thanks
This might be as lightweight as you get.
Shader "SolidColor" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
}
SubShader {
Tags {"Queue" = "Geometry" "RenderType" = "Opaque"}
Pass {
Tags {"LightMode" = "ForwardBase"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
#include "AutoLight.cginc"
struct appdata_pos {
float4 vertex : POSITION;
};
struct v2f
{
float4 pos : SV_POSITION;
LIGHTING_COORDS (0,1)
};
v2f vert (appdata_pos v)
{
v2f o;
o.pos = mul( UNITY_MATRIX_MVP, v.vertex);
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
fixed4 _Color;
fixed4 frag(v2f i) : COLOR
{
return _Color * LIGHT_ATTENUATION(i);
}
ENDCG
}
}
FallBack "VertexLit" // Use VertexLit's shadow caster/reciever passes.
}
Great! thank you very much.