Exemplo n.º 1
0
        /// <summary>
        /// Gets the size of the desampling.
        /// </summary>
        void GetDesamplingSize(DesamplingRate rate, out int w, out int h)
        {
#if UNITY_EDITOR
            var res = UnityEditor.UnityStats.screenRes.Split('x');
            w = int.Parse(res[0]);
            h = int.Parse(res[1]);
#else
            w = Screen.width;
            h = Screen.height;
#endif

            if (rate == DesamplingRate.None)
            {
                return;
            }

            float aspect = (float)w / h;
            if (w < h)
            {
                h = Mathf.ClosestPowerOfTwo(h / (int)rate);
                w = Mathf.CeilToInt(h * aspect);
            }
            else
            {
                w = Mathf.ClosestPowerOfTwo(w / (int)rate);
                h = Mathf.CeilToInt(w / aspect);
            }
        }
 protected override void Reset()
 {
     // Set parameters as 'Medium'.
     m_BlurIterations = 3;
     m_FilterMode     = FilterMode.Bilinear;
     m_DesamplingRate = DesamplingRate.x1;
     m_ReductionRate  = DesamplingRate.x1;
     base.Reset();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the size of the desampling.
        /// </summary>
        public void GetDesamplingSize(DesamplingRate rate, out int w, out int h)
        {
            var cam = canvas.worldCamera ?? Camera.main;

            h = cam.pixelHeight;
            w = cam.pixelWidth;
            if (rate != DesamplingRate.None)
            {
                h = Mathf.ClosestPowerOfTwo(h / (int)rate);
                w = Mathf.ClosestPowerOfTwo(w / (int)rate);
            }
        }
        /// <summary>
        /// Gets the size of the desampling.
        /// </summary>
        public void GetDesamplingSize(DesamplingRate rate, out int w, out int h)
        {
            var cam = canvas.worldCamera ?? Camera.main;

            h = cam.pixelHeight;
            w = cam.pixelWidth;
            if (rate == DesamplingRate.None)
            {
                return;
            }

            float aspect = (float)w / h;

            if (w < h)
            {
                h = Mathf.ClosestPowerOfTwo(h / (int)rate);
                w = Mathf.CeilToInt(h * aspect);
            }
            else
            {
                w = Mathf.ClosestPowerOfTwo(w / (int)rate);
                h = Mathf.CeilToInt(w / aspect);
            }
        }