void Awake() {
     //Brightness -- make sure the main camera has this script attached!
     toneMappingScript = Camera.main.GetComponent<Tonemapping>();
     if (toneMappingScript != null) toneMappingScript.middleGrey = middleGray;
     else { print("Could not find ToneMappingScript. Make sure it is attached to the Main Camera"); }
     
     //Quality
     qualityLevels = QualitySettings.names;                                      //Check available quality settings and store them in an array;
     currentQualityLevel = QualitySettings.GetQualityLevel();                    //Check the current quality setting and store it in a variable;
     qualityToggles[currentQualityLevel].isOn = true;
 }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        fogDensity = RenderSettings.fogDensity;
        //skydome = GameObject.FindGameObjectWithTag ("SkyDome").GetComponent<Sky> ();
        //skydomeLight = skydome.m_sunIntensity;
        colorCurve = Camera.main.GetComponent<ColorCorrectionCurves> ();
        toneMapper = Camera.main.GetComponent<Tonemapping> ();
        sunShafts = Camera.main.GetComponent<SunShafts> ();

        sunShaftIntens = sunShafts.sunShaftIntensity;
        colorSat = colorCurve.saturation;
        toneExp = toneMapper.exposureAdjustment;
    }
    //public new void OnEnable() {
    //    if(debugLogness)Debug.Log("ColorGrading OnEnable");
    //    UpdateTone(time);
    //    base.OnEnable();
    //}
    private void UpdateTone(float timeIn)
    {
        if (debugLogness) Debug.Log("ColorGrading UpdateTone: time:" + timeIn + " crossFade:" + crossFade + " :" + toneMapping, this);
        if (toneMapping == null) toneMapping = GetComponent<Tonemapping>();
        var crossTo = 0f;
        var crossFade2 = crossFade;
        if (crossFade < 0) {
            crossTo = 30;
            crossFade2 = -crossFade;
        }
        if (exposure != null) toneMapping.exposureAdjustment = Mathf.Lerp(Mathf.Lerp(exposure2.x, exposure2.y, exposure.Evaluate(timeIn).r), crossTo, crossFade2);
        if (exposure != null) toneMapping.Brightness = Mathf.Lerp(brightness2.x, brightness2.y, exposure.Evaluate(timeIn).r);
        //if (exposure != null) toneMapping.Brightness = Mathf.Lerp(Mathf.Lerp(brightness2.x, brightness2.y, exposure.Evaluate(timeIn).r), Mathf.Lerp(brightness2.x, brightness2.y, exposure.Evaluate(timeIn).r)*0.0f, Mathf.Max(0, crossFade*2f - 0.5f));

        if (exposure != null) toneMapping.Contrast = Mathf.Lerp(Mathf.Lerp(contrast2.x, contrast2.y, exposure.Evaluate(timeIn).r), 1f, crossFade);
        if (exposure != null) toneMapping.Saturation = Mathf.Lerp(saturation2.x, saturation2.y, exposure.Evaluate(timeIn).r);
    }
