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

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 :slight_smile:

Antialiasing in in the camera settings since HDRP 5.3.1, not in post process or somethingā€¦ You can change antialiasing like this:

using UnityEngine.Experimental.Rendering.HDPipeline;
    public void Aliasing(){


        switch(antiblabla){

        case 0:

            mainCam.GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.None;
            antiText.text = "Off";

            break;

        case 1:
    
            mainCam.GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.FastApproximateAntialiasing;
            antiText.text = "FXAA";

            break;

        case 2:

            mainCam.GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing;
            antiText.text = "TAA";

            break;
        }

    }
5 Likes

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.

2 Likes

I see, thank you for the replies :).

@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:

        private IEnumerator UpdateQuality()
        {
            if (Application.isEditor) yield break;

            var hdRenderPipelineAsset = GetRpQualityAsset();

            if (GraphicsSettings.renderPipelineAsset == hdRenderPipelineAsset) yield break;

            Logger.Log("Changing quality to " + GraphicsQuality);

            GraphicsSettings.renderPipelineAsset = null;
            yield return null;

            switch (GraphicsQuality)
            {
                case ProgramEnums.GraphicsQuality.High:
                    QualitySettings.SetQualityLevel(2);
                    break;
                case ProgramEnums.GraphicsQuality.Medium:
                    QualitySettings.SetQualityLevel(1);
                    break;
                case ProgramEnums.GraphicsQuality.Low:
                    QualitySettings.SetQualityLevel(0);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            yield return null;

            GraphicsSettings.renderPipelineAsset = hdRenderPipelineAsset;

            yield return new WaitForSeconds(0.8f);
        }

        private static HDRenderPipelineAsset GetRpQualityAsset()
        {
            HDRenderPipelineAsset hdRenderPipelineAsset;
            switch (Instance.GraphicsQuality)
            {
                case ProgramEnums.GraphicsQuality.High:
                    hdRenderPipelineAsset = Instance.HighQualityAsset;
                    break;
                case ProgramEnums.GraphicsQuality.Medium:
                    hdRenderPipelineAsset = Instance.MediumQualityAsset;
                    break;
                case ProgramEnums.GraphicsQuality.Low:
                    hdRenderPipelineAsset = Instance.LowQualityAsset;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return hdRenderPipelineAsset;
        }

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?

Im getting the same black screen when i try to change the resolution, iā€™m doing the same thing an it workis.

            Instance.PostProcessingVolume.enabled = false;
            Instance.SceneVolume.enabled = false;

            switch (screenMode)
            {
                case ProgramEnums.ScreenMode.FullScreen:
                    var fsRes = Screen.resolutions;
                    var highRes = fsRes[fsRes.Length - 1];
                    Screen.SetResolution(highRes.width, highRes.height, FullScreenMode.ExclusiveFullScreen);
                    break;
                case ProgramEnums.ScreenMode.Windowed:
                    var res = GetHighestResolution(2);
                    if (res == null) break;
                    Screen.SetResolution(res.Value.width, res.Value.height, FullScreenMode.Windowed);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(screenMode), screenMode, null);
            }

            var hdRenderPipelineAsset = GetRpQualityAsset();

            GraphicsSettings.renderPipelineAsset = null;
            yield return null;
            GraphicsSettings.renderPipelineAsset = hdRenderPipelineAsset;

            yield return null;
            Instance.PostProcessingVolume.enabled = true;
            Instance.SceneVolume.enabled = true;

@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?

I would love to know the same thing about changing the graphics quality with HDRP. Whatā€™s the workflow for this now?

Hi, you can find information about how to do configuration for HDRP here: Finding your way in HDRP 7.2.0 - Getting started - Settings - New feature
an HDRP asset can be swap at runtime, and this is how you handle multiple configuration.

1 Like

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?

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

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.

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

1 Like

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?

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.

1 Like

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

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.

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.

using UnityEngine.Rendering.HighDefinition;

//with this script on the camera:

            GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing;
            GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.FastApproximateAntialiasing;
            GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.None;
            GetComponent<HDAdditionalCameraData>().antialiasing = HDAdditionalCameraData.AntialiasingMode.SubpixelMorphologicalAntiAliasing;