- Home /
Transparent Cutout Double Diffuse shader with accurate lighting?
So we're making one of those 3d billboard sprite games and I'm having an issue with our shader. When a light source hits one side of the planes, the opposite side is affected the same. This is causing issues because our buildings are made of cutout shaded planes as well. So in a night setting, an interior light makes the exterior side of the building's planes light up, essentially glowing . Is there any way to modify this shader code to allow each side of the plane to be affected separately by light sources?
Shader "Transparent/Cutout/Diffuse" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 200
Cull Off
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
Any help or even a point in the right direction would be great. I know this is a lot of functions for a shader, but I can't seem to find this anywhere.
The only solution I can think of that could solve this would be to add cull back into the shader and duplicate my building's faces, flip their normals in Maya and try again. This just seems like a whole lot of extra work that a shader might be able to handle on it's own.