Let me show the shader I’ve put together. I want to change the color of the vertex in the shader, like using the normal. And although I have the colors in the preview material/shader, in the render all is shades of white…
Shader “Lines/ShinyShader” {
Properties {
_MainTex (“Base (RGB)”, 2D) = “green” {}
_Shininess (“Shininess”, Range (0.01, 1)) = 1
}
SubShader {
Tags { “Queue” = “Transparent” }
LOD 300
ZWrite Off
Alphatest Greater 0
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
Lighting On
SeparateSpecular On
CGPROGRAM
#pragma surface surf Lambert finalcolor:mycolor vertex:myvert
sampler2D _MainTex;
fixed4 _Color;
half _Shininess;
half4 LightingSimpleSpecular (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
float lt = dot(lightDir, s.Normal);
float vt = dot(viewDir, s.Normal);
float ln = sqrt(1.0 - pow(lt,2.0));
float vr = ln * sqrt( 1 - pow(vt, 2.0) ) - (lt*vt);
//I = ka + kd(l.n) + ks(v.r)^n
half3 h = normalize (lightDir + viewDir);
//half diff = max (0, dot (s.Normal, lightDir));
float nh = max (0, dot (s.Normal, h));
float spec = pow (vr, 48.0);
half4 c;
c.rgb = (s.Albedo * _LightColor0.rgb * ln) + (_LightColor0.rgb * spec) * (atten * 2);
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
float3 customColor;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Albedo = IN.customColor;
//o.Gloss = c.rgb;
o.Alpha = c.a;
//o.Specular = _Shininess;
//o.Albedo = IN.customColor.rgb; // vertex RGB
//o.Alpha = IN.customColor.a; // vertex Alpha
}
void myvert(inout appdata_full v, out Input data)
{
UNITY_INITIALIZE_OUTPUT(Input,data);
data.customColor = normalize(v.normal);// * 0.5 + 0.5;
}
void mycolor (Input IN, SurfaceOutput o, inout fixed4 color)
{
color.rgb = IN.customColor;
o.Albedo = IN.customColor;
}
ENDCG
}
Fallback “VertexLit”
}