Search Unity

Is it possible to create a sky-sphere?

Discussion in 'Editor & General Support' started by Dulrr, May 5, 2009.

  1. Dulrr

    Dulrr

    Joined:
    May 5, 2009
    Posts:
    17
    Greetings gentlefolk,

    New to Unity and working on our first game. Trying to implement a nice day/night cycle. Have the sun working nicely, and next step is the stars.

    Having a physics/astronomy background, the stars are something I want to get right. Specifically, I would like to have the constellations rotate about the pole over the course of the night.

    So... probably not easy using a skybox. However, if I could encase the scene in a sky sphere that's visible at night, the scene can be tilted and rotated 15 degrees per game-hour to give the effect.

    Anybody have any thoughts about if/how something like this could be done?
     
  2. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    Make a (inside-out) sphere. Stick a camera inside it. Keep that camera pointing in the same direction as your main camera. Set up rendering so that the sphere camera renders first, and so that the second camera doesn't erase or draw a sky.

    Both cameras should render to the same part of the screen.

    You may need to do some other tricks, like sticking your sky sphere and its camera outside max range of your main camera or doing some finagling with layers, etc.

    That's the general idea -- and similar techniques are used for real-time depth-of-field effects and managing the complexity of gigantic scenes (you have a low detail "world" mesh rendered in backdrop by one camera and a higher detail "local" mesh rendered on top of it by another camera).

    There should be a ton of examples of this kind of thing around.
     
  3. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    Another solution, also using two cameras, is to have one camera with a skybox on it, and another camera with a higher depth for everything else. The trick is then to set the rotation of the skybox camera to be the same as the rotation of the other camera, except that you can multiply that skybox camera rotation with some other rotation to make the skybox appear to rotate.

    This solution does not require a special mesh skysphere or skybox but can use the built-in feature.

    Rune
     
  4. Dulrr

    Dulrr

    Joined:
    May 5, 2009
    Posts:
    17
    Thanks for the advice! Will see what I can get working!