- Home /
 
               Question by 
               Nicolas-Liatti · May 30, 2014 at 11:18 AM · 
                shaderiostransparent  
              
 
              Problem with transparent shader on iOS
Hi,
I'm trying to write a shader that moves the leaves of a tree, but I need to be able to make the leaves transparent. It works fine in the editor, however on iPhone the leaves are transparent, but when there is a character behind the leaves it is not drawn...
My shader below. Why do I have this problem on iOS, and how could I solve it?
Thanks for help :)
 Shader "Nature/Tree Creator Leaves Fast_Custom" {
 Properties {
     _Color ("Main Color", Color) = (1,1,1,1)
     _Cutoff ("Alpha cutoff", Range(0,1)) = 0.3
     _Alpha ("Alpha", Range(0,1)) = 0.3
     
     _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
     
     // These are here only to provide default values
     _Scale ("Scale", Vector) = (1,1,1,1)
     _SquashAmount ("Squash", Float) = 1
 }
 
 
 SubShader { 
     Tags {
         "IgnoreProjector"="True"
         "RenderType" = "Transparent"
     }
     LOD 200
         
     Pass {
         Tags { "Queue"= "Transparent" "RenderType"="Transparent" "LightMode" = "Always"}
           ZTest Always
           ZWrite On
           ColorMask RGBA
           Blend SrcAlpha OneMinusSrcAlpha
 
     CGPROGRAM
 // Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct v2f_leaf members alpha)
 #pragma exclude_renderers d3d11 xbox360
         #include "TreeVertexLit.cginc"
 
         #pragma vertex VertexLeaf
         #pragma fragment FragmentLeaf
         #pragma exclude_renderers flash
         #pragma multi_compile_fwdbase nolightmap
         
         sampler2D _MainTex;
         float4 _MainTex_ST;
 
         float _Cutoff;
         float _Alpha;
         sampler2D _ShadowMapTexture;
 
         struct v2f_leaf {
             float4 pos : SV_POSITION;
             fixed4 diffuse : COLOR0;
             
             float2 uv : TEXCOORD0;
     
         };
 
         v2f_leaf VertexLeaf (appdata_full v)
         {
             v2f_leaf o;
             TreeVertLeaf(v);
             o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                         
             fixed3 color = v.color.rgb * _Color.rgb;// * ao;
             
             float3 worldN = mul ((float3x3)_Object2World, SCALED_NORMAL);
 
         
             o.diffuse.rgb = _Color;//ShadeTranslucentLights (v.vertex, worldN) * color;
             o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
             return o;
         }
 
         float4 FragmentLeaf (v2f_leaf IN) : COLOR
         {
             float4 albedo = tex2D(_MainTex, IN.uv);
             float alpha = albedo.a;
 
             clip (alpha - _Cutoff);
 
                       albedo.a = _Alpha;
 
             half4 light = IN.diffuse;
             return float4(albedo.rgb * light, albedo.a);
         }
 
     ENDCG
     }
 }
 
 Dependency "OptimizedShader" = "Hidden/Nature/Tree Creator Leaves Fast Optimized"
 FallBack "Transparent/Diffuse"
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Transparent Detail on mobile 0 Answers
Unlit/Transparent is best choice? 1 Answer
How to Make Transparent Objects Blurry 1 Answer
Transparency working in the editor but not when I build 0 Answers
Transparent Shader Render Order Issue 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                