Example #1
0
        public void Start()
        {
            try
            {
                _camera     = Camera.main;
                _zoomButton = GameObject.Find("ZoomButton").GetComponent <UIMultiStateButton>();
                _mainPanel  = GameObject.Find("RenderItMainPanel").GetComponent <MainPanel>();

                _postProcessingBehaviour = _camera.gameObject.GetComponent <PostProcessingBehaviour>();
                if (_postProcessingBehaviour == null)
                {
                    _postProcessingBehaviour         = _camera.gameObject.AddComponent <PostProcessingBehaviour>();
                    _postProcessingBehaviour.profile = ScriptableObject.CreateInstance <PostProcessingProfile>();
                }
                _postProcessingBehaviour.enabled = true;

                _antialiasingModel     = new AntialiasingModel();
                _ambientOcclusionModel = new AmbientOcclusionModel();
                _bloomModel            = new BloomModel();
                _colorGradingModel     = new ColorGradingModel();

                _renderItAtlas = LoadResources();
                CreateUI();
            }
            catch (Exception e)
            {
                Debug.Log("[Render It!] ModManager:Start -> Exception: " + e.Message);
            }
        }
    IEnumerator save_AmbientOcclusion()
    {
        yield return(new WaitForEndOfFrame());


        for (int a = 0; a < pb.Length; a++)
        {
            AmbientOcclusionModel m = pb [a].profile.ambientOcclusion;

            if (ambientOcclusion.value == 0)
            {
                m.enabled = false;
                PlayerPrefs.SetString("AO", "Off");
            }

            if (ambientOcclusion.value == 1)
            {
                m.enabled = true;

                AmbientOcclusionModel.Settings s = pb [a].profile.ambientOcclusion.settings;
                s.sampleCount = AmbientOcclusionModel.SampleCount.Lowest;
                m.settings    = s;
                PlayerPrefs.SetString("AO", "Lowest");
            }
            if (ambientOcclusion.value == 2)
            {
                m.enabled = true;

                AmbientOcclusionModel.Settings s = pb [a].profile.ambientOcclusion.settings;
                s.sampleCount = AmbientOcclusionModel.SampleCount.Low;
                m.settings    = s;
                PlayerPrefs.SetString("AO", "Low");
            }
            if (ambientOcclusion.value == 3)
            {
                m.enabled = true;

                AmbientOcclusionModel.Settings s = pb [a].profile.ambientOcclusion.settings;
                s.sampleCount = AmbientOcclusionModel.SampleCount.Medium;
                m.settings    = s;
                PlayerPrefs.SetString("AO", "Medium");
            }
            if (ambientOcclusion.value == 4)
            {
                m.enabled = true;

                AmbientOcclusionModel.Settings s = pb [a].profile.ambientOcclusion.settings;
                s.sampleCount = AmbientOcclusionModel.SampleCount.High;
                m.settings    = s;
                PlayerPrefs.SetString("AO", "High");
            }
        }
    }
    public override void OnEnable()
    {
        base.OnEnable();
        ambientOcclusionModel = GetPostEffectModel <AmbientOcclusionModel>();
        intensity             = ambientOcclusionModel.intensity;
        radius       = ambientOcclusionModel.radius;
        downsampling = ambientOcclusionModel.downsampling;
        sampleCount  = ambientOcclusionModel.sampleCount;
        width        = ambientOcclusionModel.width;
        height       = ambientOcclusionModel.height;
        isHdr        = ambientOcclusionModel.isHdr;

        k_BlitShader = ambientOcclusionModel.k_BlitShader;
        k_Shader     = ambientOcclusionModel.k_Shader;
    }
    public void OnEnable()
    {
        rendererCamera       = Camera.main;
        isSupported          = true;
        m_CommandBuffers     = new Dictionary <Type, KeyValuePair <CameraEvent, CommandBuffer> >();
        renderTextureFactory = new RenderTextureFactory();
        m_Camera             = gameObject.GetComponent <Camera>();
        PostEffectModelContainer postEffectModel = Resources.Load("PostEffectModelContainer") as PostEffectModelContainer;

        blurEffect = new BlurEffect();
        blurEffect.renderTextureFactory = renderTextureFactory;
        blurEffectModel = postEffectModel.blurEffectModel;
        blurEffect.SetPostEffectModel <BlurEffectModel>(blurEffectModel);

        oldFilmEffect = new OldFilmEffect();
        oldFilmEffect.renderTextureFactory = renderTextureFactory;
        oldFilmEffectModel = postEffectModel.oldFilmEffectModel;
        oldFilmEffect.SetPostEffectModel <OldFilmEffectModel>(oldFilmEffectModel);

        nightVisionEffect = new NightVisionEffect();
        nightVisionEffect.renderTextureFactory = renderTextureFactory;
        nightVisionEffectModel = postEffectModel.nightVisionEffectModel;
        nightVisionEffect.SetPostEffectModel <NightVisionEffectModel>(nightVisionEffectModel);

        ambientOcclusionEffect = new AmbientOcclusionEffect();
        ambientOcclusionEffect.renderTextureFactory = renderTextureFactory;
        ambientOcclusionModel = postEffectModel.ambientOcclusionModel;
        ambientOcclusionEffect.SetPostEffectModel(ambientOcclusionModel);

        postEffectList.Add(blurEffect);
        postEffectList.Add(oldFilmEffect);
        postEffectList.Add(nightVisionEffect);
        postEffectList.Add(ambientOcclusionEffect);

        for (int i = 0; i < postEffectList.Count; i++)
        {
            BasePostEffect postEffect = postEffectList[i];
            postEffect.OnEnable();
        }
        CheckResources();
    }
 public AmbientOcclusionPanel(AmbientOcclusionModel model)
 {
     m_model = model;
 }