Double sided pass?

Hi everyone,

I have this shader but - mainly due to my limited knowledge of shader programming - don’t know why it is not working as “double sided”.

Currently, whenever I flip the sprite object, the reverse side is unlit. To my knowledge Cull Off should do it, but it is not working. Is is possible at all with the current code?

Shader "Sprites/Diffuse"
{
	Properties
	{
		[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
		_Color ("Tint", Color) = (1,1,1,1)
		[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
		_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.5
	}

	SubShader
	{
		Tags
		{ 
			"Queue"="Transparent" 
			"IgnoreProjector"="True" 
			"RenderType"="Transparent" 
			"PreviewType"="Plane"
			"CanUseSpriteAtlas"="True"
		}

		Cull Off
		Lighting Off
		ZWrite Off
		Fog { Mode Off }
		Blend One OneMinusSrcAlpha

		CGPROGRAM
		#pragma surface surf Lambert alpha addshadow vertex:vert
		#pragma multi_compile DUMMY PIXELSNAP_ON

		sampler2D _MainTex;
		fixed4 _Color;

		struct Input
		{
			float2 uv_MainTex;
			fixed4 color;
		};
		
		void vert (inout appdata_full v, out Input o)
		{
			#if defined(PIXELSNAP_ON) && !defined(SHADER_API_FLASH)
			v.vertex = UnityPixelSnap (v.vertex);
			#endif
			v.normal = float3(0,0,-1);
			
			UNITY_INITIALIZE_OUTPUT(Input, o);
			o.color = v.color * _Color;
		}

		void surf (Input IN, inout SurfaceOutput o)
		{
			fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color;
			o.Albedo = c.rgb * c.a;
			o.Alpha = c.a;
		}
		ENDCG
	}

Fallback "Transparent/Cutout/VertexLit"
}

When you disable culling it will render both sides, however the vertex attributes exits only once, so your vertex normals can only point in one direction. That means they are wrong for the other side (usually the back-side)

A common way to write a double sided shader is to implement it as two-pass shader and do back face culling in one pass and front-face culling in the second pass. The second pass would of course use the inverted normal for lighting.

Another way is to use the camera-to-object vector and the objects normal vector to figure out which side is visible and invert the normal if it’s pointing in the same direction as your cam-to-obj vector.

Usually it’s way easier and more versatile to simply add the back face in the mesh. So if it’s a quad you would use 2 quads one that faces the front and one that faces the back each with correct normals. That’s why “cull off” shaders are usually unlit shaders like in particle systems.