Creating a Real-time Photo-real Landscape Material in UE4 (Quixel)
Hi all,
I'm the lead dev on a WW2 hardcore FPS title called Hell Let Loose. You can check out the game at our website and on Steam.
I've said in a couple of places that I'll put together a bit of a guide on how to create a landscape material that presents well in-engine, works at real-time and gets close to photo-real in quality - that also uses Quixel Megascans. Our team is only made up of 6 full time devs (including every department), and all our maps are created by 1-2 people at most. The key to creating beautiful work in-game is to be careful in controlling each asset as it comes in and working to make them sit correctly together. There are a couple of other aspects that I may make additional posts on down the line (lighting/atmosphere, world building, foliage etc.).
The landscape material in action in our European theatre from an upcoming map.
Fundamentally, a good looking landscape material is going to be based on the reference you find and the amount of testing that can be done as you refine the look. I began using Unreal Engine in 2015 and before that had absolutely no experience with 3D art - so I want to encourage you that it's very possible to continue refining your work and pushing yourself to aim for a greater visual fidelity.
In that time, we've developed a pretty standard pipeline for creating landscapes that give us great flexibility in achieving a diversity of looks across a large 2km map. We knew that we needed at least 7-10 materials in order to quickly achieve multiple different looks. The layers have two purposes - the first is that they allow us greater creative control in quickly establishing a different location (mud vs grass vs cobbles) and the second is that they allow us to auto-spawn "grass" and other small objects per layer. This is a really quick and powerful way of painting in a natural environment without having to worry about the manual placement of smaller props.
To begin our landscape material, I think about the location of the level and begin looking at references in order to start breaking down the key looks. For us, that's often:
- Mud
- Dirt
- Flattened field grass
- Longer, wild grass
- Rubble
etc.
Below I've written out a guide that I'll iterate on and add to if people have questions. It's a complex process and has lots of nuance and other quirks to navigate in order to accomplish a good look in-engine. Often, the things that make the biggest difference are not what you'd expect (like scale of the texture as applied to the landscape).
Landscape Material Layer Setup:
- Set up your material in Quixel Mixer. I always use a 4m x 4m plane, as the detail quality remains high even at 2k when imported into engine. It also means that there is more unique surface area in the engine before it needs to repeat (ie. the texture repeats every 4m or so instead of every 2m). I also make sure to keep the lighting preset as Pisa within Mixer. While this is not the most accurate, the key is to keep consistency so that what you see in Mixer stays uniform. If you change the lighting setting a lot in Mixer, you'll end up with textures that look continually different with each import into UE4.
- Export the 3 textures from Quixel Mixer to the appropriate content folder in your project (ie. content/materials/landscape) using the following settings in Mixer. We export as PNG as it's the best format for UE4 (compression vs quality). I always export 4k as we can manually set the resolution lower in engine by changing the LOD bias in texture. It is important to flip the Y (green) channel in your normal as UE4 has it flipped by default. I normalize the displacement map as it creates stronger details that allow for crisper and more defined tessellation within the engine. Pay particular attention to the RDA map - it is one texture with the roughness in the red channel, displacement in the green channel and ao in the blue channel. If you're using a metallic landscape material, you may want to export out an additional map or potentially change displacement to metallic. Please note, these channels are laid out in a way to maximise texture budget. NEVER use the alpha channel in a texture, as it will end up costing 3 x the total texture memory than one entire texture and is never efficient.
- Drag your three textures into your landscape material and begin to set them up using the following guide. Image 01 and then image 02. Image 02 is designed to create a macro variation in color/diffuse throughout that material layer (ie. we use it to create larger patches of dead grass in our normal grass material). You can simply use image 01 as your guide and plug in the Albedo node straight in - instead of going up to the lerp. Depending on how complex you want to make it, you can also use this same technique to vary roughness, normal and all other properties of the material. The only property that does not function via lerp is displacement/tessellation.
- Navigate to your textures in your content browser in-engine and select the special/RDA map (it'll appear pink in the engine). Double click it and change the settings with the following in mind. Having changed the settings inside the texture itself, you will ALSO need to change the settings by clicking on the texture inside the material and editing them on the left hand side in the details panel. Make sure that EVERY texture is set as wrap inside the material and inside the texture itself. This is very important and will otherwise limit you to the use of 6 textures at most within the material.
- Additionally, to push the visual quality of the landscape we have tessellation enabled. This allows us to create a really integrated look and bring the surface of the landscape to life. I generally find that good use of tessellation and roughness can really break up the repetitive look of landscape materials.The tessellation set up within the material uses the following settings.
- Once you've set up several material layers in the landscape material, right click on it in your content browser and create a Material Instance. Then assign the MI to your landscape. If you open up the MI, you'll find each layer is separated out into groups and you can quickly throw in new textures to create new materials - as well as adjust a myriad of settings per material layer. See image 01 and 02.
The material that I just took from Mixer to UE4 is called dune_sand. You can see it in-action here.
I'll flesh this out more if people have questions. There's more advanced functionality here that we don't use - such as height blending or assigning material based on slope angle. We personally have adjusted our material to suit our exact use, but once you get a basic material underway you can quickly change the function of individual layers to suit your own needs.
When iterating out the materials, I always use unlit mode to check and make sure the darkness, brightness and saturation sits comfortably together. It's an old trick but it really helps you establish a balanced look across all the lighting conditions. I also recommend that when creating real-life locations you collect as much reference as possible and try and colour match in-engine. In the material we've set up there are controls for every material and texture that allow us to quickly iterate the look as fast as possible. You really don't want to have to touch the master material ever once you've created it as the shader rebuilds can be immense depending on your map size.
In addition, the landscape material will only be able to take you so far towards a great environment look. Something that always helps is adding variation through the use of decals (puddles) and mesh decals (tracks). The mesh decals can be placed via landscape spline which is about as close to a proper road tool as UE4 gets. I'd also recommend using the unlit mode as a constant way of checking how any added 3d assets sit within the world, and also continually check the relative scales of every model you bring in - as it will drastically effect whether or not the environment feels convincing.
Please ask any questions you may have below - I'd be happy to answer them!
Here is a link to the whole IMGUR album - complete with more images of the material in action.
Posted May 8, 2019, 9:20 AM UTC · edited
> NEVER use the alpha channel in a texture, as it will end up costing 3 x the total texture memory than one entire texture and is never efficient.
Thank you for this, I was wondering why nobody used this in pngs and I felt really smart having used them, but now that I know this I'll need to rethink my strategies.
Glad it helps! It's one of those small counter-intuitive nuances that really need to be explicitly stated.
[deleted]
This is due to different texture compression methods, 3 channels will be compressed with DXT1 (8:1) while adding an alpha channel will result in the use of DXT5 (4:1).
It's related to DirectX, not UE4.
Here you can find a comparison table: https://docs.unrealengine.com/en-us/Engine/Content/Types/Textures/SupportAndSettings
Note however, that if you use alpha, that channel would receive the most memory and thus least quality degradation (its a lossy compression). The texture is stored as R5G6B5A8, with 8bits in the alpha channel, as opposed to 6 in G and 5 in R and B, respectively.
Sometimes it can be justified to use that channel for masks that could benefit from the quality increase.
Also, if packing your textures into 3 channels rather than 4 results in using more texture samples in your shader (e.g. you now have 2 textures instead of 1 in your material), your memory savings come at a shader performance cost. It's always something to keep in mind.
Btw. the green channel has a higher memory allocation than the red and blue channels regardless of which of those 2 compression methods are being used, it is therefore recommended to use it for your most detailed mask (usually roughness) as the information will be stored as 6 bits instead of the 5 in RB.
[deleted]
Thanks for the brilliant reply. I was digging up the documentation in reply and saw that you'd beaten me to it! As you've identified, it's always a balance of pros vs cons - I'm sure someone somewhere will find use for the alpha channel.
I thought it was at most 2x (the same as another RGB texture)? I recall reading that from an Epic employee on the forums. Also Epic themselves use packed alphas in some of their example projects. And is commonly done if you don’t have 2 other channels to pack a separate packed texture with. It’s far more convenient when you have say 1000 assets all packed that way.
Here's a snippet from some design documents
https://i.gyazo.com/b9cdf8b681edd1effae69188e8d16b20.png
Configurations
(2k) DXT1 + DXT5 = 7.99MB (7 total channels)
(2k) DXT5 + DXT5 = 10.66MB (8 total channels)
(2k) DXT1 + DXT1 + DXT1 = 7.98MB (9 total channels)
*DXT5 being a texture that contains an 8bit alpha