Hey everyone! In this dev diary we want to share with you one of our workflows to texture our worlds using Quixel's Megascans and integrating it with Unreal Engine!
What are Megascans?
Megascans is a service provided by Quixel to access a huge library of photo scanned materials. We have been using Quixel for quite some time and we absolutely love everything about it!
We start off by downloading the material we wish in our library. The great thing about this service is that once you purchase the material you can download it forever even if you are no longer a subscriber.
Once you download the material, Megascans Bridge will automatically detect the file and add it to your computer library.
After that, you can export the textures to any program you wish to use. In this case we are using Unreal Engine. The good thing about it, is that it will automatically calibrate the textures which is very important when working with Physically Based Rendering.
We just need to import the textures to Unreal Engine. For our workflow, we are using 3 textures for each material: albedo, mask and normals. The mask stores grayscales textures in each channel, in our case we are storing: roughness, displacement and ambient occlusion. Note that the mask compression settings need to be "Mask" in order to get all the values accurately.
Material libraries are super important in game development. They provide a non destructive workflow, fast iterations and can add incredibly amount of detail to your models. They are basically materials stored as Material Functions which you can then drag and drop into a Material and blend them with other materials.
CREATING THE MATERIAL FUNCTION
The materials should be really simple because it can scale up really quickly when you put more materials on top on another. Like your typical material we will connect the texture inputs to their respective channels but we will take care of some stuff that will be useful to us in the long run.
This material connects all the texture inputs into their respective channels but have some useful UV tiling system that we will use for all the models we create in our game.
We just need to use the Object Radius to detect the size of our model. This will take care of the texel density of the 3d model regardless if it's too big or too small. Since we don't want to deal with decimals, we just want to divide it by a number to make the Tiling input a little more user friendly.
The rest of the material looks like this:
We could get more complex but like we stated above, we want to keep it simple. We just want 2 inputs: The material and the displacement mask. As for the albedo,, we want to tint it in case we want to change the color later. One thing to keep in mind is that we are using a Constant Clamp to assure that the values don't go below 0 or above 1. This will make sure that the material properties don't break the energy conservation which is very important to achieve realistic materials.
After creating some materials and importing some textures from Megascans you can build a library like this:
The next step is to create our master material to apply it to our models.
The great thing about working with material libraries, is that we just can drag and drop them into our material and we can blend them between other materials! For instance we can just create 2 materials just by creating some inputs.
After that, is just a matter of creating a blend between those materials and use the vertex colors of the model to blend between those using Layered Materials.
Let's apply it to a simple sphere and see how it looks like.
The texture will tile depending on the object radius, so we won't see that much pixels even if we zoom in really close. You can always add Detail Texturing, if you wish to know more about it you can read more on our Optimization article.
After that is just a matter of paint the vertex colors using Mesh Paint Mode. After doing the same process with all the materials you wish to blend, you can create some cool materials and have the illusion of really complex surfaces even on simple models!
That's it for this article we hope you find it useful and apply this technique to your projects! If you have any questions don't hesitate to reach out to us in the comments!