Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by tayl0r · Jan 28, 2016 at 02:06 AM · iosshadersgraphicstransparencyspriterenderer

mobile shader broke in iOS 9 - fully transparent pixels rendering as black

I have a shader that works fine on Android and fine on iOS prior to iOS 9. On iOS 9, the fully transparent pixels render as black instead. It also works fine in the Editor.

I'm using Unity 5.2.2p4.

Partially transparent pixels still render normally. It appears to only be the completely transparent pixels that render as black instead. You can see this by looking at the outline of the sprite - the outline fades out, so the transparency is working there.

I'm using this shader on SpriteRenderer objects, not mesh renderers.

Example of problem

shader code:

 Shader "Premul2WayHueShift" 
 {
     Properties 
     {
         _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
         _Hue1 ("Hue Base", Range(0, 1)) = .5
         _Hue2 ("Hue Highlight", Range(-.25, .25)) = .1
         _Sat1 ("Saturation Base", Range(0, 1)) = 1
         _Sat2 ("Saturation Highlight", Range(0, 1)) = 1
         _Val1 ("Value Base", Range(-1, 1)) = 0
         _Val2 ("Value Highlight", Range(-1, 1)) = .4
         _LerpRange ("Lerp Range", Range(0, 1)) = .1
         _LerpOffset ("Lerp Offset", Range(0, 1)) = .5
     }
         
     SubShader
     {
         Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
         ZWrite Off Lighting Off Cull Off Fog { Mode Off } Blend One OneMinusSrcAlpha
         LOD 110
         
         Pass 
         {
             CGPROGRAM
             #pragma vertex vert_vct
             #pragma fragment frag_mult 
             #pragma fragmentoption ARB_precision_hint_fastest
             #include "UnityCG.cginc"
             #include "../../../../Code/Shaders/FoxCub.cginc"
 
             sampler2D _MainTex;
             half _Hue1;
             half _Hue2;
             half _LerpRange;
             half _LerpOffset;
             half _Sat1;
             half _Sat2;
             half _Val1;
             half _Val2;
          
             struct vin_vct 
             {
                 float4 vertex : SV_POSITION;
                 float4 color : COLOR;
                 float2 texcoord : TEXCOORD0;
             };
 
             struct v2f_vct
             {
                 float4 vertex : SV_POSITION;
                 half4 color : COLOR;
                 float2 texcoord : TEXCOORD0;
             };
 
             v2f_vct vert_vct(vin_vct v)
             {
                 v2f_vct o;
                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                 o.color = v.color;
                 o.texcoord = v.texcoord;
                 return o;
             }
 
             half4 frag_mult(v2f_vct i) : COLOR
             {
                 half4 col = tex2D(_MainTex, i.texcoord) * i.color.a;
                 half3 hsv = RGBToHSV(col.rgb);
 
                 half cutLow = lerp(0, 1-_LerpRange, 1-_LerpOffset);
                 half cutHigh = cutLow + _LerpRange;
 
                 half hue2 = _Hue1 + _Hue2;
 
                 hsv.x = frac( lerp(_Hue1, hue2, smoothstep(cutLow, cutHigh, hsv.z)) );
                 hsv.y += lerp(_Sat1, _Sat2, smoothstep(cutLow, cutHigh, hsv.z));
                 hsv.z += lerp(_Val1, _Val2, smoothstep(cutLow, cutHigh, hsv.z));
                 //hsv.z = cutLow;
 
                 return half4(HSVToRGB(hsv), col.a) * col.a;
             }
             
             ENDCG
         } 
     }
  
     SubShader
     {
         Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
         ZWrite Off Blend One OneMinusSrcAlpha Cull Off Fog { Mode Off }
         LOD 100
 
         BindChannels 
         {
             Bind "Vertex", vertex
             Bind "TexCoord", texcoord
             Bind "Color", color
         }
 
         Pass 
         {
             Lighting Off
             SetTexture [_MainTex] { combine texture * primary } 
         }
     }
 }
 

Any ideas?

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

47 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Transperent Side of a Texture becomes black in Shader PBR Graph 1 Answer

Problem with Z testing??? 1 Answer

Screen Not rendering 0 Answers

Please Help! Scene Lighting has Bugged Out and Colors are Not Showing Correctly Anymore 1 Answer

In ShaderLab, does alpha blending automatically turn off writing into depth buffer? 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