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.
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?
Your answer
Follow this Question
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