Search Unity

iOS - shadows not appearing for double-sided panes

Discussion in 'Shaders' started by Fr2, Jun 1, 2017.

  1. Fr2

    Fr2

    Joined:
    Jan 19, 2013
    Posts:
    39
    I've got a script which procedurally creates trees, and each branch segment consists of a double-sided plane (4 vertices with 4 tris). The material contains a transparent texture for the leaves, and a custom shader:

    Code (CSharp):
    1. Shader "Unlit/Transparent Cutout (Shadow)"
    2. {
    3.     Properties
    4.     {
    5.         _Color   ("Main Color", Color) = (1,1,1,1)
    6.         _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
    7.         _Cutoff  ("Alpha cutoff", Range(0,1)) = 0.5
    8.     }
    9.     SubShader
    10.     {
    11.         Tags
    12.         {
    13.             "Queue" = "AlphaTest"
    14.             "IgnoreProjector" = "True"
    15.             "RenderType" = "TransparentCutout"
    16.  
    17.         }
    18.         LOD      100
    19.         Lighting Off
    20.         CGPROGRAM
    21.         #pragma surface surf Lambert alphatest:_Cutoff
    22.         sampler2D _MainTex;
    23.         fixed4 _Color;
    24.         struct Input
    25.         {
    26.             float2 uv_MainTex;
    27.         };
    28.         void surf (Input IN, inout SurfaceOutput o)
    29.         {
    30.             fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    31.             o.Emission = c.rgb;
    32.             o.Alpha = c.a;
    33.         }
    34.         ENDCG
    35.     }
    36.     Fallback "Transparent/Cutout/VertexLit"
    37.     //FallBack "Diffuse"
    38. }
    My problem is that while shadows appear to be fine on my mac, on iOS they don't appear. I think it's down to the fact that the planes are double-sided. If I add the material to a cube, the shadows appear fine on iOS. As there are many branches, I'd like to keep the vertex count low. Any ideas? Thanks.
     
    Last edited: Jun 1, 2017