Exemplo n.º 4
0
    public static void CheckToggleSaturationCorrection()
    {
        GameObject obj2 = GameObject.FindWithTag("MainCamera");

        if (obj2 != null)
        {
            if (Input.GetKeyUp(KeyCode.F12))
            {
                isF12KeyDown = false;
            }
            if (!isF12KeyDown && Input.GetKeyDown(KeyCode.F12))
            {
                if (iniHelper == null)
                {
                    iniHelper = new IniHelper(Application.dataPath + "/Managed/new.ini");
                }

                TM_Enable    = (iniHelper.ReadValue("Graphics Enhance", "ToneMapping") == "1") ? true : false;
                SSAO_Enable  = (iniHelper.ReadValue("Graphics Enhance", "SSAO") == "1") ? true : false;
                CE_Enable    = (iniHelper.ReadValue("Graphics Enhance", "ContrastEnhance") == "1") ? true : false;
                CS_Enable    = (iniHelper.ReadValue("Graphics Enhance", "ContrastStretch") == "1") ? true : false;
                Bloom_Enable = (iniHelper.ReadValue("Graphics Enhance", "Bloom") == "1") ? true : false;

                Tonemapping           TM    = obj2.GetComponent <Tonemapping> ();
                SSAOEffect            SSAO  = obj2.GetComponent <SSAOEffect>();
                ContrastEnhance       CE    = obj2.GetComponent <ContrastEnhance> ();
                BloomAndLensFlares    bloom = obj2.GetComponent <BloomAndLensFlares> ();
                ContrastStretchEffect CS    = obj2.GetComponent <ContrastStretchEffect> ();

                QualitySettings.antiAliasing = 4;

                if (CS == null)
                {
                    CS              = obj2.AddComponent <ContrastStretchEffect> ();
                    CS.shaderAdapt  = Shader.Find("Hidden/Contrast Stretch Adaptation");
                    CS.shaderApply  = Shader.Find("Hidden/Contrast Stretch Apply");
                    CS.shaderLum    = Shader.Find("Hidden/Contrast Stretch Luminance");
                    CS.shaderReduce = Shader.Find("Hidden/Contrast Stretch Reduction");
                }

                if (bloom == null)
                {
                    bloom = obj2.AddComponent <BloomAndLensFlares> ();
                    bloom.addBrightStuffOneOneShader = Shader.Find("Hidden/BlendOneOne");
                    bloom.brightPassFilterShader     = Shader.Find("Hidden/BrightPassFilterForBloom");
                    bloom.hollywoodFlaresShader      = Shader.Find("Hidden/MultipassHollywoodFlares");
                    bloom.lensFlareShader            = Shader.Find("Hidden/LensFlareCreate");
                    bloom.screenBlendShader          = Shader.Find("Hidden/Blend");
                    bloom.separableBlurShader        = Shader.Find("Hidden/SeparableBlurPlus");
                    bloom.vignetteShader             = Shader.Find("Hidden/VignetteShader");
                }

                if (TM == null)
                {
                    TM            = obj2.AddComponent <Tonemapping> ();
                    TM.tonemapper = Shader.Find("Hidden/Tonemapper");
                    TM.type       = Tonemapping.TonemapperType.AdaptiveReinhardAutoWhite;
                }
                if (SSAO == null)
                {
                    SSAO = obj2.AddComponent <SSAOEffect>();
                    SSAO.m_SSAOShader        = Shader.Find("Hidden/SSAO");
                    obj2.camera.farClipPlane = 1000;
                }

                FightUIInterface.uiInterface.cheatWindow.Open();
                //Main.actorMgr.SwitchControlActor ();

                if (CE == null)
                {
                    CE = obj2.AddComponent <ContrastEnhance> ();
                    CE.contrastCompositeShader = Shader.Find("Hidden/ContrastComposite");
                    CE.separableBlurShader     = Shader.Find("Hidden/SeparableBlurPlus");
                }

                isF12KeyDown = true;
                if (!SaturationCorrectionFlag)
                {
                    FightUIInterface.ShowPromptText("画面增强打开", 1, 1f);
                    SaturationCorrectionFlag = true;

                    if (TM)
                    {
                        TM.enabled = TM_Enable;
                    }

                    if (SSAO)
                    {
                        SSAO.enabled              = SSAO_Enable;
                        SSAO.m_Radius             = 0.8f;
                        SSAO.m_SampleCount        = SSAOEffect.SSAOSamples.Medium;
                        SSAO.m_OcclusionIntensity = 2.4f;
                        SSAO.m_Downsampling       = 2;
                        SSAO.m_MinZ = 0.8f;
                    }
                    if (CE)
                    {
                        CE.enabled = CE_Enable;
                    }
                    if (bloom)
                    {
                        bloom.enabled = Bloom_Enable;
                    }

                    if (CS)
                    {
                        CS.enabled = CS_Enable;
                    }
                }
                else
                {
                    FightUIInterface.ShowPromptText("画面增强关闭", 1, 1f);
                    SaturationCorrectionFlag = false;
                    //component.enabled = false;
                    if (SSAO)
                    {
                        SSAO.enabled = false;
                    }
                    if (CE)
                    {
                        CE.enabled = false;
                    }
                    if (TM)
                    {
                        TM.enabled = false;
                    }
                    if (bloom)
                    {
                        bloom.enabled = false;
                    }
                    if (CS)
                    {
                        CS.enabled = false;
                    }
                }
                //FightUIInterface.ShowPromptText (SSAO_Enable ? "SSAO ON" : "SSAO OFF");
            }
        }

        //FightUIInterface.ShowPromptText (Application.unityVersion.ToString ());
    }
