Skip to content

Commit 25b7bcc

Browse files
authored
Merge branch 'master' into master
2 parents 9a3084b + 6b17fba commit 25b7bcc

File tree

6 files changed

+37
-54
lines changed

6 files changed

+37
-54
lines changed

Assets/Resources/Shaders/FairyGUI-BMFont.shader

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ Shader "FairyGUI/BMFont"
4949
Pass
5050
{
5151
CGPROGRAM
52-
#pragma multi_compile NOT_GRAYED GRAYED
53-
#pragma multi_compile NOT_CLIPPED CLIPPED SOFT_CLIPPED
52+
#pragma multi_compile _ GRAYED
53+
#pragma multi_compile _ CLIPPED SOFT_CLIPPED
5454
#pragma vertex vert
5555
#pragma fragment frag
5656
#pragma exclude_renderers d3d9 opengl flash
@@ -127,28 +127,22 @@ Shader "FairyGUI/BMFont"
127127
#endif
128128

129129
#ifdef SOFT_CLIPPED
130-
float2 factor = float2(0,0);
131-
if(i.clipPos.x<0)
132-
factor.x = (1.0-abs(i.clipPos.x)) * _ClipSoftness.x;
133-
else
134-
factor.x = (1.0-i.clipPos.x) * _ClipSoftness.z;
135-
if(i.clipPos.y<0)
136-
factor.y = (1.0-abs(i.clipPos.y)) * _ClipSoftness.w;
137-
else
138-
factor.y = (1.0-i.clipPos.y) * _ClipSoftness.y;
130+
float2 factor;
131+
float2 condition = step(i.clipPos.xy, 0);
132+
float4 clip_softness = _ClipSoftness * float4(condition, 1 - condition);
133+
factor.xy = (1.0 - abs(i.clipPos.xy)) * (clip_softness.xw + clip_softness.zy);
139134
col.a *= clamp(min(factor.x, factor.y), 0.0, 1.0);
140135
#endif
141-
142136
#ifdef CLIPPED
143137
float2 factor = abs(i.clipPos);
144138
col.a *= step(max(factor.x, factor.y), 1);
145139
#endif
146140

147141
return col;
148-
}
142+
}
149143
ENDCG
150144
}
151145
}
152146

153-
Fallback "FairyGUI/Text"
147+
//Fallback "FairyGUI/Text"
154148
}

