fix #33; Shaders for TMPro have compile errors
parent
e954e6d3b2
commit
ab6e037a23
|
@ -151,6 +151,7 @@ SubShader {
|
|||
fixed4 underlayColor : COLOR1;
|
||||
#endif
|
||||
float4 textures : TEXCOORD5;
|
||||
SOFTMASK_EDITOR_ONLY(float4 worldPosition : TEXCOORD6;)
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
|
@ -220,6 +221,7 @@ SubShader {
|
|||
underlayColor,
|
||||
#endif
|
||||
float4(faceUV, outlineUV),
|
||||
SOFTMASK_EDITOR_ONLY(input.position)
|
||||
};
|
||||
|
||||
return output;
|
||||
|
@ -292,7 +294,7 @@ SubShader {
|
|||
faceColor *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
faceColor *= SoftMask(input.position);
|
||||
faceColor *= SoftMask(input.position, input.worldPosition);
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(faceColor.a - 0.001);
|
||||
|
|
|
@ -113,6 +113,7 @@ SubShader {
|
|||
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
|
||||
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
|
||||
#endif
|
||||
SOFTMASK_EDITOR_ONLY(float4 worldPosition : TEXCOORD5;)
|
||||
};
|
||||
|
||||
|
||||
|
@ -180,6 +181,7 @@ SubShader {
|
|||
float4(input.texcoord0 + layerOffset, input.color.a, 0),
|
||||
half2(layerScale, layerBias),
|
||||
#endif
|
||||
SOFTMASK_EDITOR_ONLY(input.vertex)
|
||||
};
|
||||
|
||||
return output;
|
||||
|
@ -218,7 +220,7 @@ SubShader {
|
|||
c *= input.texcoord1.z;
|
||||
#endif
|
||||
|
||||
c *= SoftMask(input.vertex);
|
||||
c *= SoftMask(input.vertex, input.worldPosition);
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(c.a - 0.001);
|
||||
|
|
|
@ -104,7 +104,7 @@ Shader "TextMeshPro/Sprite (SoftMaskable)"
|
|||
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
#endif
|
||||
|
||||
color.a *= SoftMask(IN.vertex);
|
||||
color.a *= SoftMask(IN.vertex, IN.worldPosition);
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
|
|
|
@ -19,14 +19,18 @@ fixed Approximately(float4x4 a, float4x4 b)
|
|||
1);
|
||||
}
|
||||
|
||||
fixed GetMaskAlpha(fixed alpha, fixed stencilId, fixed interaction)
|
||||
float GetMaskAlpha(float alpha, int stencilId, float interaction)
|
||||
{
|
||||
fixed onStencil = step(stencilId, _Stencil);
|
||||
alpha = lerp(1, alpha, onStencil * step(1, interaction));
|
||||
return lerp(alpha, 1 - alpha, onStencil * step(2, interaction));
|
||||
}
|
||||
|
||||
half SoftMask(float4 clipPos, float4 wpos)
|
||||
#if SOFTMASK_EDITOR
|
||||
float SoftMaskInternal(float4 clipPos, float4 wpos)
|
||||
#else
|
||||
float SoftMaskInternal(float4 clipPos)
|
||||
#endif
|
||||
{
|
||||
half2 view = clipPos.xy/_ScreenParams.xy;
|
||||
#if SOFTMASK_EDITOR
|
||||
|
@ -43,9 +47,18 @@ half SoftMask(float4 clipPos, float4 wpos)
|
|||
half alpha = GetMaskAlpha(mask.x, 1, _MaskInteraction.x)
|
||||
* GetMaskAlpha(mask.y, 3, _MaskInteraction.y)
|
||||
* GetMaskAlpha(mask.z, 7, _MaskInteraction.z)
|
||||
* GetMaskAlpha(mask.w, 15, _MaskInteraction.w);
|
||||
* GetMaskAlpha(mask.w, 15, _MaskInteraction.w)
|
||||
;
|
||||
|
||||
return alpha;
|
||||
}
|
||||
|
||||
#if SOFTMASK_EDITOR
|
||||
#define SOFTMASK_EDITOR_ONLY(x) x
|
||||
#define SoftMask(clipPos, worldPosition) SoftMaskInternal(clipPos, worldPosition)
|
||||
#else
|
||||
#define SOFTMASK_EDITOR_ONLY(x)
|
||||
#define SoftMask(clipPos, worldPosition) SoftMaskInternal(clipPos)
|
||||
#endif
|
||||
|
||||
#endif // UI_SOFTMASK_INCLUDED
|
Loading…
Reference in New Issue