Layered materials in Unreal Engine 4

Some time ago I finished first vehicle for my project “Stranger Worlds”.
Vehicle’s codename – Thor.

During development, I solved on of the biggest problem for me - how to make materials for a complex asset with hundreds of parts and achieve a clean result. Before that, I used two different approaches in texturing – unique textures for unique assets and texture atlases for environments. But unique textures mean that I should make around 5-10 materials for such vehicle, each one containing at least three 4K textures to achieve proper texture distribution. Making texture atlases is also not a good approach due to tight UV.

So I decided to develop new (for me) texturing workflow, which will give me an ability to texture complex assets with very tight UVs by using only one material. 

It’s all started from block-out. I also tried to test vehicle in UE4 as early as possible, because vehicle system in UE4 is really complicated and even if you have one wrong joint orientation or wrong collision between parts, your vehicle won't be able to move or you will see a bunch of other problems. So it's important to fixate main design as soon as possible to prevent lots of bugs and changes later.

I decided from start not to bake any maps, so I had to found another way to add small details to the model. In UE4 it’s possible to use normal decals, so I made a simple plane mesh, paint normal decals on it in Substance Painter 2, then export a normal texture to Maya LT and cut plane into separate pieces, which I can use as decals to provide small details on the model.

Then I started to add details to my model block-out. Because it’s a vehicle for the game, which is not using normal maps, it was hard to keep enough details while keeping the smallest possible number of polygons.

After I became happy with my model, I started to make UV for the vehicle. It’s a pretty boring task, which took around 3 hours. Usually, I’m hiding all similar parts and then unwrapping unique parts of a mesh. Then I’m using texel density script and packing all unique UV islands in 0-1 space. After that I copying UV to hidden mesh. As a result, I’ve got something like this. Not the best packing, but because I’m making my game all alone, speed is the most crucial thing, so I simply can’t be a perfectionist.

If your model is a static object, then you can use simple automatic unwrapping and use tri-planar mapping in UE4. But because my vehicle has a rig, attached to it, I have to make a proper UV, because tri-planar mapping gives some artifacts for skeletal meshes in UE4, when they moves and I still don’t know how to fight with it. Even though, for most assets, tri-planar mapping will save you a lot of time.

After I made an UV, I started to draw masks in Substance Painter 2. I used custom channels to draw 3 masks in additional to the base material. It’s possible to draw more masks, but in case of this model, I simply didn’t need more. If you don’t have tight UV, like in this model, you can use smart masks to add additional effects like dirt or scratches and use this mask later in UE4. But in my case, I could draw masks only on the whole UV islands or objects, so proper unwrapping was a key to good material distribution.

When I finished with masks, I started to develop proper material in UE4. I decided to use a layered materials with tiled textures, so tight UV won't be a bottleneck anymore. I wrote a universal master material, which allows to quickly texture any asset by using masks from SP2. I also wrote a universal material layer function, which works with packed maps from SP2. It’s also possible to add additional effects to layers, like noise masks or tune existing maps to achieve the desired effect. Now I have a library of 120+ tiled materials (each one has three 2K textures), 50+ noise masks (can be applied per layer to add more details), 100+ normal/emissive decals (which all stored in 1 texture) in my project at this moment. I can reuse them in many game assets, instead of making unique textures per each asset, so I can save a lot of memory because of that.

You might have heard that layered materials are quite expensive after you read official UE documentation. I guess it can be true, especially for small assets or for mobile games. However, shader complexity even for material with 7 layers looks green. Moreover, I know that layered materials are used in Paragon for texturing characters, so I guess it's fine to use them for complex assets.

When material has been ready, I started to experiment with its parameters and try different textures to get a proper look of the vehicle. 

Such workflow gives you an ability to easily implement In-Game asset customization, so the player can change materials on the fly.

After that, I tested vehicle in different environments to be sure that materials look good in different lighting scenarios.

At this moment, the biggest bunch of work with this vehicle has been completed and I’m happy with result. I’m planning to use this workflow for other complex assets – starships, big objects (probably will use distance-based texture tiling, like I did for landscapes) and maybe for some complex unique props in environments. Thanks for reading.

Artstation: https://www.artstation.com/artwork/DKOEo

Ruslan Nazirov

I am 25 years old developer. I have solid experience in programming and used to be a java developer for 4 years. Now I’m working on my own projects and games, based on Unreal Engine 4.

Leave a Reply