Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Can any/all HDRenderPipelineAsset values be changed at runtime?

Discussion in 'Graphics Experimental Previews' started by dgoyette, Apr 2, 2019.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I'd just test this out, but I'm having trouble figuring out how to go about accessing some of the sections of the HDRenderPipelineAsset. I'm curious whether these settings are designed to be changed at runtime, such as via options exposed to the player? For example, is it reasonable to allow the player to choose how much Shadow resolution they want, via a dropdown, letting them adjust the settings to their computer's capabilities?

    If so, does anyone have an example of the proper way to access and change these values? I'm also not sure whether changes to these files at runtime would persist the next time the player starts up the game.

    Thanks.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I dug a bit more into this, and it seems straightforward (HDRP 4.10 as I write this). In the simplest case, you could create a public property of type 'HDRenderPipelineAsset' on some script, assign your pipeline settings asset it, and then modify the values of the HDRenderPipelineAsset at runtime. That will immediately trigger the graphics changes, just like it does in the editor.

    The downside is that the asset is a scriptable object, so runtime changes "stick" (at least in the Editor) when exiting play mode, which you might not want. So, one approach would be to copy the asset first. For example, the following code makes a copy of the existing settings, modifies a value, and reassigns the settings:

    Code (CSharp):
    1. var pipelineAsset = Instantiate(GraphicsSettings.renderPipelineAsset) as HDRenderPipelineAsset;
    2. pipelineAsset.renderPipelineSettings.hdShadowInitParams.maxShadowRequests = pipelineAsset.renderPipelineSettings.hdShadowInitParams.maxShadowRequests == 128 ? 1 : 128;
    3. GraphicsSettings.renderPipelineAsset = pipelineAsset;
    This will cause the shadow count to change at runtime, but the change will be transient; it won't be reflected in your original HD Render Pipeline asset.

    Anyone please correct me if this isn't a good approach to changing graphics settings at runtime.
     
  3. remi_unity163

    remi_unity163

    Unity Technologies

    Joined:
    Jun 19, 2018
    Posts:
    16
    Hi,

    We currently not support change at runtime on HDRenderPipelineAsset. Changing graphics quality settings at runtime (for instance: changing shadow quality option in menu) is something we are looking into.

    Main issue you can encounter at the moment with changing HDRenderPipelineAsset at runtime is that you could not be able to recompile. Which is required currently for stripped feature and shader variant recompilation. So you will not be able to see your change or even enter in an unstable configuration.

    So while your approach may works for a HDRenderPipelineAsset settings, it could not work for several others.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    Ah, interesting. So far I've wired up a handful of HDRP settings to my graphics options, which I'm setting at runtime, and it's seemed to work so far. But I'll hopefully have some idea of what's going on if this all breaks at some point.
     
  5. garryjnewman

    garryjnewman

    Joined:
    Sep 11, 2015
    Posts:
    33
    Bumping this. It's something I feel is quite important to us too. While it's great to be able to turn features off completely, per camera, we have a varied user base on the PC who like to be able to tweak every setting they can. At a minimum we'd need to provide "good, medium, low" setting groups.
     
  6. fredericv

    fredericv

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    8
    Hi, FYI, We are currently working on providing configurable quality settings for HDRP.

    We intent to have settings configurable per platform and tiers. Also, in a configuration (platform + tier) we are looking to include levels (low, medium, high, ultra) so you can have objects using different level for the same configuration.

    The topic is quite complicated to make this properly configurable and stable, but we will provide the features step by step.
     
  7. garryjnewman

    garryjnewman

    Joined:
    Sep 11, 2015
    Posts:
    33
    Perfect! It's quite hard to know the current state of things. I find posts that are a couple of months old that say things are coming - I'm not sure whether they're done, whether they've been abandoned etc.

    It'd be useful to have a list of things that are done, being worked on, are coming, to sync everyone on where everything is currently.
     
    manbearpigman likes this.
  8. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Besides the upcoming quality setting thing, this was merged to master at the end of April: https://github.com/Unity-Technologies/ScriptableRenderPipeline/pull/3473:

    "The variant stripper was stripping shaders based only on the HDRP asset assigned in the graphic settings.
    If the user had code to switch to other HDRP assets that were either references in the scenes/prefabs or loaded from Resources folders, it would ignore them, and thus, not compile needed shaders.

    Now instead the stripper will search for :

    • The HDRP asset assigned in the graphic settings
    • Any HDRP asset detected as dependency of the scenes added and enabled in the build settings.
    • Any HDRP asset in Resource folders."
    So it appears that you can get away with multiple HDRP assets on the recent or at least upcoming versions now.

    And as for the quality settings, this is the PR for it (just got merged to master): https://github.com/Unity-Technologies/ScriptableRenderPipeline/pull/3841
     
    Last edited: Jun 18, 2019
  9. oobartez

    oobartez

    Joined:
    Oct 12, 2016
    Posts:
    167
    @fredericv Has there been any progress on allowing runtime changes to quality settings? A great example is UniversalRenderPipelineAsset.renderScale. That option does not make much sense as a hardcoded value per quality level. We would like to expose it to our players as a slider in game settings.

    How can we do that?
     
    Last edited: Jul 31, 2021
    baggyg and Bastienre4 like this.
  10. Bastienre4

    Bastienre4

    Joined:
    Jul 8, 2014
    Posts:
    191
    I'm also interested :)
     
  11. Weendie-Games

    Weendie-Games

    Joined:
    Feb 17, 2015
    Posts:
    75
    Bump
     
    gyx920820 likes this.
  12. projectorgames_unity

    projectorgames_unity

    Joined:
    Oct 15, 2018
    Posts:
    107
    This is the top google hit for this subject - any movement?
     
    gyx920820, Bastienre4 and sama-van like this.
  13. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    Need something.
     
    gyx920820 and Bastienre4 like this.
  14. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    Bump.Bump.Bump Please give us runtime options.
     
  15. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    You can't typically change SRP asset settings directly at runtime but you can swap between SRP assets. But the idea is that you just use SRP asset to set the features you want to be included in the build and toggle the feats off somewhere else.

    With HDRP that means you toggle things on/off from either camera, volume or frame settings and can also swap the whole HDRP asset to another either by changing the main SRP asset when there's no quality level overrides for SRP assets... or by changing quality levels if SRP asset overrides have been made for Quality levels.

    I also wrote a bit about some of these earlier here: https://forum.unity.com/threads/making-a-graphics-options-screen-with-hdrp.1153124/#post-7398344
     
  16. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    Thanks a lot for that link. But as garry said "While it's great to be able to turn features off completely, per camera, we have a varied user base on the PC who like to be able to tweak every setting they can"
    Its great we can at-least swap out the asset for different assets settings now, however fine-tuning the options would be best. I'm working on a racing game and having as many graphics options on runtime as possible would, probably, be the best way to go.
     
    malkere likes this.
  17. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Like already mentioned on my previous reply, you can toggle most effects already at runtime, just not from HDRP asset (it's not designed for this purpose).

    Also please do check the link I put there, there are literally examples there how to do this.
     
  18. Incole

    Incole

    Joined:
    May 5, 2018
    Posts:
    10
    Wow. Still nothing. I think it's so cool that we need to feel pain making quality settings menu for PC players.
     
    Last edited: Jul 18, 2022
  19. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    Refer to rz_0lento's posts they are helpful
     
  20. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    I sure would like to know how you got your graphics settings in rust to work... At this point I'd pay you, seeing as how unity won't help us lol.
     
  21. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    Finally some sweet sweet prog.
    So it took me forever to figure this out, because there's no f-----ing documentation explaining this stuff.
    But if you want something like custom LOD biases you need to also change the LOD bias mode to overwrite
    It may sound straight forward, but with no one explaining this it was confusing as heck.
    So for example if we want the LOD bias to = 2.2f

    It will look something like the attached file:
     

    Attached Files:

    Stardog likes this.
  22. John_Milton

    John_Milton

    Joined:
    Mar 30, 2021
    Posts:
    1
    I have found a way to adjust the private field m_renderPipelineSettings from the Unity API. The only setting that I cannot change at runtime is raytracing, so in order to do so, I have two hdrp assets that copy each others fields at runtime, except the only difference is one asset has raytracing enabled. I have two scripts to manage this. Here is my code to accomplish all of this.
     

    Attached Files:

    Last edited: Nov 1, 2022
  23. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37

    heres a tutorial at the request of someone who asked, covers more settings that unity has refused to document like shadow quality and camera render distance
     
  24. UrbanNuke

    UrbanNuke

    Joined:
    Jun 11, 2019
    Posts:
    21
    Still nothing? It will be really useful guys.
     
  25. NanushTol

    NanushTol

    Joined:
    Jan 9, 2018
    Posts:
    131
    Bumping this too, any news on that?
     
  26. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    watch my tutorial, im talking to unity right now. Very frustrated. They consider my code standards to not be up to snuff while they can't even document their own product.
     
  27. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    Unity seems to think the best solution is to ignore game developers and hope that targeting Hollywood directors will somehow give them less problems. (Ironic because I come from the film industry and its only 100x more dramatic)
    I would give up the ghost on hoping that Unity will EVER document this and just watch my tutorials, they simply don't care about developers using HDRP. Its for Hollywood, not us.
    The fact a extremely successful developer was complaining about this 4 years ago and they still have done NOTHING can give one the assumption that they wont any time soon.
    Here was part 1 btw:
     
  28. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    I switched to unreal engine, i suggest all of you do the same.
    This company is looney toons stupid.
     

    Attached Files:

  29. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    I see why gary switched already LOL
     
  30. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
    also when you, inevitably, switch to unreal engine.... Just buy a main menu asset, yah you heard me, main menu asset, now your graphics settings are done for every single game you make ever.
    No pipe-line bs, so the asset will always work.

    Unity isn't going to approve anything that is actually useful to game devs and want unreal's hollywood money more than they want to help us do literally anything.

    HDRP was supposed to be the definitive solution to defeat unreal engine 4's graphics, but 5 is just insane, and now they don't stand a chance. Go look. Download it and try it yourself. Built in features like level building tools unity should have, ai tools that unity wont even approve.

    They've rejected about 6 of my assets so far for no real reason, and gave me the run around when i spent time trying to "improve" them. I'm completely done with this company. If I ask what "too simple" means they tell me to just go "research" on my own. Welp, i did, the unreal market place is much better. And more accepting to ACTUAL game developers instead of just people wishing to play around with play-dough.

    If my "code standards" aren't up to par with this company (even though their own standards post says they don't have any standards see here: https://blog.unity.com/engine-platform/clean-up-your-code-how-to-create-your-own-c-code-style), I hope they one day learn how to code actual graphics settings for actual game developers.

    And maybe learn to give an ounce of respect before they leave for a MUCH superior engine.
     
  31. manbearpigman

    manbearpigman

    Joined:
    Feb 29, 2020
    Posts:
    37
  32. baggyg

    baggyg

    Joined:
    Nov 21, 2013
    Posts:
    30
    Presumably by setting the Min and Max in the Asset and then calling your own scaler delegate based on what you want.

    DynamicResolutionHandler.SetDynamicResScaler(ScalerDelegate, DynamicResScalePolicyType.ReturnsPercentage);

    And say returning 75 for 75% render Scale.
     
    manbearpigman likes this.
  33. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    135
    That lowers the resolution, but only if I disable "allow DLSS". But there are different settings for FSR and DLSS like "maximum performance" or "Balanced" as DLSS custom quality. You can set it on the camera when the QualitySettings are set up. However I have no idea how to change that at runtime. Many games allow the option to choose between FRS, DLSS and the different quality profiles for those. How can I adjust that (at runtime) using c#?
     
  34. baggyg

    baggyg

    Joined:
    Nov 21, 2013
    Posts:
    30
    Pretty simple:

    HDAdditionalCameraData mainCameraData;
    mainCameraData = mainCamera.GetComponent<HDAdditionalCameraData>();
    (where mainCamera is a reference to your camera)

    mainCameraData.deepLearningSuperSamplingUseCustomQualitySettings = true;
    mainCameraData.deepLearningSuperSamplingQuality = (uint)1;
     
    KYL3R likes this.