So basically, how to create or how to bake skymap in Blender and use it in Unreal Engine 4. We are focusing more of unreal part in this tutorial. Plus we are going to use Photoshop but you can do it with Gimp too, you just need to get gimp cubemap plugin.
Blender file is setup with world material nodes, cube, materials and uv’s. You don’t really need it if you have decent amount of experience with Blender. It’s more for beginners to study.
You need Nvidia texture tools for Photoshop to able to save as cubemap.
This is how we have set up baking cube in Blender.
Plane number 1 is pointing towards front ortho in Blender. If you rotate viewport counter clock wise around cube, we’re going through 2, 3, 4. Top is 5 and bottom is 6.
Note: number 2 should actually be front but we won’t get so good quality with that plan.
We have 6 Materials they each control one texture, UV map is overlapped (all with same rotation).
To pack it as cubemap texture we need to import all images in Photoshop and match it like this:
Baking box/cube is in layer 1 and visualization planes are on layer 2. We only need the cube to do the baking job.
Blend file is packed so first you need to unpack it. Uncheck “automatically pack into .blend” and “unpack all into files”. We are using 2048 x 2048 texture resolution.
You might like to change render device to GPU, goes like 8-12 times faster.
Select your cube and set bake type to Enviroment and hit Bake.
Go to uv edit and save all images.
Putting it together with Photoshop
Create a new document. Width needs to be Resolution x 6.
File -> Place Embedded
You can rotate texture number one from the settings on top and get it in right place by changing X to 1024.
You can also use Move tool. Don’t leave any empty space, make sure you use every pixel.
All in place:
When you’re done save it as DDS file.
Make sure you got Cube Map. After saving don’t close Photoshop yet.
Unreal Engine 4 -> blank project -> remove sky sphere from world outliner.
Import it in Unreal Engine 4. This might take a while. 2k textures should finish in 20 minutes, 4k textures takes 50 minutes or even more. You can actually cheat it if you first import with 512 px and re import with 4k textures. Re import always takes about 3 or 6 minutes no matter of resolution.
Update: seems like it works faster with 4.15.
Texture Settings and Material
Double click cubemap texture in content browser. Change mip map gen setting: nomipmaps and texture group: skybox.
Now we need to create skybox material so add a new Material.
Open it and change couple things like shading mode, two sided.
Drag cubemap texture in your material and set up it like in picture:
Constant value is 8 if picture is unclear for you.
It’s much easier if we just add empty blueprint rather then edit the one located in engine content.
Add blueprint class -> actor.
Open it. Add Static Mesh and name it something like skydome.
Go to Construction Script. Add Set Material and Set Static Mesh and make it look like in picture below.
Promote public variables to “New Mesh” and “Material” (right click).
Note the eye in Variables list.
Now you can add your own Sky Material and Sky Sphere (from engine content).
Change settings in skydome mesh.
Make sure you use right compression settings. Or you might get something ugly.
So much better.
Why i added that arrow there… (haha).
We can actually add stars inside our material in unreal. But first we need to get rid of stars we have in Blender.
Bake it again and save all images.
Lets go back to Photoshop.
Right click layer and click Replace Contents.
Match the number and hit Place. Go through all layers. Export as cubemap again and reimport in ue4 (right click on cubemap in content browser).
Go back to sky material.
Add Texture Sample and change texture to T_Sky_Stars (engine content).
Add few more things like texturecoord, scalarparameter, multiply and lerp.
TexCoord settings are:
- Coordinate index: 1
- Utiling: 12
- Vtiling: 12
ScalarParameter value is 0.1
And connect it all like in below.
Looking good but stars should be behind moon. You can probably figure it out though *wink*.
If your scene is on planet this workflow doesn’t work well. Usually people wan’t more dynamic sky maps. But if your scene is in space then this is very good way to do it. But now you know how to work with sky maps in ue4 and that was the whole point of this tutorial.
Noise texture node in Blender made that white spot in textures. It helps you to see if bottom texture is correctly set though.
Thanks for reading!