Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Resolved How to change the HDRI SKY exf cubemap using script ?

Discussion in 'High Definition Render Pipeline' started by MagicienToz, Oct 31, 2021.

  1. MagicienToz

    MagicienToz

    Joined:
    Sep 16, 2020
    Posts:
    2
    Hi, I searched the Internet but I can't find a clean, complete and working script example allowing me to change the exf cubemap from a HDRi Sky.

    Can someone help me ?
     
  2. MagicienToz

    MagicienToz

    Joined:
    Sep 16, 2020
    Posts:
    2
    OK I managed to get what I needed.

    Code (CSharp):
    1.     public Volume skybox;
    2.     public HDRISky sky;
    3.  
    4.     void Start()
    5.     {
    6.  
    7.         if (skybox.profile.TryGet<HDRISky>(out HDRISky tmpOut))
    8.         {
    9.             sky = tmpOut;
    10.         }
    11.  
    12.         if (sky != null)
    13.         {
    14.             CubemapParameter cbParam;
    15.             Texture2D tmpTexture =  StringToTexture("HDRi", "snowy_field_19k");
    16.  
    17.  
    18.             // sky.hdriSky.Override(tmpTexture);
    19.  
    20.         }
    21.      
    22.       }
    I was trying to access directly the hdriSky CubeMap. But there's a simpler way using profiles

    Code (CSharp):
    1. public class HDRIScript : MonoBehaviour
    2. {
    3.     public Volume skybox;
    4.  
    5.     public VolumeProfile test;
    6.  
    7.     // Start is called before the first frame update
    8.     void Start()
    9.     {
    10.         skybox.profile = test;
    11.      }
    12. }
    And it works great !
     
    radiantboy likes this.
  3. Hyper_Vapor

    Hyper_Vapor

    Joined:
    Mar 29, 2023
    Posts:
    1
    like this