So I’m trying to get a shader to work that will act like the default Transparent/Diffuse shader, which is able to be lit by point lights - but also support accepting a vertex color to change the tint.
This is so I can have multiple objects with the same material but vary the tints slightly, and still have them be affected by lighting.
Here is a shader that is transparent and has the Vertex color, but isn’t lit. Is it possible to modify this to be lit, or modify the Transparent/Diffuse shader to also accept vertex colors?
I’m very much a n00b with shader code.
Thanks!
Shader "Ferr/Unlit Transparent Textured Vertex Color" {
Properties {
_MainTex("Texture (RGBA)", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
LOD 200
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
struct VS_OUT {
float4 position : SV_POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD0;
};
VS_OUT vert (appdata_full input) {
VS_OUT result;
result.position = mul (UNITY_MATRIX_MVP, input.vertex);
result.uv = TRANSFORM_TEX (input.texcoord, _MainTex);
result.color = input.color;
return result;
}
half4 frag (VS_OUT input) : COLOR {
half4 color = tex2D(_MainTex, input.uv);
return color * input.color;
}
ENDCG
}
}
}