[Tutorial] Skybox - Environment Cube

skybox is a method of creating backgrounds to make a computer and video game levels look bigger than it really is. When a skybox is used, the level is enclosed in a cuboid; and the sky, distant mountains, distant buildings, and other unreachable objects are projected onto the cube's faces (using a technique called cube mapping), thus creating the illusion of distant three-dimensional surroundings.

skydome employs the same concept but uses either a sphere or a hemisphere instead of a cube.

Games often employ skyboxes. Traditionally, these are simple cubes with up to 6 different textures placed on the faces. By careful alignment, a viewer in the exact middle of the skybox will perceive the illusion of a real 3D world around it, made up of those 6 faces. http://en.wikipedia.org/wiki/Skybox_(video_games)


A good example of what the skybox and environment cube does.

 

 

Skydomes

For the in game background, SoaSE uses a spherical skybox, often referred to as a skydome, in conjunction with an environment cube for in game reflections on the models.

SoaSE uses 2 types of spherical UVs for the skydomes. The first set is a smaller size (4 mb textures) but separates the top and bottom islands to avoid the 'pole pinch'.

 

The larger texture set spheres (8 mb textures) UV unwraps the entire sphere onto a single flat UV. Pole pinch is an issue, but can be avoided by leaving the poles transparent for stars to show through, or using a solid colour. The alpha channel is the transparency mask.


To open, edit and save the textures in GIMP, the DDS plugin is required. The GIMP project files below can be opened without the plugin as the textures are already saved in the project.

 

SkyboxBackdrop.4096x2048.xcf

Includes the 3 stock 4096 x 2048 textures, a simple star field, the UV map, and a few nebula examples from a google image search.

Trinity (used mipmaps)
Rebellion (no mipmaps)

 

 

 

The Alpha mask

Once the skydome texture is complete, the alpha channel will need to be edited to allow the in-game star field to show through. The black areas on the alpha allow the texture to show, while the transparent areas allow the star field to show through. Applying the mask to the alpha keeps the original image intact.

 

To edit the alpha channel, add a layer mask and apply the brush effect to the layer mask.

Under the Layers tab, right click the layer to edit and choose Add Layer Mask. A dialog box will ask you how you want the layer mask to be initialized. Presuming you'll start with a visible image and brush away the part you want transparent, the best choice is White (Full Opacity). Click Add.

Under the Layers tab, you should now see the white thumbnail of the layer mask, next to the thumbnail of the layer image. Click on the thumbnail to edit the layer mask. Choose your brush effect and the color black, and apply the transparancy.

If you switch to the Channels tab, you will see in real time how the alpha channel changes as you paint on the layer mask.

If you prefer to start with a transparent image and brush on the part you want visible, just start with a layer mask which is Black (Full Transparency) and apply your brush effect to the layer mask with the color white.

You can always switch back and forth between black and white paint to add or remove transparency on the layer mask.

When you want to return to editing the layer image instead of the layer mask, go back to the Layers tab and click on the thumbnail of the layer image.

After the layer mask is completed, export the texture to .dds, or export to raw .tga and use AMD's Compressionator. Save the GIMP project file.


For Sins: Rebellion's new skyboxes we also optimized them using AMD's Compressonator tool. It yielded significantly smaller file sizes with fewer compression artifacts/degradation than other tools. -- Yarlen



Environment Cube

A cube map is a series of six textures that are combined together in the shape of a cube to give the illusion of being surrounded by an environment. They are usually made from a series of six texture maps stitched together onto the sides of a cube and behave similarly to standard texture maps.

Remember that SoaSE only uses Environment Cubes for reflections on models in game.


There is a script for GIMP that will cut the above shapes into separate layers and save as a .DDS texture, but will not work on the style Blender creates shown below. 
Cubemap Layers Generator


This 6 sided cube map image was created in Blender by placing a cube inside the textured sphere skydome with the spheres normals flipped (flip faces) so the texture points inward and gets projected onto the cube. This and other things are shown in the video tutorial below.

