- Home /
HDRP Rotate Skybox in Time DeltaTime
This should be simple, and every time I cannot find anyone addressing my question it means I'm overlooking something everyone else thinks is obvious.
Working in Unity 2020.3 High Definition Render Pipeline
Turn on Project Settings in Edit > Project Settings Then, in **Project Settings > HDRP Default Settings > HDRI Sky (checked) > HDRI Sk**y is using a cubemap for a skybox dragged from the Assets folder into the slot in the Settings Panel.
Below that are some settings: - Enable Distortion (unchecked) - Intensity Mode - Exposure - ROTATION <--- Can I animate this? If I can then I could slowly rotate my skybox in the game, right?
Just below Rotation are Update Mode and Update Period which don't appear to do anything as far as I can tell.
How can I animate the Skybox with a slow rotation?
I've tried the following script, added as a component to an empty game object in the hierarchy, which again does nothing as far as I can tell:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateSky : MonoBehaviour
{
public float speed_Multiplier = 0.01f;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
RenderSettings.skybox.SetFloat("_Rotation", Time.time * speed_Multiplier);
//To set the speed, just multiply Time.time with whatever amount you want in the speed multiplier.
}
}
Answer by Koyemsi · May 11, 2021 at 11:20 AM
You can try this :
using UnityEngine;
public class SkyAnim : MonoBehaviour { public Material skyboxMat; float rot = 0f;
void Update() { skyboxMat.SetFloat("_Rotation", rot); rot += Time.deltaTime * 10f; } }
Please note that I used a 6-sided skybox for this, because I had no cubemap to play with, but I assume it will work the same.
Answer by JeffreyBennett · May 11, 2021 at 01:06 PM
That probably would work if you have a material for your skybox. In the HDRP you don't use a material for the skybox, and you don't attach it to the camera or anything like that.
In the HDRP the Project Settings accepts your cube map, not really a material, and uses that for the Skybox. In fact, I have no idea how you change the skybox from one scene to the next, or in a new volume or anything, because the project settings are at the project level and seem to be global for the whole project. HDRP is weird that way!
So your script, I don't know where it gets the material from to animate. And also I don't know what to attach it to. Your public variable skyboxMat would logically point to the skybox cubemap that is in the Project Settings, but there is no way I can see to refer up to the map in the project settings. You cannot, for example, drag and drop the project settings panel into the public variable in the Inspector.
Thanks for the attempt @Koyemsi , but it looks as if I still have a lot of work to do to figure this out.
You're welcome. Actually I never used the HDRP, so I wasn't aware of these particularities. Sorry I couldn't help, wishing you good luck.
Your answer
Follow this Question
Related Questions
Unity 5 procedural skybox with working bottom 1 Answer
creating skybox material problem 1 Answer
Changing skyboxes? 1 Answer
Skybox uses 1.7k Tris and 5.0k Verts even if occluded? 1 Answer
Custom procedural skybox 0 Answers