Пример #1
0
    public static void CalculateKernel(Color[] target, int targetStart, int targetSize, Color subsurfaceColor, Color falloffColor)
    {
        float single;
        int   num     = targetSize;
        int   num1    = num * 2 - 1;
        float single1 = (num1 > 20 ? 3f : 2f);
        float single2 = 2f;

        Color[] colorArray = new Color[num1];
        float   single3    = 2f * single1 / (float)(num1 - 1);

        for (int i = 0; i < num1; i++)
        {
            float single4 = -single1 + (float)i * single3;
            float single5 = (single4 < 0f ? -1f : 1f);
            colorArray[i].a = single1 * single5 * Mathf.Abs(Mathf.Pow(single4, single2)) / Mathf.Pow(single1, single2);
        }
        for (int j = 0; j < num1; j++)
        {
            single = (j > 0 ? Mathf.Abs(colorArray[j].a - colorArray[j - 1].a) : 0f);
            float   single6 = (j < num1 - 1 ? Mathf.Abs(colorArray[j].a - colorArray[j + 1].a) : 0f);
            Vector3 vector3 = (single + single6) / 2f * SeparableSSS.Profile(colorArray[j].a, falloffColor);
            colorArray[j].r = vector3.x;
            colorArray[j].g = vector3.y;
            colorArray[j].b = vector3.z;
        }
        Color color = colorArray[num1 / 2];

        for (int k = num1 / 2; k > 0; k--)
        {
            colorArray[k] = colorArray[k - 1];
        }
        colorArray[0] = color;
        Vector3 vector31 = Vector3.zero;

        for (int l = 0; l < num1; l++)
        {
            vector31.x += colorArray[l].r;
            vector31.y += colorArray[l].g;
            vector31.z += colorArray[l].b;
        }
        for (int m = 0; m < num1; m++)
        {
            colorArray[m].r /= vector31.x;
            colorArray[m].g /= vector31.y;
            colorArray[m].b /= vector31.z;
        }
        target[targetStart] = colorArray[0];
        for (uint n = 0; (ulong)n < (long)(num - 1); n++)
        {
            target[checked ((IntPtr)((long)targetStart + (ulong)n + (long)1))] = colorArray[checked ((IntPtr)((long)num + (ulong)n))];
        }
    }
Пример #2
0
    public static void CalculateKernel(
        Color[] target,
        int targetStart,
        int targetSize,
        Color subsurfaceColor,
        Color falloffColor)
    {
        int   num1   = targetSize;
        int   length = num1 * 2 - 1;
        float num2   = length > 20 ? 3f : 2f;
        float num3   = 2f;

        Color[] colorArray = new Color[length];
        float   num4       = 2f * num2 / (float)(length - 1);

        for (int index = 0; index < length; ++index)
        {
            float num5 = (float)(-(double)num2 + (double)index * (double)num4);
            float num6 = (double)num5 < 0.0 ? -1f : 1f;
            colorArray[index].a = (__Null)((double)num2 * (double)num6 * (double)Mathf.Abs(Mathf.Pow(num5, num3)) / (double)Mathf.Pow(num2, num3));
        }
        for (int index = 0; index < length; ++index)
        {
            Vector3 vector3 = Vector3.op_Multiply((float)(((index > 0 ? (double)Mathf.Abs((float)(colorArray[index].a - colorArray[index - 1].a)) : 0.0) + (index < length - 1 ? (double)Mathf.Abs((float)(colorArray[index].a - colorArray[index + 1].a)) : 0.0)) / 2.0), SeparableSSS.Profile((float)colorArray[index].a, falloffColor));
            colorArray[index].r = vector3.x;
            colorArray[index].g = vector3.y;
            colorArray[index].b = vector3.z;
        }
        Color color = colorArray[length / 2];

        for (int index = length / 2; index > 0; --index)
        {
            colorArray[index] = colorArray[index - 1];
        }
        colorArray[0] = color;
        Vector3 zero = Vector3.get_zero();

        for (int index = 0; index < length; ++index)
        {
            ref __Null local1 = ref zero.x;