Environment cube


You can do any post-production here. It looks like SoaSE upped the brightness/contrast and played with the colour ramp a bit before chopping the images and placing them on the separate 256 x 256 layers.


From Blender, the created cube faces are in the following order.


  • Download to edit/customize this Gimp text layout file.
  • Download the example Environment Map Gimp file.
  • Download the Environment Map Blender scene file.


The 2 sections with the arrows need the UVs to be rotated 180°.


 

 

This is the order in GIMP of the imported skybox03environmentcube.dds from the SoaSE textures directory.

Load the six image clips into GIMP as separate layers.

 

 

 

 

 

 

 

 


When everything is setup, you can export the .dds file. Under 'Export As' select .dds and name your file (make sure the file name has the .dds extension). Some pop-up options will be presented if you have the .dds plugin installed correctly.




 

Inside the Environment Cube in Blender

 



Blender Skydome and Environment Cube Tutorial

Note: If you create a new sphere with new UVs in Blender, it will have to be exported (.obj) and imported into XSI|Softimage for export to a SoaSE mesh. The included Blender file will have the 2 types of spheres and the existing SkyboxBackdrop's packed. I recommend copying one of the existing textures and painting the new one, and use the included Blender file to create the skybox environment cube for the in game model reflections.

If you plan on following the video below, note that he uses Blender particles to create stars. SoaSE has assets you can attach to these particles and follow along. Typical install directory.
C:\Program Files (x86)\Steam\steamapps\common\Sins of a Solar Empire Rebellion\Textures

  • StarscapeStar0.dds
  • StarscapeStar1.dds

 

Also note that the tutorial saves the images as .PNG which uses compression. Always save the textures as lossless Targa Raw (.TGA), then convert to .DDS for use in game. Always save the original assets in lossless form. BMP is also lossless, but does not allow transparencies.

 

 

Skydomes.blend (139 mb)

Includes the 7 stock skydomes with textures packed, and a couple blank copies to experiment with. The EnvCube is created but not set-up. Follow the steps outlined in the video below.

 

 

 

 

  


See also:

Skyboxs for download

 

Blender - Blender Render (Internal) vs Cycles Render

Just realize that the environment blender file scene will be in 'Blender Render' due to the limitations of the Cycles engine. This is explained in Render A Skybox Environment Map (Cycles Render) which does include a workaround. All the model scenes will be in the newer Cycles engine.

Blender Basics - 05 - Shading and Lighting 
Blender Beginner Tutorial - Part 4: Material Nodes

 

Blender - Create some cool scenes to render your models

Render A Skybox Environment Map (Blender Render) 
Render A Skybox Environment Map (Cycles Render)

How to Create a Realistic Earth in Blender (Blender Render) 
How to Create a Realistic Earth in Blender (Cycles Render)

 
   
29,714 views 14 replies
Reply #1 Top

reserved  :X

Reply #2 Top

Here is a scene with an environment cube with all the different environmentcube textures from
C:\Program Files (x86)\Stardock Games\Sins of a Solar Empire - Trinity\Textures 

In the materials manager, just connect a new cube texture to see how it looks. 

The top and bottom never match up that well, but I expected that, coming from a spherical texture image.

 

soase.x90x.net/Skybox/Skybox-environmentCubes.exp

 

 

Reply #3 Top

Huh, I must have picked the wrong skybox to look at. Replying so I don't forget about his.

Reply #4 Top

You realize the skybox, and enviroment cube textures do not need any mip maps, because the skybox, or enviroment cube doesnt scale in, or out like the ship meshes do. Already fixed that issue for next TSOP update. :) Amazing how much less space textures take up if you take out the mip maps.

Good Job Fist0 :D

Reply #5 Top

Ya Stress, I was just wiping up some info and seen that EnvCubes1 in trin uses no mipmaps, all the rest do.

