Hello.
I am having issues since an update from 4.2.0 to 4.3.4 regarding shaders using multiple lights in forward rendering path using a custom projection camera: objects are rendered in the good place but additionnal point lights seems to not take the custom matrix into account.
Here is the surface shader (works great with regular projection AND was working under 4.2.0 with custom projection matrix):
Shader "PU3D/Managed/TEST" {
Properties {
_Color ("Color", Color) = (1.0,1.0,1.0,1.0)
_SpecColor ("Specular Color", Color) = (1.0,1.0,1.0,1.0)
_Shininess ("Shininess", Float) = 10
_ReflectColor ("Reflection Color", Color) = (1,1,1,0.0)
_Cube ("Reflection Cubemap", CUBE) = "_Skybox" { TexGen CubeReflect }
_MainTex ("Main Texture", 2D) = "white" {}
_BackLightingStrength("BackLighting Multiplicator", Range(0.0,20.0)) = 0.0
}
SubShader {
Cull Off
ZWrite On
ZTest LEqual
Lighting On
SeparateSpecular On
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest GEqual 0.001
Tags { "Queue"="Transparent" "RenderType"="Transparent"}
LOD 300
CGPROGRAM
#pragma surface surf PU3D_Full alpha alphatest:_Cutoff fullforwardshadows
uniform float _BackLightingStrength;
uniform sampler2D _MainTex;
uniform fixed4 _Color;
uniform half _Shininess;
uniform samplerCUBE _Cube;
uniform fixed4 _ReflectColor;
// NOTE: some intricacy in shader compiler on some GLES2.0 platforms (iOS) needs 'viewDir' & 'h'
// to be mediump instead of lowp, otherwise specular highlight becomes too bright.
inline fixed4 LightingPU3D_Full (SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
{
half3 h = normalize (lightDir + viewDir);
fixed diff = max (0, dot (s.Normal, lightDir));
fixed diffBack = max (0, dot (-s.Normal, lightDir));
float nh = max (0, dot (s.Normal, h));
float spec = pow (nh, s.Specular) * s.Gloss *_SpecColor.rgb*_SpecColor.a;
fixed4 c;
c.rgb = (s.Albedo * _LightColor0.rgb * atten * (diff+spec+diffBack*_BackLightingStrength));
c.a = s.Alpha;
return c;
}
inline fixed4 LightingPU3D_Full_PrePass (SurfaceOutput s, half4 light)
{
fixed spec = light.a * s.Gloss;
fixed4 c;
c.rgb = (s.Albedo * light.rgb + light.rgb * _SpecColor.rgb * spec);
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
float3 worldRefl;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
fixed4 texC = texCUBE (_Cube, IN.worldRefl);
fixed4 refl = fixed4(0,0,0,1);//texC * fixed4(_ReflectColor.r,_ReflectColor.g,_ReflectColor.b,1f)*_ReflectColor.a*10;
o.Albedo = tex.rgb * _Color.rgb + refl;
o.Gloss = _SpecColor.a;
o.Alpha = tex.a * _Color.a + _ReflectColor.a;
o.Specular = _Shininess;
}
ENDCG
}
FallBack "Diffuse"
}
Can this be due to something missing when:
“Culling in Unity has been rewritten
Now it’s much faster across the board. Umbra occlusion culling is used to cull away point lights that don’t contribute to the final image; and to drastically reduce number of shadow casters from directional lights.”
on the 4.3.0 update?
Cheers,
Cédric