Cull Off not working

I am trying to disable backface culling in a simple shader but “Cull Off” seems to have no effect. It always culls one side. vertex buffer has no normals. version 2019.3.14f1. What could be the problem?

Shader "Custom/test" {

    Properties {
        _MainTex ("Texture", 2D) = "white" { }
    }
    SubShader {
        Tags { "Queue" = "Transparent" }

        Pass {
            Blend SrcAlpha OneMinusSrcAlpha
            Ztest always
            ZWrite Off
            Cull Off

            CGPROGRAM

            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            sampler2D _MainTex;

            struct appdata {
                float4 vertex : POSITION;
                float2 texcoord : TEXCOORD0;
                fixed4 color : COLOR;
            };

            struct v2f {
                float4 pos : SV_POSITION;
                float2 texcoord : TEXCOORD0;
                fixed4 color : COLOR;
            };

            float4 _MainTex_ST;


            v2f vert (appdata v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.texcoord = TRANSFORM_TEX (v.texcoord, _MainTex);
                o.color = v.color;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 texcol = tex2D (_MainTex, i.texcoord);
                return texcol * i.color;
            }
            ENDCG

        }
    }
}

How do you know it’s always culling one side? What you have above will work, but my guess is either part of your mesh’s vertex coloring is fully transparent, or you’re mistaking sorting problems with culling.

Depending on the order of the triangles in the mesh, some triangles will draw on top of others. There isn’t really a solution to this because efficient real time sorting of transparent surfaces is an unsolved problem.

However there are often hacky workarounds that can work for specific situations, if you can post images of the problem you’re seeing.

Looks like the shader wasn’t getting compiled during the normal build. I had to re-import asset. Works now.

1 Like