/ Custom skyboxes and cloud domes in Unity /

 

Hi guys & gals!

Today I had some time to play around in Unity again and after some coffee I decided to have a closer look at custom skyboxes and animated cloud domes in Unity. This is something that I`ve always been wanting to check out in more detail and after fiddling around with Substance Designer lately, I had some ideas I wanted to test out.

The skybox in Unity is, well, just a flipped box with a texture on each side. In most cases, this can create pretty cool looking skyboxes, but the problem comes when you want more dynamic weather and moving clouds in your scenes. If you look closely, you can also sometimes see the corners of the skybox and color banding in the textures, which in most cases will break the illusion.

There are plug-ins out there that can do skybox magic for you, but these cost money and money can often be hard to come by. One method also involves creating another camera in your scene that only renders the skybox into a texture, which can then be squeezed into a skybox. With this method you can kind of fake the movement and color tint of the sky by animating the camera rotation and other camera properties, but it`s still pretty limited in terms of depth and variation.

Before experimenting with my Substance ideas, I went into 3ds max and quickly made a standard cube with 6 sides. I then just selected each sideplane and applied some skybox textures I had generated earlier. After adding a Normal modifier to flip the normals, I added a Turbosmooth modifier with 3 subdivisions and voilĂ  –> I now had my own custom skybox, or skysphere in this case :) As I usually do, I finally added an edit mesh modifier on top of the modifier stack and then exported the skysphere to fbx.

In Unity, I could now simply add this skysphere mesh to the scene, scale it up a _LOT_ and add a suitable shader. As I am no coder, I don`t know which shaders I should use for something like this, but I ended up using an “Unlit/Texture” shader. This seemed to do the trick, as you can see below :)

Doing it this way gave me a lot more control and I would get rid of some of the dark corners that sometimes occur the “rigid” built-in skybox. Animating the rotation of the skybox would also be a very simple thing to do now, but I was nowhere done experimenting.

Going back to 3ds max I now wanted to see if I could make some kind of cloud dome and I quickly made one from a sphere, inverted it`s normals and unwrapped it. Next up was Photoshop, where I simply just used the Render Clouds filter and tweaked the levels a little. Back in 3ds max I applied the cloud texture and tweaked the scale using the Unwrap modifier and exported it to fbx. In Unity, after messing around with most of the transparent and particle shaders, I ended up giving it a “Particles/Alpha Blended” shader. With this one, I could tweak both the color tint and the amount of opacity and it seemed to do the trick! I also made a squashed cloud dome to see if it worked better than the regular dome. They both worked well and for variation I decided to use them both in the scene.

The clouds looked pretty cool already, but they were still not moving. Animating them wouldn`t be very hard though, as there are some scripts out there that makes it easy to animate the uv-offset of the texture. This is the one I used, but I also added some code so that the rotation of the dome itself could be animated.

In the end, I added another cloud dome, tweaked the scale a little and adjusted both the animation and rotation speed. This really added to the sunshaft effect on the camera, adding randomness and realism. God rays FTW!

Now I really didn`t need the skysphere mesh, as the cloud domes pretty much did the trick, so I deleted it and gave the background color of the camera a blue`ish tint. This pretty much gave me full control over both the sky and clouds, and it wouldn`t be too hard to make a day/night-cycle and several different types of weather.

This technique worked like a charm and the animated clouds looked quite good, but I still wasn`t superconvinced. The clouds were animated in the sky, right, but the clouds themselves looked very static. I wanted to animate the clouds themselves and quickly realized this could maybe be done using a custom cloud substance generated in Substance Designer. This will be covered in the next blogpost though, so stay tuned for that one! In the meantime, check out the desert scene here:

5 comments

  1. Metakid says:

    Totally cool writeup, thx for this :)

  2. Alec says:

    The desert scene doesn’t work for me. It displays pink instead of the sky texture.

    Would love to see the final version if you get a chance to re-upload it.

  3. Fairchild670 says:

    Thanks for putting this together! Most other skybox tutorials cover the usual cubemap way. This way seems to make more sense to me especially with the layering and minimal draw calls. Great stuff!

    Mix

  4. Edwin Ramses says:

    Hello,
    this desert Scene looks realy cool!!
    Can i download this Scene somewhere?
    Thanks in Advance!
    Edwin

  5. Abdul says:

    My Unity camera is not rendering my sky dome :(
    I inverse the normals in Maya and exported it into Unity but still not working :(

Leave a Reply

Your email address will not be published. Required fields are marked *