Intro
The purpose of this post is to show off a system of optimizations that have been done to the Quixel Megascan materials and a couple tweaks done that have given them, in my opinion, a slightly more realistic and detailed look while using less resources in Unreal. Huge credit to Ben Cloward for the idea of this pipeline and his Youtube Tutorials.
Concept
The first idea for this system came from reducing the number of textures used in the Megascan assets as they use three textures to create their materials in Unreal. These 3 textures are formatted in a widely used industry standard format with individual textures for color and normal and combined textures for ambient occlusion, roughness, and displacement in the R, G, and B channels.
However, this process only uses two textures, achieving seemingly the same results, and it even takes advantage of an extra underused channel in Unreal: Specular. This pipeline saves on game and project file size, load times, shader instructions, and just makes textures in projects more organized.
Process/Pipeline
What is needed first from Megascans are six maps: albedo, roughness, displacement, normal, cavity, and AO. You can access all these extra textures from the material download options in the Quixel Bridge app.
Next comes the texture magic. For this, I will be using Substance Designer, but you can also use Photoshop or any app that can access photo RGBA channels. The roughness is stored in the alpha channel of the albedo texture to create the BCR texture. Next comes the normal map; the blue channel is masked, and only the red and green channels are carried over to the RGBA merge. The cavity map is then multiplied by the AO map and plugged into the blue channel. This just gives the AO some more pop, but this will also be used later in the Unreal Master Material. Finally, the displacement map is put into the alpha channel to complete the NAOH texture.
Now that the two textures are created, they need to actually be usable in Unreal. Here is the master material I put together to show how this works. From looking at it, you can see most of it actually takes place in the material function, so let's take a look at that first. I created this material function so it would be easy to throw the function into any master materials in the project.
First, the alpha channel is masked from the RGB channels in the BCR texture and split up as two separate outputs, which is easy enough. Next is the NAOH map, and it starts by masking the R and G channels. Remember how the blue channel was cut from the normal map? Well, now it is going to be recalculated with some quick vector math, mainly normalizing the two values to get the blue channel back. Then B is masked from the NAOH, some more quick math is done, adjusting some values to get the right AO, and this is also where the specular is calculated. Finally, the height channel is taken from the alpha. Height is technically optional, but it can be useful for material blending, or it can just be replaced with a metallic map if your material has metallic properties.
*(Side note: the compression settings on the NAOH textures are set to BC7, also make sure to turn of SRGB. Recalculating the blue channel of a normal map does lose some quality but the difference seems negligible)
Results
The reason the specular map is added here is just because it can be; you can easily derive it from the AO/Cavity combo texture. It just adds that extra pop and lighting detail that most realistic materials are missing. I think the results speak for themselves.
*(Materials on the Left are default Megascans. Materials on the Right are the BCR_NAOH pipeline)
P.S.
After seeing some discussion online I have learned that this method is definitely not a replacement for the industry standard if you are striving for realism in your game. It's not that it's unusable for realistic games, but I see the value in the argument that the full Normal map is more important to have in some cases in order to preserve quality. However, if your game is more stylized or if you don't notice a difference between the two, I think that this could be a really good optimization solution.