fix #33; Shaders for TMPro have compile errors

pull/87/head
mob-sakai 2019-02-05 09:21:37 +09:00
parent e954e6d3b2
commit ab6e037a23
4 changed files with 23 additions and 6 deletions

View File

@ -151,6 +151,7 @@ SubShader {
fixed4 underlayColor : COLOR1; fixed4 underlayColor : COLOR1;
#endif #endif
float4 textures : TEXCOORD5; float4 textures : TEXCOORD5;
SOFTMASK_EDITOR_ONLY(float4 worldPosition : TEXCOORD6;)
}; };
// Used by Unity internally to handle Texture Tiling and Offset. // Used by Unity internally to handle Texture Tiling and Offset.
@ -220,6 +221,7 @@ SubShader {
underlayColor, underlayColor,
#endif #endif
float4(faceUV, outlineUV), float4(faceUV, outlineUV),
SOFTMASK_EDITOR_ONLY(input.position)
}; };
return output; return output;
@ -292,7 +294,7 @@ SubShader {
faceColor *= m.x * m.y; faceColor *= m.x * m.y;
#endif #endif
faceColor *= SoftMask(input.position); faceColor *= SoftMask(input.position, input.worldPosition);
#if UNITY_UI_ALPHACLIP #if UNITY_UI_ALPHACLIP
clip(faceColor.a - 0.001); clip(faceColor.a - 0.001);

View File

@ -113,6 +113,7 @@ SubShader {
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y) half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
#endif #endif
SOFTMASK_EDITOR_ONLY(float4 worldPosition : TEXCOORD5;)
}; };
@ -180,6 +181,7 @@ SubShader {
float4(input.texcoord0 + layerOffset, input.color.a, 0), float4(input.texcoord0 + layerOffset, input.color.a, 0),
half2(layerScale, layerBias), half2(layerScale, layerBias),
#endif #endif
SOFTMASK_EDITOR_ONLY(input.vertex)
}; };
return output; return output;
@ -218,7 +220,7 @@ SubShader {
c *= input.texcoord1.z; c *= input.texcoord1.z;
#endif #endif
c *= SoftMask(input.vertex); c *= SoftMask(input.vertex, input.worldPosition);
#if UNITY_UI_ALPHACLIP #if UNITY_UI_ALPHACLIP
clip(c.a - 0.001); clip(c.a - 0.001);

View File

@ -104,7 +104,7 @@ Shader "TextMeshPro/Sprite (SoftMaskable)"
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect); color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
#endif #endif
color.a *= SoftMask(IN.vertex); color.a *= SoftMask(IN.vertex, IN.worldPosition);
#ifdef UNITY_UI_ALPHACLIP #ifdef UNITY_UI_ALPHACLIP
clip (color.a - 0.001); clip (color.a - 0.001);

View File

@ -19,14 +19,18 @@ fixed Approximately(float4x4 a, float4x4 b)
1); 1);
} }
fixed GetMaskAlpha(fixed alpha, fixed stencilId, fixed interaction) float GetMaskAlpha(float alpha, int stencilId, float interaction)
{ {
fixed onStencil = step(stencilId, _Stencil); fixed onStencil = step(stencilId, _Stencil);
alpha = lerp(1, alpha, onStencil * step(1, interaction)); alpha = lerp(1, alpha, onStencil * step(1, interaction));
return lerp(alpha, 1 - alpha, onStencil * step(2, 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; half2 view = clipPos.xy/_ScreenParams.xy;
#if SOFTMASK_EDITOR #if SOFTMASK_EDITOR
@ -43,9 +47,18 @@ half SoftMask(float4 clipPos, float4 wpos)
half alpha = GetMaskAlpha(mask.x, 1, _MaskInteraction.x) half alpha = GetMaskAlpha(mask.x, 1, _MaskInteraction.x)
* GetMaskAlpha(mask.y, 3, _MaskInteraction.y) * GetMaskAlpha(mask.y, 3, _MaskInteraction.y)
* GetMaskAlpha(mask.z, 7, _MaskInteraction.z) * GetMaskAlpha(mask.z, 7, _MaskInteraction.z)
* GetMaskAlpha(mask.w, 15, _MaskInteraction.w); * GetMaskAlpha(mask.w, 15, _MaskInteraction.w)
;
return alpha; 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 #endif // UI_SOFTMASK_INCLUDED