In the following image you can see that certain parts of my world are illuminated differently. Although both shaders are almost the same. There seems to be one major difference: One shader uses forward rendering where the other is based on deferred shading.
Do their lighting equations differ? If so, what can I do to make them match? If not, what am I doing wrong?
Here you can see the code for both shaders in use:
Forward Shader:
Shader "Custom/WorldAlpha"
{
Properties
{
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Fog
{
Mode Off
}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha nofog
sampler2D _MainTex;
fixed4 _Color;
struct Input
{
float2 uv_MainTex;
float4 color : COLOR;
float3 worldNormal;
float3 worldPos;
};
void surf(Input IN, inout SurfaceOutput o)
{
o.Albedo = float3(0.3,.5,0.3);
o.Alpha = 1;
}
ENDCG
}
Fallback "Transparent/VertexLit"
}
Deferred Shader:
Shader "Custom/World"
{
Properties
{
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader
{
Tags
{
"Queue" = "AlphaTest"
"IgnoreProjector" = "True"
"RenderType" = "TransparentCutout"
}
Fog
{
Mode Off
}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff nofog noforwardadd novertexlights nolightmap exclude_path:forward exclude_path:prepass nometa nodirlightmap nodynlightmap
sampler2D _MainTex;
fixed4 _Color;
struct Input
{
float2 uv_MainTex;
float4 color : COLOR;
float3 worldNormal;
float3 worldPos;
};
void surf(Input IN, inout SurfaceOutput o)
{
o.Albedo = float3(0.3,.5,0.3);
o.Alpha = 1;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
