Monday 12 May 2014

Creating a Sky Box

Every outdoor level needs a sky, and in Unity you use a sky box object to create this. The sky box is a large scale cube with a texture on each face, it's on such a large scale that it doesn't appear like a cube to the player so it makes the space of the sky seem infinite. The texture is not affected by light sources or shadows, so it doesn't appear like other objects in the level.

With my level I've also got to add the mechanic of a transitioning sky box, where the texture must change from evening to night. After talking with Sean Oxspring and Alex Saye who are programming and assisting with the Unity aspects of the project, they have told me that it's possible and relatively easy to achieve a transitioning sky box. I have looked into the process myself, the parts which I can do is creating two textures for each time of day. Alex Saye will be implementing it into Unity and programming the transition.

The Unity website had a lot of information on how to do this, so it was quite easy to learn. [For exmaple]

In a Photoshop file I started by creating all of the evening skybox textures. Searching some games development forums, I found that the resolution of the sky box textures should be anywhere from 512x512 and above works. A few people recommended at least 1024, however I thought I would try 512 and use that if it's not too pixelated. I started with a colour gradient layer which is used for the front, left, right and back faces. Then by colour picking the shades at the top and bottom of this image, I created 2 block colour layers for the top and bottom faces of the box. Next I needed to add some clouds, so I painted different variations for each face (except top and bottom). I saved each combination for each face as .tga files to drop into the Unity project folder, ready to apply to the sky box object.  



I repeated this process for the night versions, however this time I made adjustment layers above the cloud layers so that I could change the colour of the clouds according to night-time lighting without changing their shape or position. I also added stars layers and painted a few stars on each face. 


Below you can see how the transition looks during a gameplay test. 




One issue I do have is the visible seams of the box. After consulting with Alex and Sean they could not find a way of fixing this.