Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Call for a sky environment update from a script?

Discussion in 'High Definition Render Pipeline' started by Kamichalik, Feb 28, 2020.

  1. Kamichalik

    Kamichalik

    Joined:
    Apr 18, 2018
    Posts:
    5
    Can anyone give me a code example, I cant find a working example for this in any documentation.
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
  3. Kamichalik

    Kamichalik

    Joined:
    Apr 18, 2018
    Posts:
    5
    In the new HDRP Gradient Sky, it has an exposure variable, which can be edited and affects the colour of the unlit areas of models from the direction light, whenever the exposure value is changed it will not have any effect until SkyEnvironmentUpdate() is called from the HDRenderPipeline Class, this can be done automatically is you select the realtime option on your gradient sky update mode, but there is another option called OnDemand(), when OnDemand is the selected option, you need to manually call SkyEnvironmentUpdate(), now this function is not static and requires an actual instance of the HDRenderPipeline Class, which i have no clue how to get, which is my question, where do i get a reference to this object.
     
  4. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Ok I see now. Any reason you can't use that realtime update, if it works? (EDIT or On Changed.)
     
    Last edited: Mar 4, 2020
  5. alloystorm

    alloystorm

    Joined:
    Jul 25, 2019
    Posts:
    88
    Here is what I'm doing
    Code (CSharp):
    1.  
    2. if (RenderPipelineManager.currentPipeline is HDRenderPipeline) {
    3.     HDRenderPipeline hd = (HDRenderPipeline)RenderPipelineManager.currentPipeline;
    4.     hd.RequestSkyEnvironmentUpdate();
    5. }
    6.