Exemplo n.º 5
0
        public bool ReadBackBuffer(out ImageResult imageResult)
        {
            imageResult = null;

            if (_cameras == null)
            {
                Debug.LogError("[AmplifyColor] Camera collection is invalid.");
                return(false);
            }

            var camera = _cameras.SelectedCamera;

            if (camera == null)
            {
                Debug.LogError("[AmplifyColor] Selected camera is invalid.");
                return(false);
            }

            AmplifyColorEffect component      = camera.GetComponent <AmplifyColorEffect>();
            Tonemapping        prevTonemapper = Tonemapping.Disabled;
            float   prevExposure         = 1.0f;
            float   prevLinearWhitePoint = 11.2f;
            bool    prevApplyDithering   = false;
            float   prevBlendAmount      = 0.0f;
            Texture prevLUT = null;

            if (component != null)
            {
                prevTonemapper       = component.Tonemapper;
                prevExposure         = component.Exposure;
                prevLinearWhitePoint = component.LinearWhitePoint;
                prevApplyDithering   = component.ApplyDithering;
                prevBlendAmount      = component.BlendAmount;
                prevLUT = component.LutTexture;

                component.Tonemapper       = ToolSettings.Instance.ApplyHDRControl ? component.Tonemapper : Tonemapping.Disabled;
                component.Exposure         = ToolSettings.Instance.ApplyHDRControl ? component.Exposure : 1.0f;
                component.LinearWhitePoint = ToolSettings.Instance.ApplyHDRControl ? component.LinearWhitePoint : 11.2f;
                component.ApplyDithering   = ToolSettings.Instance.ApplyHDRControl ? component.ApplyDithering : false;
                component.BlendAmount      = ToolSettings.Instance.ApplyColorGrading ? component.BlendAmount : 0.0f;
                component.LutTexture       = ToolSettings.Instance.ApplyColorGrading ? component.LutTexture : null;
            }

            var width  = ToolSettings.Instance.Resolution.TargetWidth;
            var height = ToolSettings.Instance.Resolution.TargetHeight;

            //if (ToolSettings.Instance.Resolution.IsGameWindowSize)
            //{
            //    width = Screen.width;
            //    height = Screen.height;
            //}

            var cameratarget = camera.targetTexture;

            var rt = RenderTexture.GetTemporary(width, height, 24, RenderTextureFormat.ARGB32);

            camera.targetTexture = rt;
            camera.Render();
            camera.targetTexture = cameratarget;

            var activert = RenderTexture.active;

            RenderTexture.active = rt;
            var text = new Texture2D(width, height, TextureFormat.ARGB32, false);

            text.ReadPixels(new Rect(0, 0, width, height), 0, 0);
            text.Apply();
            RenderTexture.active = activert;
            var colors = text.GetPixels(0, 0, width, height);

            Texture2D.DestroyImmediate(text);

            var colordata = new Color[width, height];

            for (int i = height - 1; i >= 0; i--)
            {
                for (int j = 0; j < width; j++)
                {
                    colordata[j, (height - 1 - i)]   = colors[i * width + j];
                    colordata[j, (height - 1 - i)].a = 1;
                }
            }

            if (component != null)
            {
                component.Tonemapper       = prevTonemapper;
                component.Exposure         = prevExposure;
                component.LinearWhitePoint = prevLinearWhitePoint;
                component.ApplyDithering   = prevApplyDithering;
                component.BlendAmount      = prevBlendAmount;
                component.LutTexture       = prevLUT;
            }

            imageResult = new ImageResult(colordata);

            return(true);
        }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     tone = GetComponent<Tonemapping>();
 }
 public new void Awake()
 {
     toneMapping = GetComponent<Tonemapping>();
     base.Awake();
 }
 void Start()
 {
     Bloom       bloomEffect       = Camera.main.GetComponent <Bloom>();
     Blur        blurEffect        = Camera.main.GetComponent <Blur>();
     Tonemapping toneMappingEffect = Camera.main.GetComponent <Tonemapping>();
 }