Пример #1
0
    public static int UnityStyleLightmapResolution(SunshineLightResolutions resolution)
    {
        if (resolution == SunshineLightResolutions.Custom)
        {
            return(0);
        }
        int num  = Mathf.Max(Screen.width, Screen.height);
        int num2 = Mathf.NextPowerOfTwo((int)((float)num * 1.9f));
        int a    = 2048;

        if (SystemInfo.graphicsMemorySize >= 512)
        {
            a = 4096;
        }
        num2 = Mathf.Min(a, num2);
        if (resolution != SunshineLightResolutions.LowResolution)
        {
            if (resolution != SunshineLightResolutions.MediumResolution)
            {
                if (resolution == SunshineLightResolutions.VeryHighResolution)
                {
                    num2 *= 2;
                }
            }
            else
            {
                num2 /= 2;
            }
        }
        else
        {
            num2 /= 4;
        }
        return(Mathf.Min(a, num2));
    }
Пример #2
0
 public static int UnityStyleLightmapResolution(SunshineLightResolutions resolution)
 {
     if (resolution == SunshineLightResolutions.Custom)
     {
         return 0;
     }
     int num = Mathf.Max(Screen.width, Screen.height);
     int num2 = Mathf.NextPowerOfTwo((int)((float)num * 1.9f));
     int a = 2048;
     if (SystemInfo.graphicsMemorySize >= 512)
     {
         a = 4096;
     }
     num2 = Mathf.Min(a, num2);
     switch (resolution)
     {
     case SunshineLightResolutions.LowResolution:
         num2 /= 4;
         break;
     case SunshineLightResolutions.MediumResolution:
         num2 /= 2;
         break;
     case SunshineLightResolutions.VeryHighResolution:
         num2 *= 2;
         break;
     }
     return Mathf.Min(a, num2);
 }
Пример #3
0
    /// <summary>
    /// Estimates the Shadow Resolution that Unity internally calculates
    /// </summary>
    /// <returns>
    /// The resolution that Unity is estimated to use...
    /// </returns>
    /// <param name='resolution'>
    /// An approximate Resolution quality...
    /// </param>
    public static int UnityStyleLightmapResolution(SunshineLightResolutions resolution)
    {
        if(resolution == SunshineLightResolutions.Custom)
            return 0;
        //Excerpt from the Unity Documentation:
        /*
            Directional lights: NextPowerOfTwo( pixel size * 1.9 ), but no more than 2048.
            When graphics card has 512MB or more video memory, the upper shadow map limits are increased (4096 for Directional, 2048 for Spot, 1024 for Point lights).
            At "Medium" shadow resolution, shadow map size is 2X smaller than at "High" resolution. And at "Low" resolution, it's 4X smaller than at "High" resolution.
        */
        int pixelSize = Mathf.Max(Screen.width, Screen.height);
        int result = Mathf.NextPowerOfTwo((int)((float)pixelSize * 1.9f));
        int dimensionLimit = 2048;
        if(SystemInfo.graphicsMemorySize >= 512)
            dimensionLimit = 4096;

        result = Mathf.Min(dimensionLimit, result); //Yes, both Min()'s appear to be required to simulate Unity Sizing...
        switch(resolution)
        {
        case SunshineLightResolutions.LowResolution: result /= 4; break;
        case SunshineLightResolutions.MediumResolution: result /= 2; break;
        case SunshineLightResolutions.VeryHighResolution: result *= 2; break;
        }
        result = Mathf.Min(dimensionLimit, result); //Yes, both Min()'s appear to be required to simulate Unity Sizing...

        //TODO: Reduce until Lightmap fits into...
        //(TotalVideoMemory - ScreenMemory - RenderTextureMemory) / 3.

        return result;
    }