Ejemplo n.º 1
0
    private static Vector4 GenerateGaussianBlurKernel(POSTFX_GUASSIAN_BLUR_MODE mode, float sigma)
    {
        float lowEndFake = 1.0f;

        if (GameFlowControlManager.Instance == null || GameFlowControlManager.Instance.m_StateMachine == null)
        {
        }
        else
        {
            PerformanceInfo.ePOSTFX_QUALITY fxquality = PerformanceManager.Instance.PerformanceInfo.EnvironmentInfoForScene(GameFlowControlManager.Instance.m_StateMachine.ActiveStateName).postFXQuality;
            if (fxquality == PerformanceInfo.ePOSTFX_QUALITY.Medium)
            {
                lowEndFake *= 1.8f;
            }
        }

        sigma *= lowEndFake;
        // any questions about the fake values in rendersettings,find hank.



        Vector4 res = Vector4.zero;

        if (mode == POSTFX_GUASSIAN_BLUR_MODE.TAP_3 || mode == POSTFX_GUASSIAN_BLUR_MODE.TAP_3_RAMP)
        {
            res.x = Mathf.Exp(-0.0f / (2.0f * sigma * sigma)) / (2.0f * Mathf.PI * sigma * sigma);
            res.y = Mathf.Exp(-1.0f / (2.0f * sigma * sigma)) / (2.0f * Mathf.PI * sigma * sigma);
            float t = res.y + res.x + res.y;
            res /= t;
        }
        else
        {
            res.x = Mathf.Exp(-0.0f / (2.0f * sigma * sigma)) / (2.0f * Mathf.PI * sigma * sigma);
            res.y = Mathf.Exp(-1.0f / (2.0f * sigma * sigma)) / (2.0f * Mathf.PI * sigma * sigma);
            res.z = Mathf.Exp(-4.0f / (2.0f * sigma * sigma)) / (2.0f * Mathf.PI * sigma * sigma);
            res.w = Mathf.Exp(-9.0f / (2.0f * sigma * sigma)) / (2.0f * Mathf.PI * sigma * sigma);
            float t = res.w + res.z + res.y + res.x + res.y + res.z + res.w;
            res /= t;
        }
        return(res);
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        PerformanceInfo.ePOSTFX_QUALITY postfxquality = PerformanceInfo.ePOSTFX_QUALITY.Off;
        if (!(GameFlowControlManager.Instance == null || GameFlowControlManager.Instance.m_StateMachine == null))
        {
            postfxquality = PerformanceManager.Instance.PerformanceInfo.EnvironmentInfoForScene(GameFlowControlManager.Instance.m_StateMachine.ActiveStateName).postFXQuality;
        }

        List <PerformanceInfo.ePOSTFX> fxtypes = new List <PerformanceInfo.ePOSTFX>(3);

        if ((fxs & PerformanceInfo.ePOSTFX.Bloom) == PerformanceInfo.ePOSTFX.Bloom)
        {
            fxtypes.Add(PerformanceInfo.ePOSTFX.Bloom);
        }
        if ((fxs & PerformanceInfo.ePOSTFX.Vignette) == PerformanceInfo.ePOSTFX.Vignette)
        {
            fxtypes.Add(PerformanceInfo.ePOSTFX.Vignette);
        }
        if ((fxs & PerformanceInfo.ePOSTFX.Vignette2) == PerformanceInfo.ePOSTFX.Vignette2)
        {
            fxtypes.Add(PerformanceInfo.ePOSTFX.Vignette2);
        }
        if ((fxs & PerformanceInfo.ePOSTFX.FakeVignette) == PerformanceInfo.ePOSTFX.FakeVignette)
        {
            fxtypes.Add(PerformanceInfo.ePOSTFX.FakeVignette);
        }
        if ((fxs & PerformanceInfo.ePOSTFX.ColorGrade) == PerformanceInfo.ePOSTFX.ColorGrade)
        {
            fxtypes.Add(PerformanceInfo.ePOSTFX.ColorGrade);
        }
        if ((fxs & PerformanceInfo.ePOSTFX.ToneMap) == PerformanceInfo.ePOSTFX.ToneMap)
        {
            fxtypes.Add(PerformanceInfo.ePOSTFX.ToneMap);
        }
        if ((fxs & PerformanceInfo.ePOSTFX.Warp) == PerformanceInfo.ePOSTFX.Warp)
        {
            fxtypes.Add(PerformanceInfo.ePOSTFX.Warp);
        }
        if ((fxs & PerformanceInfo.ePOSTFX.RadialBlur) == PerformanceInfo.ePOSTFX.RadialBlur)
        {
            fxtypes.Add(PerformanceInfo.ePOSTFX.RadialBlur);
        }

        for (int i = fxtypes.Count - 1; i >= 0; --i)
        {
            if (System.Array.IndexOf(PerformanceManager.Instance.CurrentEnvironmentInfo.postFX, fxtypes[i]) < 0)
            {
                fxtypes.RemoveAt(i);
            }
        }

        if (fxtypes.Contains(PerformanceInfo.ePOSTFX.FakeVignette))
        {
            ShowFakefx();
            fxtypes.Remove(PerformanceInfo.ePOSTFX.FakeVignette);
        }

        if (postfxquality == PerformanceInfo.ePOSTFX_QUALITY.Low)
        {
            return;
        }

        PostFXManager.Instance.Init(Camera.main, postfxquality, fxtypes.ToArray());
    }
Ejemplo n.º 3
0
    public void Init(Camera camera, PerformanceInfo.ePOSTFX_QUALITY quality, PerformanceInfo.ePOSTFX[] newPostFX)
    {
        if (camera == null)
        {
            EB.Debug.LogWarning("Couldn't init PostFX as we don't have a camera");
            return;
        }

        if (quality != Quality)
        {
            //quality mode has changed, destroy any previously active postfx
            foreach (PerformanceInfo.ePOSTFX postfx in System.Enum.GetValues(typeof(PerformanceInfo.ePOSTFX)))
            {
                if (IsActive(postfx))
                {
                    DestroyEffect(postfx);
                }
            }
        }

        Quality = quality;

        var trigger = camera.gameObject.GetComponent <PostFXManagerTrigger>();

        if ((Quality == PerformanceInfo.ePOSTFX_QUALITY.Off) || (newPostFX.Length == 0))
        {
            if (trigger != null)
            {
#if EBG_POSTFX_BLOOM
                DestroyEntity(trigger);
#endif
            }

            foreach (PerformanceInfo.ePOSTFX postfx in System.Enum.GetValues(typeof(PerformanceInfo.ePOSTFX)))
            {
                //destroy any previously active postfx that are no longer active
                if (IsActive(postfx))
                {
                    DestroyEffect(postfx);
                }
            }
            return;
        }
        else if (trigger == null)
        {
            //create the trigger if it doesn't exist
            camera.gameObject.AddComponent <PostFXManagerTrigger>();
        }

        foreach (PerformanceInfo.ePOSTFX postfx in System.Enum.GetValues(typeof(PerformanceInfo.ePOSTFX)))
        {
            //destroy any previously active postfx that are no longer active
            if (IsActive(postfx) && (System.Array.IndexOf(newPostFX, postfx) == -1))
            {
                DestroyEffect(postfx);
            }
            //init any active post fx that weren't previously active
            if (!IsActive(postfx) && (System.Array.IndexOf(newPostFX, postfx) != -1))
            {
                InitEffect(postfx, camera);
            }
        }

        _inited = true;
    }