Assets/Resources/Shaders/FairyGUI-Image.shader

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ Shader "FairyGUI/Image"
4949
Pass
5050
{
5151
CGPROGRAM
52-
#pragma multi_compile NOT_COMBINED COMBINED
53-
#pragma multi_compile NOT_GRAYED GRAYED COLOR_FILTER
54-
#pragma multi_compile NOT_CLIPPED CLIPPED SOFT_CLIPPED ALPHA_MASK
52+
#pragma multi_compile _ COMBINED
53+
#pragma multi_compile _ GRAYED COLOR_FILTER
54+
#pragma multi_compile _ CLIPPED SOFT_CLIPPED ALPHA_MASK
5555
#pragma vertex vert
5656
#pragma fragment frag
5757

@@ -139,15 +139,10 @@ Shader "FairyGUI/Image"
139139
#endif
140140

141141
#ifdef SOFT_CLIPPED
142-
float2 factor = float2(0,0);
143-
if(i.clipPos.x<0)
144-
factor.x = (1.0-abs(i.clipPos.x)) * _ClipSoftness.x;
145-
else
146-
factor.x = (1.0-i.clipPos.x) * _ClipSoftness.z;
147-
if(i.clipPos.y<0)
148-
factor.y = (1.0-abs(i.clipPos.y)) * _ClipSoftness.w;
149-
else
150-
factor.y = (1.0-i.clipPos.y) * _ClipSoftness.y;
142+
float2 factor;
143+
float2 condition = step(i.clipPos.xy, 0);
144+
float4 clip_softness = _ClipSoftness * float4(condition, 1 - condition);
145+
factor.xy = (1.0 - abs(i.clipPos.xy)) * (clip_softness.xw + clip_softness.zy);
151146
col.a *= clamp(min(factor.x, factor.y), 0.0, 1.0);
152147
#endif
153148

Assets/Resources/Shaders/FairyGUI-Text.shader

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ Shader "FairyGUI/Text"
4949
Pass
5050
{
5151
CGPROGRAM
52-
#pragma multi_compile NOT_GRAYED GRAYED
53-
#pragma multi_compile NOT_CLIPPED CLIPPED SOFT_CLIPPED
52+
#pragma multi_compile _ GRAYED
53+
#pragma multi_compile _ CLIPPED SOFT_CLIPPED
5454
#pragma vertex vert
5555
#pragma fragment frag
5656

@@ -125,15 +125,10 @@ Shader "FairyGUI/Text"
125125
#endif
126126

127127
#ifdef SOFT_CLIPPED
128-
float2 factor = float2(0,0);
129-
if(i.clipPos.x<0)
130-
factor.x = (1.0-abs(i.clipPos.x)) * _ClipSoftness.x;
131-
else
132-
factor.x = (1.0-i.clipPos.x) * _ClipSoftness.z;
133-
if(i.clipPos.y<0)
134-
factor.y = (1.0-abs(i.clipPos.y)) * _ClipSoftness.w;
135-
else
136-
factor.y = (1.0-i.clipPos.y) * _ClipSoftness.y;
128+
float2 factor;
129+
float2 condition = step(i.clipPos.xy, 0);
130+
float4 clip_softness = _ClipSoftness * float4(condition, 1 - condition);
131+
factor.xy = (1.0 - abs(i.clipPos.xy)) * (clip_softness.xw + clip_softness.zy);
137132
col.a *= clamp(min(factor.x, factor.y), 0.0, 1.0);
138133
#endif
139134

Assets/Scripts/Core/Container.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ private void DoFairyBatching()
942942

943943
private void CollectChildren(Container initiator, bool outlineChanged)
944944
{
945+
EnsureSizeCorrect();
945946
int count = _children.Count;
946947
for (int i = 0; i < count; i++)
947948
{

Assets/Scripts/Core/DisplayObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ virtual public void SetRenderingOrder(UpdateContext context, bool inBatch)
885885
return;
886886
}
887887

888-
_renderingOrder = context.renderingOrder + 1;
888+
_renderingOrder = context.renderingOrder;
889889
if (graphics != null)
890890
graphics.SetRenderingOrder(context, inBatch);
891891
else

Assets/Scripts/Extensions/TextMeshPro/Shaders/FairyGUI-TMP.shader

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ Properties {
8181
_StencilReadMask ("Stencil Read Mask", Float) = 255
8282

8383
_ColorMask ("Color Mask", Float) = 15
84+
85+
_BlendSrcFactor ("Blend SrcFactor", Float) = 5
86+
_BlendDstFactor ("Blend DstFactor", Float) = 10
8487
}
8588

8689
SubShader {
@@ -106,7 +109,8 @@ SubShader {
106109
Lighting Off
107110
Fog { Mode Off }
108111
ZTest [unity_GUIZTestMode]
109-
Blend One OneMinusSrcAlpha
112+
113+
Blend [_BlendSrcFactor] [_BlendDstFactor]
110114
ColorMask [_ColorMask]
111115

112116
Pass {
@@ -120,8 +124,8 @@ SubShader {
120124

121125
//#pragma multi_compile __ UNITY_UI_CLIP_RECT
122126
//#pragma multi_compile __ UNITY_UI_ALPHACLIP
123-
#pragma multi_compile NOT_GRAYED GRAYED
124-
#pragma multi_compile NOT_CLIPPED CLIPPED SOFT_CLIPPED
127+
#pragma multi_compile _ GRAYED
128+
#pragma multi_compile _ CLIPPED SOFT_CLIPPED
125129

126130
#include "UnityCG.cginc"
127131
#include "UnityUI.cginc"
@@ -455,26 +459,20 @@ SubShader {
455459
#endif
456460

457461
#ifdef SOFT_CLIPPED
458-
float2 factor = float2(0,0);
459-
if(input.mask.x<0)
460-
factor.x = (1.0-abs(input.mask.x)) * _ClipSoftness.x;
461-
else
462-
factor.x = (1.0-input.mask.x) * _ClipSoftness.z;
463-
if(input.mask.y<0)
464-
factor.y = (1.0-abs(input.mask.y)) * _ClipSoftness.w;
465-
else
466-
factor.y = (1.0-input.mask.y) * _ClipSoftness.y;
462+
float2 factor;
463+
float2 condition = step(input.mask.xy, 0);
464+
float4 clip_softness = _ClipSoftness * float4(condition, 1 - condition);
465+
factor.xy = (1.0 - abs(input.mask.xy)) * (clip_softness.xw + clip_softness.zy);
467466
faceColor.a *= clamp(min(factor.x, factor.y), 0.0, 1.0);
468467
clip(faceColor.a - 0.001);
469468
#endif
470-
471-
return faceColor * input.color.a;
472-
}
469+
return half4(faceColor.rgb, input.color.a * faceColor.a);
470+
}
473471

474472
ENDCG
475473
}
476474
}
477475

478-
Fallback "TextMeshPro/Mobile/Distance Field"
476+
//Fallback "TextMeshPro/Mobile/Distance Field"
479477
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
480478
}

0 commit comments

Comments
 (0)