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.

Feature Request It's trivial to change the .png of a skybox right? It should be, look what I want to do: Warp Drive!

Discussion in 'High Definition Render Pipeline' started by goodnewsjimdotcom, Aug 6, 2022.

  1. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    302
    MY QUESTION IS: How do I swap a hdrp skybox graphic texture? It should be easy right? No one can help me. I've been asking for months and even had an employee try and come up empty.

    Amazingly awesome use CASE:

    Warp drive has never been done right before in any video game or movie. We only had glimpses of it in Star Trek TNG.

    I have a Starfield. Proceedurally generated galaxy.

    When a player enters warp, they see the different colored nebula, stars and phenomena whip past them! Far more eloquent than Star Trek TNG. When they exit warp, the player is actively playing the game again and needs to be able to control their player and Frames per second matters. I can render all stars and nebula live in game, but it taxes the player's computer.

    Instead what I want to do should be easy: When the player exits warp and the stars are not moving, I draw what the player sees 360x360 vision to the skybox. Then I derender the stars and nebula. Then the player can start playing in that star system fighting drones/asteroids/selling stuff at stations/etc without the heavy rendering of hundreds of stars and nebula in the distance.

    When the player enters warp, the Entities(gameobjects) render again, the skybox derenders to black and the warp animation happens.

    Awesome right?!? I just need to know how to change a skybox texture on the fly. This should be easy for Unity to do right?
     
  2. cLick1338

    cLick1338

    Joined:
    Feb 23, 2017
    Posts:
    39
    Code (CSharp):
    1. currentVolume.profile.TryGet<HDRISky>(out var hdriSky);
    2. hdriSky.hdriSky.value = newSkyTexture;
    Something like this? Might still be tricky though, HDRP does not do well at all with extra cameras rendering; Will need to slice rendering to avoid frametime spikes (repurpose Unity's reflection probe?); Might need very high res skybox for >=4K displays, low FOV scenarios. Also consider keeping regular rendering on as a graphics setting.
     
  3. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    302
    >Will need to slice rendering to avoid frametime spikes

    Frame spikes don't matter, its a still transition in a cut scene where you won't notice
     
  4. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    302
    Everyone else said it was impossible. I'll try.
     
  5. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    302
    I finally can dig into this having advanced my other tech.

    I have a problem: It's not finding Volume.


    upload_2022-11-25_5-43-14.png




    Here are my usings:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using Steamworks;
    using Unity.Entities;
    using Unity.Mathematics;
    using Unity.Transforms;
    using Unity.Rendering;
    using System.Threading;
    using UnityEngine.Rendering.HighDefinition;

    Thank you, I want to know if this is possible or if I have to change to URP after using HDRP for 1.7 years.
     
  6. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    302
    Okay, I was able to obtain it: UnityEngine.Rendering.Volume

    Next up assigning a texture to it as you say, the last line of your two lines of code. :)
     
  7. goodnewsjimdotcom

    goodnewsjimdotcom

    Joined:
    May 24, 2017
    Posts:
    302
    THANK YOU THANK YOU THANK YOU!

    upload_2022-11-25_7-46-7.png

    MY CODE for others:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using Steamworks;
    using Unity.Entities;
    using Unity.Jobs;
    using Unity.Mathematics;
    using Unity.Transforms;
    using Unity.Rendering;
    using System.Threading;
    using UnityEngine.Rendering.HighDefinition;

    public UnityEngine.Rendering.Volume volume;
    public Cubemap[] myCube;
    public HDRISky sky;

    Start()
    {
    GameObject skygo=[ASSIGN YOUR 'Sky and Fog Volume' GameObject here]

    volume = skygo.GetComponent<UnityEngine.Rendering.Volume>();
    volume.profile.TryGet<HDRISky>(out var hdriSky);

    Cubemap iceCube= [THE CUBE MAP TEXTURE YOU WANT TO ASSIGN]
    hdriSky.hdriSky.value = iceCube;
    }
     
    cLick1338 likes this.