Unreal Engine 4 and Blender – Skybox

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.

Project files:

Blender File 2.78 (11 Mb) – GoogleDrive

Backup – Dropbox

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.

https://developer.nvidia.com/nvidia-texture-tools-adobe-photoshop

This is how we have set up baking cube in Blender.

Screenshot_35

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.

boxes2

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:

boxescorrect_updated.png

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.

Screenshot_34

Select your cube and set bake type to Enviroment and hit Bake.

Screenshot_37

Go to uv edit and save all images.

Putting it together with Photoshop

Create a new document. Width needs to be Resolution x 6.

Screenshot_2

File -> Place Embedded

Screenshot_3

You can rotate texture number one from the settings on top and get it in right place by changing X to 1024.

Screenshot_4

You can also use Move tool. Don’t leave any empty space, make sure you use every pixel.

Screenshot_5

All in place:

Screenshot_5.png

When you’re done save it as DDS file.

Screenshot_7

Screenshot_10

Make sure you got Cube Map. After saving don’t close Photoshop yet.

Screenshot_11

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.

Screenshot_12

Texture Settings and Material

Double click cubemap texture in content browser. Change mip map gen setting: nomipmaps and texture group: skybox.

Screenshot_18

Now we need to create skybox material so add a new Material.

Screenshot_16

Open it and change couple things like shading mode, two sided.

Screenshot_1

Drag cubemap texture in your material and set up it like in picture:

Constant value is 8 if picture is unclear for you.

Screenshot_20

Skybox Blueprint

It’s much easier if we just add empty blueprint rather then edit the one located in engine content.

Add blueprint class -> actor.

Screenshot_21

Screenshot_22

Open it. Add Static Mesh and name it something like skydome.

Screenshot_23

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).

Screenshot_42

Note the eye in Variables list.

Screenshot_41

Now you can add your own Sky Material and Sky Sphere (from engine content).

Screenshot_43

Screenshot_3.png

Change settings in skydome mesh.

Screenshot_44

Screenshot_2

Quality

Make sure you use right compression settings. Or you might get something ugly.

Screenshot_26

So much better.

Why i added that arrow there… (haha).

Screenshot_27

Stars

We can actually add stars inside our material in unreal. But first we need to get rid of stars we have in Blender.

Screenshot_33

Bake it again and save all images.

Lets go back to Photoshop.

Right click layer and click Replace Contents.

Screenshot_31

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).

Screenshot_32

Go back to sky material.

Add Texture Sample and change texture to T_Sky_Stars (engine content).

Screenshot_29

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.

Screenshot_30

Looking good but stars should be behind moon. You can probably figure it out though *wink*.

ScreenShot00005.png

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!

Advertisements

One thought on “Unreal Engine 4 and Blender – Skybox

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s