Esempio n. 1
0
        public override void UpdateSetting(object newValue)
        {
            int value = (int)newValue;

            switch (value)
            {
            case (int)QualitySettings.SSAOQualityLevel.OFF:
                ssaoFeature.SetActive(false);
                break;

            case (int)QualitySettings.SSAOQualityLevel.LOW:
                ssaoFeature.SetActive(true);
                sourceField.SetValue(settings, 0);
                downsampleField.SetValue(settings, true);
                break;

            case (int)QualitySettings.SSAOQualityLevel.MID:
                ssaoFeature.SetActive(true);
                sourceField.SetValue(settings, 1);
                downsampleField.SetValue(settings, true);
                break;

            case (int)QualitySettings.SSAOQualityLevel.HIGH:
                ssaoFeature.SetActive(true);
                sourceField.SetValue(settings, 1);
                downsampleField.SetValue(settings, false);
                break;
            }

            currentQualitySetting.ssaoQuality = (QualitySettings.SSAOQualityLevel)value;
        }
Esempio n. 2
0
        public static void SetSSAOActive(bool active)
        {
            var urpAsset = GraphicsSettings.renderPipelineAsset as UniversalRenderPipelineAsset;

            ScriptableRenderer forwardRenderer = urpAsset.GetRenderer(0);
            FieldInfo          featuresField   = typeof(ScriptableRenderer).GetField("m_RendererFeatures", BindingFlags.NonPublic | BindingFlags.Instance);

            IList features = featuresField.GetValue(forwardRenderer) as IList;
            ScriptableRendererFeature ssaoFeature = features[0] as ScriptableRendererFeature;

            if (!active)
            {
                ssaoFeature.SetActive(false);
                return;
            }

            FieldInfo settingsField = ssaoFeature.GetType().GetField("m_Settings", BindingFlags.NonPublic | BindingFlags.Instance);
            object    settings      = settingsField.GetValue(ssaoFeature);

            FieldInfo sourceField     = settings.GetType().GetField("Source", BindingFlags.NonPublic | BindingFlags.Instance);
            FieldInfo downsampleField = settings.GetType().GetField("Downsample", BindingFlags.NonPublic | BindingFlags.Instance);

            ssaoFeature.SetActive(true);
            sourceField.SetValue(settings, 1);
            downsampleField.SetValue(settings, false);
        }