// Function to determine how much extra padding is required as a result of material properties like dilate, outline thickness, softness, glow, etc...
        public static float GetPadding(Material[] materials, bool enableExtraPadding, bool isBold)
        {
            //Debug.Log("GetPadding() called.");

            if (isInitialized == false)
            {
                GetShaderPropertyIDs();
            }

            // Return if Material is null
            if (materials == null)
            {
                return(0);
            }

            int extraPadding = enableExtraPadding ? 4 : 0;

            if (!materials[0].HasProperty(ShaderUtilities.ID_GradientScale))
            {
                return(extraPadding);   // We are using an non SDF Shader.
            }
            Vector4 padding    = Vector4.zero;
            Vector4 maxPadding = Vector4.zero;

            float faceDilate       = 0;
            float faceSoftness     = 0;
            float outlineThickness = 0;
            float scaleRatio_A     = 0;
            float scaleRatio_B     = 0;
            float scaleRatio_C     = 0;

            float glowOffset = 0;
            float glowOuter  = 0;

            float uniformPadding = 0;

            // Iterate through each of the assigned materials to find the max values to set the padding.
            for (int i = 0; i < materials.Length; i++)
            {
                // Update Shader Ratios prior to computing padding
                ShaderUtilities.UpdateShaderRatios(materials[i], isBold);

                string[] shaderKeywords = materials[i].shaderKeywords;

                if (materials[i].HasProperty(ShaderUtilities.ID_ScaleRatio_A))
                {
                    scaleRatio_A = materials[i].GetFloat(ShaderUtilities.ID_ScaleRatio_A);
                }

                if (materials[i].HasProperty(ShaderUtilities.ID_FaceDilate))
                {
                    faceDilate = materials[i].GetFloat(ShaderUtilities.ID_FaceDilate) * scaleRatio_A;
                }

                if (materials[i].HasProperty(ShaderUtilities.ID_OutlineSoftness))
                {
                    faceSoftness = materials[i].GetFloat(ShaderUtilities.ID_OutlineSoftness) * scaleRatio_A;
                }

                if (materials[i].HasProperty(ShaderUtilities.ID_OutlineWidth))
                {
                    outlineThickness = materials[i].GetFloat(ShaderUtilities.ID_OutlineWidth) * scaleRatio_A;
                }

                uniformPadding = outlineThickness + faceSoftness + faceDilate;

                // Glow padding contribution
                if (materials[i].HasProperty(ShaderUtilities.ID_GlowOffset) && shaderKeywords.Contains(ShaderUtilities.Keyword_Glow))
                {
                    if (materials[i].HasProperty(ShaderUtilities.ID_ScaleRatio_B))
                    {
                        scaleRatio_B = materials[i].GetFloat(ShaderUtilities.ID_ScaleRatio_B);
                    }

                    glowOffset = materials[i].GetFloat(ShaderUtilities.ID_GlowOffset) * scaleRatio_B;
                    glowOuter  = materials[i].GetFloat(ShaderUtilities.ID_GlowOuter) * scaleRatio_B;
                }

                uniformPadding = Mathf.Max(uniformPadding, faceDilate + glowOffset + glowOuter);

                // Underlay padding contribution
                if (materials[i].HasProperty(ShaderUtilities.ID_UnderlaySoftness) && shaderKeywords.Contains(ShaderUtilities.Keyword_Underlay))
                {
                    if (materials[i].HasProperty(ShaderUtilities.ID_ScaleRatio_C))
                    {
                        scaleRatio_C = materials[i].GetFloat(ShaderUtilities.ID_ScaleRatio_C);
                    }

                    float offsetX  = materials[i].GetFloat(ShaderUtilities.ID_UnderlayOffsetX) * scaleRatio_C;
                    float offsetY  = materials[i].GetFloat(ShaderUtilities.ID_UnderlayOffsetY) * scaleRatio_C;
                    float dilate   = materials[i].GetFloat(ShaderUtilities.ID_UnderlayDilate) * scaleRatio_C;
                    float softness = materials[i].GetFloat(ShaderUtilities.ID_UnderlaySoftness) * scaleRatio_C;

                    padding.x = Mathf.Max(padding.x, faceDilate + dilate + softness - offsetX);
                    padding.y = Mathf.Max(padding.y, faceDilate + dilate + softness - offsetY);
                    padding.z = Mathf.Max(padding.z, faceDilate + dilate + softness + offsetX);
                    padding.w = Mathf.Max(padding.w, faceDilate + dilate + softness + offsetY);
                }

                padding.x = Mathf.Max(padding.x, uniformPadding);
                padding.y = Mathf.Max(padding.y, uniformPadding);
                padding.z = Mathf.Max(padding.z, uniformPadding);
                padding.w = Mathf.Max(padding.w, uniformPadding);

                padding.x += extraPadding;
                padding.y += extraPadding;
                padding.z += extraPadding;
                padding.w += extraPadding;

                padding.x = Mathf.Min(padding.x, 1);
                padding.y = Mathf.Min(padding.y, 1);
                padding.z = Mathf.Min(padding.z, 1);
                padding.w = Mathf.Min(padding.w, 1);

                maxPadding.x = maxPadding.x < padding.x ? padding.x : maxPadding.x;
                maxPadding.y = maxPadding.y < padding.y ? padding.y : maxPadding.y;
                maxPadding.z = maxPadding.z < padding.z ? padding.z : maxPadding.z;
                maxPadding.w = maxPadding.w < padding.w ? padding.w : maxPadding.w;
            }

            float gradientScale = materials[0].GetFloat(ShaderUtilities.ID_GradientScale);

            padding *= gradientScale;

            // Set UniformPadding to the maximum value of any of its components.
            uniformPadding = Mathf.Max(padding.x, padding.y);
            uniformPadding = Mathf.Max(padding.z, uniformPadding);
            uniformPadding = Mathf.Max(padding.w, uniformPadding);

            return(uniformPadding + 0.25f);
        }
        public static float GetPadding(Material[] materials, bool enableExtraPadding, bool isBold)
        {
            if (!ShaderUtilities.isInitialized)
            {
                ShaderUtilities.GetShaderPropertyIDs();
            }
            if (materials == null)
            {
                return(0f);
            }
            int num = (!enableExtraPadding) ? 0 : 4;

            if (!materials[0].HasProperty(ShaderUtilities.ID_GradientScale))
            {
                return((float)num);
            }
            Vector4 a    = Vector4.zero;
            Vector4 zero = Vector4.zero;
            float   num2 = 0f;
            float   num3 = 0f;
            float   num4 = 0f;
            float   num5 = 0f;
            float   num6 = 0f;
            float   num7 = 0f;
            float   num8 = 0f;
            float   num9 = 0f;
            float   num10;

            for (int i = 0; i < materials.Length; i++)
            {
                ShaderUtilities.UpdateShaderRatios(materials[i]);
                string[] shaderKeywords = materials[i].shaderKeywords;
                if (materials[i].HasProperty(ShaderUtilities.ID_ScaleRatio_A))
                {
                    num5 = materials[i].GetFloat(ShaderUtilities.ID_ScaleRatio_A);
                }
                if (materials[i].HasProperty(ShaderUtilities.ID_FaceDilate))
                {
                    num2 = materials[i].GetFloat(ShaderUtilities.ID_FaceDilate) * num5;
                }
                if (materials[i].HasProperty(ShaderUtilities.ID_OutlineSoftness))
                {
                    num3 = materials[i].GetFloat(ShaderUtilities.ID_OutlineSoftness) * num5;
                }
                if (materials[i].HasProperty(ShaderUtilities.ID_OutlineWidth))
                {
                    num4 = materials[i].GetFloat(ShaderUtilities.ID_OutlineWidth) * num5;
                }
                num10 = num4 + num3 + num2;
                if (materials[i].HasProperty(ShaderUtilities.ID_GlowOffset) && shaderKeywords.Contains(ShaderUtilities.Keyword_Glow))
                {
                    if (materials[i].HasProperty(ShaderUtilities.ID_ScaleRatio_B))
                    {
                        num6 = materials[i].GetFloat(ShaderUtilities.ID_ScaleRatio_B);
                    }
                    num8 = materials[i].GetFloat(ShaderUtilities.ID_GlowOffset) * num6;
                    num9 = materials[i].GetFloat(ShaderUtilities.ID_GlowOuter) * num6;
                }
                num10 = Mathf.Max(num10, num2 + num8 + num9);
                if (materials[i].HasProperty(ShaderUtilities.ID_UnderlaySoftness) && shaderKeywords.Contains(ShaderUtilities.Keyword_Underlay))
                {
                    if (materials[i].HasProperty(ShaderUtilities.ID_ScaleRatio_C))
                    {
                        num7 = materials[i].GetFloat(ShaderUtilities.ID_ScaleRatio_C);
                    }
                    float num11 = materials[i].GetFloat(ShaderUtilities.ID_UnderlayOffsetX) * num7;
                    float num12 = materials[i].GetFloat(ShaderUtilities.ID_UnderlayOffsetY) * num7;
                    float num13 = materials[i].GetFloat(ShaderUtilities.ID_UnderlayDilate) * num7;
                    float num14 = materials[i].GetFloat(ShaderUtilities.ID_UnderlaySoftness) * num7;
                    a.x = Mathf.Max(a.x, num2 + num13 + num14 - num11);
                    a.y = Mathf.Max(a.y, num2 + num13 + num14 - num12);
                    a.z = Mathf.Max(a.z, num2 + num13 + num14 + num11);
                    a.w = Mathf.Max(a.w, num2 + num13 + num14 + num12);
                }
                a.x    = Mathf.Max(a.x, num10);
                a.y    = Mathf.Max(a.y, num10);
                a.z    = Mathf.Max(a.z, num10);
                a.w    = Mathf.Max(a.w, num10);
                a.x   += (float)num;
                a.y   += (float)num;
                a.z   += (float)num;
                a.w   += (float)num;
                a.x    = Mathf.Min(a.x, 1f);
                a.y    = Mathf.Min(a.y, 1f);
                a.z    = Mathf.Min(a.z, 1f);
                a.w    = Mathf.Min(a.w, 1f);
                zero.x = ((zero.x >= a.x) ? zero.x : a.x);
                zero.y = ((zero.y >= a.y) ? zero.y : a.y);
                zero.z = ((zero.z >= a.z) ? zero.z : a.z);
                zero.w = ((zero.w >= a.w) ? zero.w : a.w);
            }
            float @float = materials[0].GetFloat(ShaderUtilities.ID_GradientScale);

            a    *= @float;
            num10 = Mathf.Max(a.x, a.y);
            num10 = Mathf.Max(a.z, num10);
            num10 = Mathf.Max(a.w, num10);
            return(num10 + 0.25f);
        }