OK, this has been asked before but in the answers the links are always broken!
I’m trying to find a simple shader that is more or less the default diffuse shader with texture but tinted with vertex colors. (Actually I mainly need it to darken at some vertices but tinting would do).
Thanks, but I nearly have it:
Shader "Custom/CubeShader" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
//Tags { "RenderType" = "Opaque" }
LOD 300
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
float4 color: Color; // Vertex color
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb * IN.color.rgb; // vertex RGB
o.Alpha = c.a * IN.color.a; // vertex Alpha
}
ENDCG
}
FallBack "Diffuse"
}
Except that I don’t want it transparent. Since the objects keep hiding behind transparent objects.
1 Like
No worries I’ve found it:
Shader "Custom/CubeShader" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
float4 color: Color; // Vertex color
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb * IN.color.rgb; // vertex RGB
o.Alpha = c.a * IN.color.a; // vertex Alpha
}
ENDCG
}
FallBack "Diffuse"
}