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. Dismiss Notice

Resolved Physically Based Sky - Rotating around Polar star?

Discussion in 'High Definition Render Pipeline' started by Kadae, Jun 20, 2023.

  1. Kadae

    Kadae

    Joined:
    Dec 7, 2013
    Posts:
    52
    Tying to create realistic night sky with HDRP.

    Physically Based Sky have Space Rotating (Vector3) and Texture (with some stars).

    The question is... How to rotate my night sky around Polar Star (some specific star on Texture) with Space Rotating (Vector3)? :confused:



    Is it possible? Or maybe need a feature request for this, Unity?
     
  2. Kadae

    Kadae

    Joined:
    Dec 7, 2013
    Posts:
    52
     
    Last edited: Jun 20, 2023
  3. cLick1338

    cLick1338

    Joined:
    Feb 23, 2017
    Posts:
    74
    You can dig into astronomical coordinate systems if you want scientific accuracy or you can spin the space skybox around an axis you can manually set. Could maybe bruteforce finding the right values at runtime (if not easy, point a camera at the star and use its rotation/use debug draws etc.)

    It'd be too specific to implement by Unity and the means are already here to implement it if you know what you're looking for.
     
    Kadae likes this.
  4. SebLazyWizard

    SebLazyWizard

    Joined:
    Jun 15, 2018
    Posts:
    220
    In case your star map is already in celestial coordinates (like this one https://svs.gsfc.nasa.gov/4851) you can simply rotate it along the Y axis, the polar star stays always at the very top.
     
    Kadae likes this.
  5. Kadae

    Kadae

    Joined:
    Dec 7, 2013
    Posts:
    52
    Rotating only one axis works in places like Equator and North/South poles... If Polar star at very top, we are in Arctica. But my game is not about Polar Bears.
     
  6. SebLazyWizard

    SebLazyWizard

    Joined:
    Jun 15, 2018
    Posts:
    220
    Then just multiply it by another rotation representing your position on the planet, something like this;
    Code (CSharp):
    1. Vector3 spaceRot = (Quaternion.Euler(90 - latitude, 0, 0) * Quaternion.Euler(0, dayTime, 0)).eulerAngles;
     
    Kadae likes this.
  7. Kadae

    Kadae

    Joined:
    Dec 7, 2013
    Posts:
    52
    Good, Quaternions works like a charm. Thank you all for the answer!
     
    SebLazyWizard likes this.