示例#1
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);
        }
示例#2
0
        public override void Initialize()
        {
            base.Initialize();

            urpAsset = GraphicsSettings.renderPipelineAsset as UniversalRenderPipelineAsset;

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

            IList features = featuresField.GetValue(forwardRenderer) as IList;

            ssaoFeature = features[0] as ScriptableRendererFeature;

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

            settings = settingsField.GetValue(ssaoFeature);

            sourceField     = settings.GetType().GetField("Source", BindingFlags.NonPublic | BindingFlags.Instance);
            downsampleField = settings.GetType().GetField("Downsample", BindingFlags.NonPublic | BindingFlags.Instance);
        }
示例#3
0
        public void AddRendererFeatureIfNotPresent(ScriptableRendererFeature feature)
        {
            var rendererFeatures = GetScriptableRendererFeatures();

            if (rendererFeatures != null && !rendererFeatures.Exists(element => element.GetType() == feature.GetType()))
            {
                rendererFeatures.Add(feature);
            }
        }