Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
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
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges