Fixed broken batching

pull/77/head
phoenix 2020-04-13 09:41:49 +02:00
parent f89df67e86
commit 5207e9882d
2 changed files with 6307 additions and 161 deletions

View File

@ -24,7 +24,7 @@ namespace Coffee.UIExtensions
//################################ //################################
const int kVisibleInside = (1 << 0) + (1 << 2) + (1 << 4) + (1 << 6); const int kVisibleInside = (1 << 0) + (1 << 2) + (1 << 4) + (1 << 6);
const int kVisibleOutside = (2 << 0) + (2 << 2) + (2 << 4) + (2 << 6); const int kVisibleOutside = (2 << 0) + (2 << 2) + (2 << 4) + (2 << 6);
private static readonly Dictionary<Material,Dictionary<SoftMask,Material>> s_clonedMaterials = new Dictionary<Material,Dictionary<SoftMask,Material>>();
//################################ //################################
// Serialize Members. // Serialize Members.
@ -69,9 +69,18 @@ namespace Coffee.UIExtensions
parentTransform = parentTransform.parent; parentTransform = parentTransform.parent;
} }
Dictionary<SoftMask,Material> dictBySoftMask = null;
Material result = baseMaterial; Material result = baseMaterial;
if (_softMask) if (_softMask)
{ {
if (s_clonedMaterials.TryGetValue(baseMaterial, out dictBySoftMask))
{
Material clonedMat;
if (dictBySoftMask.TryGetValue(_softMask, out clonedMat))
return clonedMat;
}
result = new Material(baseMaterial); result = new Material(baseMaterial);
result.hideFlags = HideFlags.HideAndDontSave; result.hideFlags = HideFlags.HideAndDontSave;
result.SetTexture(s_SoftMaskTexId, _softMask.softMaskBuffer); result.SetTexture(s_SoftMaskTexId, _softMask.softMaskBuffer);
@ -83,7 +92,6 @@ namespace Coffee.UIExtensions
((m_MaskInteraction >> 6) & 0x3) ((m_MaskInteraction >> 6) & 0x3)
)); ));
StencilMaterial.Remove(baseMaterial);
ReleaseMaterial(ref _maskMaterial); ReleaseMaterial(ref _maskMaterial);
_maskMaterial = result; _maskMaterial = result;
@ -95,8 +103,16 @@ namespace Coffee.UIExtensions
else else
{ {
baseMaterial.SetTexture(s_SoftMaskTexId, Texture2D.whiteTexture); baseMaterial.SetTexture(s_SoftMaskTexId, Texture2D.whiteTexture);
return baseMaterial;
} }
if (dictBySoftMask == null)
{
dictBySoftMask = new Dictionary<SoftMask, Material>();
s_clonedMaterials.Add(baseMaterial, dictBySoftMask);
}
dictBySoftMask.Add(_softMask, result);
return result; return result;
} }

File diff suppressed because it is too large Load Diff