Search Unity

Question URP how to change RenderFeatures properties/settings at runtime

Discussion in 'Universal Render Pipeline' started by curiouspers, Jun 3, 2020.

  1. curiouspers

    curiouspers

    Joined:
    Aug 7, 2014
    Posts:
    19
    Let's say I made custom Render Feature pass, with outlines, bloom and lut correction, and I want the user/player to be able to change this settings in game to balance performance/quality, how can I do that?

    I searched for methods in UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset and googled a lot, but can't find anything useful.

    To clarify, I'm trying to change any of these settings:
     
    Last edited: Jun 3, 2020
  2. curiouspers

    curiouspers

    Joined:
    Aug 7, 2014
    Posts:
    19
    I think I found what I was looking for, but why is it protected?
    What's the reason, and how do I change something in some RenderFeature if that list is protected, how am I suppose to use it "the right way"?
     
    Last edited: Jun 5, 2020
    laurentlavigne, BOXOPHOBIC and JesOb like this.
  3. curiouspers

    curiouspers

    Joined:
    Aug 7, 2014
    Posts:
    19
    I really need help as I spent almost a week on this, and still can't figure out how to change something like USE_BLOOM value from the screenshot above by user from game settings, not forking URP. Can someone please push me in the right direction?
     
  4. curiouspers

    curiouspers

    Joined:
    Aug 7, 2014
    Posts:
    19
    Turns out I can get access to this list using reflections like this:

    Code (CSharp):
    1. var _rendererFeatures = _pipelineAssetCurrent.scriptableRenderer.GetType()
    2.                     .GetProperty("rendererFeatures", BindingFlags.NonPublic | BindingFlags.Instance)
    3.                     ?.GetValue(_pipelineAssetCurrent.scriptableRenderer, null) as List<ScriptableRendererFeature>;
    If somebody will find this useful, make sure you're executing it only one time on Awake or Init, cause it's quite expensive.
     
    dionen and laurentlavigne like this.
  5. sebasopp

    sebasopp

    Joined:
    Jan 24, 2019
    Posts:
    2
    That worked to get the list. I am trying to change Settings of the URP SSAO RenderFeature. With your code i can enable/disable the feature, but i cant access attributes. For that i think i would need to cast the Feature to
    ScreenSpaceAmbientOcclusionPass but this is not possible ... Sad