I have a simple UI shader based off of the UI Default shader that is applied to a masked RawImage to fill with color and fade to full color.
This works great on iOS/tvOS but doesn’t show on some OSX devices. There is no pink replacement when it fails, so its not something wrong with the shader missing on those OSX devices. It just doesn’t render at all. At first I thought it was the UI mask, but this shader has all the correct stencil properties for UI masks.
Unity 2019.3.14f1
I’ve included the shader in the always include shaders list in the Graphics settings.
OSX is set to auto graphics api, which I believe should pick between Metal & OpenGLCore.
On iOS/tvOS are set to use Metal.
I’m stumped trying to identify why its not working sometimes on MACs. Any help?
Shader "UI/Silhouetted" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_FillColor ("FillColor", Color) = (1,1,1,1)
_FillPhase ("FillPhase", Range(0, 1)) = 0
_StencilComp ("Stencil Comparison", Float) = 6
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
LOD 100
Blend One OneMinusSrcAlpha
Cull Off Lighting Off ZWrite Off
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
ColorMask [_ColorMask]
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
float4 _FillColor;
float _FillPhase;
v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// apply sihouette fill color
float4 rawColor = tex2D(_MainTex,i.uv);
float3 finalColor = lerp(rawColor.rgb, (_FillColor.rgb * rawColor.a), _FillPhase);
return fixed4(finalColor, rawColor.a);
}
ENDCG
}
}
FallBack "UI/Default"
}