Hey guys,
The goal is to have a self-illuminated object whose illumination turns on/off based on a boolean “powered”, which also works in VertexLit mode. (set on the Camera)
I modified slightly the default Self-Illum-Diffuse shader to allow for this (check this line, where I multiply the end result by _Emission, from 0-1:
o.Emission = c.rgb * UNITY_SAMPLE_1CHANNEL(_Illum, IN.uv_Illum) * _Emission;
) but it doesn’t work in VertexLit mode - how can I convert this into a compatible shader?
Also, is there a more efficient / easier way to accomplish this?
Thanks!
Shader "Custom/Self-Illumin/Diffuse" {
Properties {
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
_Illum ("Illumin (A)", 2D) = "white" {}
_Emission ("Emission", Range(0, 1.0)) = 1
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Illum;
float _Emission;
struct Input {
float2 uv_MainTex;
float2 uv_Illum;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
fixed4 c = tex * fixed4(1,1,1,1);
o.Albedo = c.rgb;
o.Emission = c.rgb * UNITY_SAMPLE_1CHANNEL(_Illum, IN.uv_Illum) * _Emission;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Self-Illumin/VertexLit"
}