Ejemplo n.º 1
0
        public static void UpdateShaderRatios(Material mat, bool isBold)
        {
            bool  flag   = !ShaderUtilities.StringContains(mat.shaderKeywords, ShaderUtilities.Keyword_Ratios);
            float @float = mat.GetFloat(ShaderUtilities.ID_GradientScale);
            float float2 = mat.GetFloat(ShaderUtilities.ID_FaceDilate);
            float float3 = mat.GetFloat(ShaderUtilities.ID_OutlineWidth);
            float float4 = mat.GetFloat(ShaderUtilities.ID_OutlineSoftness);
            float num    = (!isBold) ? (mat.GetFloat(ShaderUtilities.ID_WeightNormal) * 2f / @float) : (mat.GetFloat(ShaderUtilities.ID_WeightBold) * 2f / @float);
            float num2   = Mathf.Max(1f, num + float2 + float3 + float4);
            float value  = flag ? ((@float - ShaderUtilities.m_clamp) / (@float * num2)) : 1f;

            mat.SetFloat(ShaderUtilities.ID_ScaleRatio_A, value);
            if (mat.HasProperty(ShaderUtilities.ID_GlowOffset))
            {
                float float5 = mat.GetFloat(ShaderUtilities.ID_GlowOffset);
                float float6 = mat.GetFloat(ShaderUtilities.ID_GlowOuter);
                float num3   = (num + float2) * (@float - ShaderUtilities.m_clamp);
                num2 = Mathf.Max(1f, float5 + float6);
                float value2 = flag ? (Mathf.Max(0f, @float - ShaderUtilities.m_clamp - num3) / (@float * num2)) : 1f;
                mat.SetFloat(ShaderUtilities.ID_ScaleRatio_B, value2);
            }
            if (mat.HasProperty(ShaderUtilities.ID_UnderlayOffsetX))
            {
                float float7  = mat.GetFloat(ShaderUtilities.ID_UnderlayOffsetX);
                float float8  = mat.GetFloat(ShaderUtilities.ID_UnderlayOffsetY);
                float float9  = mat.GetFloat(ShaderUtilities.ID_UnderlayDilate);
                float float10 = mat.GetFloat(ShaderUtilities.ID_UnderlaySoftness);
                float num4    = (num + float2) * (@float - ShaderUtilities.m_clamp);
                num2 = Mathf.Max(1f, Mathf.Max(Mathf.Abs(float7), Mathf.Abs(float8)) + float9 + float10);
                float value3 = flag ? (Mathf.Max(0f, @float - ShaderUtilities.m_clamp - num4) / (@float * num2)) : 1f;
                mat.SetFloat(ShaderUtilities.ID_ScaleRatio_C, value3);
            }
        }
Ejemplo n.º 2
0
        public static float GetPadding(Material[] materials, bool enableExtraPadding, bool isBold)
        {
            if (!ShaderUtilities.isInitialized)
            {
                ShaderUtilities.GetShaderPropertyIDs();
            }
            if (materials == null)
            {
                return(0f);
            }
            int num = enableExtraPadding ? 4 : 0;

            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], isBold);
                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) && ShaderUtilities.StringContains(shaderKeywords, 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) && ShaderUtilities.StringContains(shaderKeywords, 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) ? a.x : zero.x);
                zero.y = ((zero.y < a.y) ? a.y : zero.y);
                zero.z = ((zero.z < a.z) ? a.z : zero.z);
                zero.w = ((zero.w < a.w) ? a.w : zero.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);
        }
Ejemplo n.º 3
0
 public static bool IsMaskingEnabled(Material material)
 {
     return(!(material == null) && material.HasProperty(ShaderUtilities.ID_MaskCoord) && (ShaderUtilities.StringContains(material.shaderKeywords, ShaderUtilities.Keyword_MASK_SOFT) || ShaderUtilities.StringContains(material.shaderKeywords, ShaderUtilities.Keyword_MASK_HARD)));
 }