The Reb EnvCubes I checked  (thanks to  :X ) don't use them. The ones that have them must be a saving error.

Will add a bunch of info tomorrow.

+1 Loading…
Reply #6 Top

Okay, the source of my problem from way before was that paint.net will only open 1 side of the cube. Opening it in GIMP produced 6 different layers, one for each side, so I think I can figure that out now.

Reply #7 Top

For Sins: Rebellion's new skyboxes we also optimized them using AMD's Compressonator tool. It yielded significantly smaller file sizes with fewer compression artifacts/degradation than other tools.

Reply #8 Top

Thanks Yarlen, I am going to quote you for the OP

Reply #9 Top

Bumping this old topic to point out a problem i am running into when i edit the environment cubes.

When the texture is re-saved (ether from a new texture, or editing an existing texture) using the ATI compressionator apparently the "cube map" flag disappears, and you will get this dev.exe error.

Assert @ C:\Projects\P4\SinsEntrench\Release\CodeSource\Engine/Render/Texture/FileCubeTexture.cpp(77)

DirectXAssert: [!FAILED(dxVerifyHR)]
Context: D3DXCreateCubeTextureFromFile( g_Core.d3d9->GetDevice(), fullFileName, &d3dCubeTexture)
HR: (E_FAIL)-An undetermined error occurred.

The only way i have found to save the texture properly is to use the nvidia photoshop dds plugin, and select cube map from the drop down menu. Though i loathe re-saving from an existing DDS texture like this, because of degradation.

Is it possible to see the original environment cube TGA's (or whatever loss less format the textures were saved)?

We also need a list of other image editors that can save a texture as a "cube map".

Reply #10 Top

Quoting Major, reply 9

The only way i have found to save the texture properly is to use the nvidia photoshop dds plugin, and select cube map from the drop down menu. Though i loathe re-saving from an existing DDS texture like this, because of degradation.

Too bad, since I don't have photoshop. Wonder if GIMP has that option.

Reply #11 Top

I compressed an existing texture with AMD Compressonator and loaded it in game. I did not see that error. I also added mipmaps in the cube map with the compressonator.

 

https://dl.dropboxusercontent.com/u/5790092/Temp/skybox02environmentcube.DDS

 

I also resaved the original skybox02environmentcube.DDS in AMD Compressonator and did not see the error in that case either. The compressonator also seemed to know it was a cube map and had options to view the different parts of the cube map.

 

In the end I couldn't reproduce what you are seeing unless you are doing something different from what I interpreted from the post.

 

 

Reply #12 Top

What i did was remove the Mip Maps from some of the environment cubes, because they are not needed at all. The skybox does not scale when you zoom in, and out. So i treated the Skybox, and Environment Cubes as UI Textures with no lodding what so ever.

Where i messed up is that i saved my edited textures in TGA format first. This was to keep the detail loss down as much as possible. THAT is where it changed from a cube map to a standard texture. When i saved it in TGA it was no longer a cube map. If i re-saved it straight from its original DDS texture the cube map flag would have remained.

I had to do a little research on this. ATI Compressionator is outstanding as far as conversion from TGA to DDS. However it does not have any way to save a texture as a cube map. Like i said before. The only converter that i found that can save a texture as a cube map is the Nvidia DDS Photoshop plugin. ATI has a "cube mapper", but i haven't looked into it yet, and as far as i know that is all that's out there.

Reply #13 Top

Considering the cube map needs to be in layers and tga does not support layers I can understand why the compressonator didn't handle that. If Photoshop has a way to convert a tga into a cube map then that may be your way to go.

Also, I only did the mips to verify the compression/conversion was working against the existing cube map file.

Reply #14 Top

Yea i removed the mips, because they didn't make any sense. Plus some of the skybox/environment cubes had mips where some others did not. I figure it was a mistake on the dev's part when the originals were saved. I can see how it could happen.

Is there a purpose for an alpha channel in the cube map? Again some of the original cube maps have them, but others do not.