Работает как с forward, так и с deferred режимом.
Это такая заготовочка для своих моделей освещения, которые НЕ зависят от позиции наблюдателя.
Синтаксис:
Используется glsl
Shader "CustomLightingDiffuse_Dummy" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf CustomLambert
sampler2D _MainTex;
float4 _Color;
struct Input {
float2 uv_MainTex;
};
half4 LightingCustomLambert (SurfaceOutput s, half3 lightDir, half atten)
{
half diff = max (0, dot (s.Normal, lightDir));
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
c.a = s.Alpha;
return c;
}
half4 LightingCustomLambert_PrePass (SurfaceOutput s, half4 light)
{
half4 c;
c.rgb = s.Albedo * light.rgb;
c.a = s.Alpha;
return c;
}
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "VertexLit"
}
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf CustomLambert
sampler2D _MainTex;
float4 _Color;
struct Input {
float2 uv_MainTex;
};
half4 LightingCustomLambert (SurfaceOutput s, half3 lightDir, half atten)
{
half diff = max (0, dot (s.Normal, lightDir));
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
c.a = s.Alpha;
return c;
}
half4 LightingCustomLambert_PrePass (SurfaceOutput s, half4 light)
{
half4 c;
c.rgb = s.Albedo * light.rgb;
c.a = s.Alpha;
return c;
}
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "VertexLit"
}