Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Is it possible to change the quality of the HDpipeline during runtime?

Discussion in 'Graphics Experimental Previews' started by DanielGuirelli, Feb 18, 2019.

  1. DanielGuirelli

    DanielGuirelli

    Joined:
    May 29, 2018
    Posts:
    5
    I was wondering if it is possible to change the quality of the HDPipeline via script during runtime.

    I know you can still change the quality of the textures using SetQualityLevel, but can you do the same with everything else in the HDPipeline? And also, can you change the quality settings of the Post Processing for things like the anti-aliasing during runtime?

    Thank you :)
     
  2. id0

    id0

    Joined:
    Nov 23, 2012
    Posts:
    455
    Antialiasing in in the camera settings since HDRP 5.3.1, not in post process or something... You can change antialiasing like this:

    Code (CSharp):
    1. using UnityEngine.Experimental.Rendering.HDPipeline;
    Code (CSharp):
    1.     public void Aliasing(){
    2.  
    3.  
    4.         switch(antiblabla){
    5.  
    6.         case 0:
    7.  
    8.             mainCam.GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.None;
    9.             antiText.text = "Off";
    10.  
    11.             break;
    12.  
    13.         case 1:
    14.    
    15.             mainCam.GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.FastApproximateAntialiasing;
    16.             antiText.text = "FXAA";
    17.  
    18.             break;
    19.  
    20.         case 2:
    21.  
    22.             mainCam.GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing;
    23.             antiText.text = "TAA";
    24.  
    25.             break;
    26.         }
    27.  
    28.     }
     
    Last edited: Feb 18, 2019
  3. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    936
    Hi,

    HDRP asset where all the settings happen can be change at runtime, but it may or not work depends on what is change.

    Anything that is a "supported" features can't be tweak at few exception. We use that to remove shader variants, so for example if shadowmask are removed, you can't enable them by swapping HDRP asset at runtime.

    However some other stuff like MSAA or high quality SSS for example can be change at runtime but require to recreate the HDRenderPipeline. Overall it is best to rely on FrameSettings for "Quality" control than HDRP asset change.

    We plan in the future to support low, medium, high quality HDRP asset that can be bundled with corresponding shaders, but this work haven't start yet. Regarding Postprocess. In V3 integrated in 2019.1 everything is controllable at runtime, so the quality can be dynamic.
     
    optimise and DanielGuirelli like this.
  4. DanielGuirelli

    DanielGuirelli

    Joined:
    May 29, 2018
    Posts:
    5
    I see, thank you for the replies :).
     
  5. maikramer

    maikramer

    Joined:
    Jun 2, 2017
    Posts:
    12
    @SebLagarde
    Hi, i'm developing Materialize, originally from Bounding Box Software,
    I'm having inconsistent results changing the graphics configurations.
    What i'm doing at the moment and is working is this:

    Code (CSharp):
    1.         private IEnumerator UpdateQuality()
    2.         {
    3.             if (Application.isEditor) yield break;
    4.  
    5.             var hdRenderPipelineAsset = GetRpQualityAsset();
    6.  
    7.             if (GraphicsSettings.renderPipelineAsset == hdRenderPipelineAsset) yield break;
    8.  
    9.             Logger.Log("Changing quality to " + GraphicsQuality);
    10.  
    11.             GraphicsSettings.renderPipelineAsset = null;
    12.             yield return null;
    13.  
    14.             switch (GraphicsQuality)
    15.             {
    16.                 case ProgramEnums.GraphicsQuality.High:
    17.                     QualitySettings.SetQualityLevel(2);
    18.                     break;
    19.                 case ProgramEnums.GraphicsQuality.Medium:
    20.                     QualitySettings.SetQualityLevel(1);
    21.                     break;
    22.                 case ProgramEnums.GraphicsQuality.Low:
    23.                     QualitySettings.SetQualityLevel(0);
    24.                     break;
    25.                 default:
    26.                     throw new ArgumentOutOfRangeException();
    27.             }
    28.  
    29.             yield return null;
    30.  
    31.             GraphicsSettings.renderPipelineAsset = hdRenderPipelineAsset;
    32.  
    33.             yield return new WaitForSeconds(0.8f);
    34.         }
    35.  
    36.         private static HDRenderPipelineAsset GetRpQualityAsset()
    37.         {
    38.             HDRenderPipelineAsset hdRenderPipelineAsset;
    39.             switch (Instance.GraphicsQuality)
    40.             {
    41.                 case ProgramEnums.GraphicsQuality.High:
    42.                     hdRenderPipelineAsset = Instance.HighQualityAsset;
    43.                     break;
    44.                 case ProgramEnums.GraphicsQuality.Medium:
    45.                     hdRenderPipelineAsset = Instance.MediumQualityAsset;
    46.                     break;
    47.                 case ProgramEnums.GraphicsQuality.Low:
    48.                     hdRenderPipelineAsset = Instance.LowQualityAsset;
    49.                     break;
    50.                 default:
    51.                     throw new ArgumentOutOfRangeException();
    52.             }
    53.  
    54.             return hdRenderPipelineAsset;
    55.         }
    If i just change the pipeline asset, it breaks the render and camera gets black with lots of errors.
    If i change to null, then wait a frame, then put the new one, it works, almost always, but in some computers its causing troubles.

    My question, can you tell me the best way to do it?
    When you say change the asset you say modify or change like i'm doing?
     
  6. maikramer

    maikramer

    Joined:
    Jun 2, 2017
    Posts:
    12
    Im getting the same black screen when i try to change the resolution, i'm doing the same thing an it workis.
    Code (CSharp):
    1.             Instance.PostProcessingVolume.enabled = false;
    2.             Instance.SceneVolume.enabled = false;
    3.  
    4.             switch (screenMode)
    5.             {
    6.                 case ProgramEnums.ScreenMode.FullScreen:
    7.                     var fsRes = Screen.resolutions;
    8.                     var highRes = fsRes[fsRes.Length - 1];
    9.                     Screen.SetResolution(highRes.width, highRes.height, FullScreenMode.ExclusiveFullScreen);
    10.                     break;
    11.                 case ProgramEnums.ScreenMode.Windowed:
    12.                     var res = GetHighestResolution(2);
    13.                     if (res == null) break;
    14.                     Screen.SetResolution(res.Value.width, res.Value.height, FullScreenMode.Windowed);
    15.                     break;
    16.                 default:
    17.                     throw new ArgumentOutOfRangeException(nameof(screenMode), screenMode, null);
    18.             }
    19.  
    20.             var hdRenderPipelineAsset = GetRpQualityAsset();
    21.  
    22.             GraphicsSettings.renderPipelineAsset = null;
    23.             yield return null;
    24.             GraphicsSettings.renderPipelineAsset = hdRenderPipelineAsset;
    25.  
    26.             yield return null;
    27.             Instance.PostProcessingVolume.enabled = true;
    28.             Instance.SceneVolume.enabled = true;
     
  7. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,215
    @SebLagarde Could we get an update on the issue with
    QualitySettings.SetQualityLevel(q, true);
    please? Calling this under the HDRP 7.1.7 (as well as under 5.16, so I presume everything in between) just turns the screen black. I can sometimes get it back to rendering by disabling and reenabling all volumes in the scene. But what's happening here when we call QualitySettings.SetQualityLevel()? Should we not be calling this under HDRP? Is there another wat to set quality that does the right things with respect to HDRP?
     
  8. Liderangel

    Liderangel

    Joined:
    Jul 8, 2018
    Posts:
    101


    I would love to know the same thing about changing the graphics quality with HDRP. What's the workflow for this now?
     
  9. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    936
    Liderangel likes this.
  10. damian1994

    damian1994

    Joined:
    Jul 7, 2019
    Posts:
    9
    Hi I have a question ... is there a way to lower the quality to the fog or would just lowering the quality of the shadows lower the quality of the fog?
     
  11. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    In HDRP 10 for Unity 2020.2, they added the ability to lower the Fog quality in the advanced settings for the Fog. Not sure about a backport to HDRP 9 for 2020.1 but it's there for HDRP 10
     
  12. freso

    freso

    Joined:
    Mar 19, 2013
    Posts:
    73
    Really? Create an asset per config diff?
    So if I want to have configurable MSAA and render scale, I would just have to create 4 assets for MSAA setting * predefined number of assets for render scale, let's say 4. 16 assets. Let's add shadows on/off. 32 assets.
     
  13. damian1994

    damian1994

    Joined:
    Jul 7, 2019
    Posts:
    9
    [QUOTE = "Grimreaper358, publicación: 6274661, miembro: 246576"] En HDRP 10 para Unity 2020.2, agregaron la capacidad de reducir la calidad de la niebla en la configuración avanzada de la niebla. No estoy seguro de un backport a HDRP 9 para 2020.1 pero está disponible para HDRP 10 [/ QUOTE]
    ok perfect ... should I wait for version 2020.2 which will be out next year? and
    What do you mean by HDRP 9 and 10?
    IS THE HDRP 10 FOR THE 2020.2 VERTION?
     
  14. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    Unity 2020.2 will be released in a few months.
    The 2020 LTS will be released sometime next year.

    Every Version of Unity Has a version of HDRP and URP that it works with.

    2019.2 - HDRP 6
    2019.3 - HDRP 7
    2020.1 - HDRP 9 (8 got Skipped because there were editor changes needed to move forward)
    2020.2 - HDRP 10

    The same goes for URP and Shader Graph
     
    damian1994 likes this.
  15. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,363
    So do we have this low, medium, high yet? It is so painful trying to find out how to setup quality levels in HDRP (any new pipeline?) at runtime.
    It is a basic feature of PC games that they have lots of graphics options so why is it so hard to change them at runtime with HDRP?
     
  16. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I'm pretty certain that you could swap different quality HDRP assets as long as it has existed. Same with most of the HDRP settings. What is missing (?) is a way to communicate to shaders / shader graphs that your specific SRP asset wants to use variant x from the shader automatically but even this you can implement other ways today if you want to.

    As for Low, Medium, High HDRP asset presets, you can do this by just putting different HDRP asset to Quality Settings today, you can put a different HDRP asset for each of your quality tiers. New HDRP 10 template scene (available on recent 2020.2 betas and above) also uses this type of setup out of the box.
     
    andyz likes this.
  17. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,363
    I tried to just activate/deactivate global volumes for 'levels' but it is dodgy as you can not have say shadows in one and not in another, u end up having a shadows with 0 distance to turn off!
    (HDRP can run on very low hardware with right settings!)

    2020.2 looks like a big step forward for HDRP
     
  18. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I can slim HDRP by huge margin on my high end rig, making it run like only 30% of the cost I'd get on the default settings. But unfortunately it doesn't quite scale low enough still for truly weaker hardware as HDRP rendering itself has some overhead you simply can't get rid of even if you dropped every feat on HDRP asset and frame settings. Even if you see big gains on system x, I'd recommend always to also test on your targeted min spec gear as well.

    If you really want to target weak PC's today with Unity, URP and built-in renderers are the only practical choices as HDRP can't scale down even closely as much like these two can.
     
  19. GeniusKoala

    GeniusKoala

    Joined:
    Oct 13, 2017
    Posts:
    97
    Hi everyone, what is the way to implement SSAA in HDRP ? HDRP asset has a dynamic resolution field but it is clamped to 100%. I would like to multiply it by 2 or 4 to get rid of aliasing. URP Asset has a render scale field (it can go to 2) but HDRP has none if I am not wrong.
     
  20. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
    Code (CSharp):
    1. using UnityEngine.Rendering.HighDefinition;
    2.  
    3. //with this script on the camera:
    4.  
    5.             GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing;
    6.             GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.FastApproximateAntialiasing;
    7.             GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.None;
    8.             GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.SubpixelMorphologicalAntiAliasing;
    9.  
     
    Last edited: Nov 7, 2021