Search Unity

Skybox question I have..

Discussion in 'General Discussion' started by Terra-Sanctum, Apr 19, 2017.

  1. Terra-Sanctum

    Terra-Sanctum

    Joined:
    Sep 26, 2013
    Posts:
    21
    Hello,

    I created a 6 sided Skybox for my project and immediately noticed that the directional light wont project a "sun" in the scene anymore. I could create a fake sun but Im making a space game and its really important the sun itself is a directional light, not a game object in the scene.. Is it possible make directional lights work on 6 sided Skyboxes the same way they work on the default Skybox?

    Thanks
     
  2. Terra-Sanctum

    Terra-Sanctum

    Joined:
    Sep 26, 2013
    Posts:
    21
    I wonder, my Space 6 sided images, that make my Skybox dont have a Sun, the only way to make this effect is by adding the sun image to the Skybox and aligning my directional light towards the sun position in the Skybox image?
     
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,529
    You can use flares on directional lights.
     
  4. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    the original skybox is a procedural one, the it is putting the sunspot on it in the skyboxes shader, based on the scenes dominate directional light.
     
  5. Terra-Sanctum

    Terra-Sanctum

    Joined:
    Sep 26, 2013
    Posts:
    21
    Flares wont do the trick since its a spaceship game, the real problem is the fact the flare disappears completely behind a gameobject, like a planet. You cant see it shining at the border if the planets are, for example, like the Default Skybox sun does, you can still see it behind a object.

    I have read something saying the Default Skybox uses procedural shader, but is it possible do the same in a 6 sided skybox? Or are they all static and cant have day cycles effect?
     
  6. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,529
    The flares disappearing this is indeed annoying, but there are proper lens flare solutions on the store that help fix this iirc.

    6 sided skyboxes are static.
     
  7. Terra-Sanctum

    Terra-Sanctum

    Joined:
    Sep 26, 2013
    Posts:
    21
    That ruined my day :(

    So, unless you use one of the default skyboxes shipped with unity, there is no way to make a day cycle?
     
  8. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    Erm. You can write your own skybox shader. And you can use different images for skybox.
     
  9. Terra-Sanctum

    Terra-Sanctum

    Joined:
    Sep 26, 2013
    Posts:
    21
    Can I use different images in the procedural skybox? Because Im using a 6 sided skybox to simulate a deep space. I dont really need a full day cycle, I just need a static sun effect, like the directional light do on procedural Skyboxes. I cant get the same result using Game Objects as th Sun
     
    Last edited: Apr 19, 2017
  10. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,023
    In my space game, I built a runtime procedural scene generator that creates a 3D space scene and bakes it to a static skybox. Then I use the static skybox as the skybox for the player's camera. It works great and offer excellent performance benefits. But it is static. That is the tradeoff.

    One option if you want to have movements within the skybox is to periodically regenerate the 3D space scene and rebake it to the skybox. This would let you have various cycles.

    The directional light need to be attached to another game object in the scene, which is easy enough.
     
  11. Terra-Sanctum

    Terra-Sanctum

    Joined:
    Sep 26, 2013
    Posts:
    21
    I see, one question, where can I find the default procedural and 6 sided skybox shaders script? I will see if I can see if I can make my own shader, using the sun with 6 sided maps
     
  12. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
    You can download source code for all standard shaders from unity website:
    https://unity3d.com/get-unity/download/archive

    Just click on "v" dropdown menu, and select Built-in shaders. The archive will include source code for every shader, including skyboxes.

    Also, you can have multiple cameras active in the scene at the same time rendering into the same viewport. So you could have first camera render dynamic skybox somewhere, and the second one render the scene on top of that (just need to clear zbuffer, pretty much). The only problem is that the dynamic skybox rendered thsi way won't really contribute to GI, but then again, there's not much of a GI in space.
     
  13. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,023
    Yeah, I tried that for a while. Baking the a static skybox offers a performance advantage over using stacked cameras, though.
     
  14. Terra-Sanctum

    Terra-Sanctum

    Joined:
    Sep 26, 2013
    Posts:
    21
    Alright, thanks for that. I have downloaded all shaders code but its really beyond my limited programing knowledge, I dont think I can play with that;

    Im not sure if I understand, you mean you baked the procedural shader into a 6 sided skybox? And by doing this you got a static sun baked into your 6 sided skybox?
     
  15. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,023
    No, I was not talking about using a procedural shader. I mean I procedurally generated a 3D space scene, then rendered that scene to a separate camera (using a separate layer), and then I baked that into a skybox. Then I use the skybox with the player's camera. Yes, the sun gets statically baked into the skybox, so I create a second sun in a game object in one of the layers the player's camera can see.