October 15, 2018
In this tutorial we'll go over how to utilize Megascans assets in Renderman, Megascans provide high-quality geometry and texture maps from real-world scans - they're captured in a way to provide consistent output which makes them really useful to setup a single all-purpose shading network which can be re-used via RenderMan's Preset Browser.
At lot of these concepts aren't specific to Megascans maps and geometry, a lot of this is fundamental look-development setup which works for any source of map and geometry your working from. I'm approaching this from a very asset-centric workflow where you model and texture the assets individually then pull them in together to build your scene.
Megascans provide free samples of their scans to give you example of what their like, head on over to https://megascans.se/library/free to download them. I'm using the Rock Sandstone and Soil Clay examples here.
The first thing you'll notice is your given a range of options for your download, these options cover the resolution of the maps and geometry, the type of rendering your wanting to do (real-time vs offline) and how you want to deal with specular colour (specular/metalness) and specular roughness (roughness/glossy).
I've gone for the above options. There isn't necessarily a correct set of options here - it largely comes down to how you like to work and how you use the maps. There is more details on what the maps are in the Megascan FAQ
This largely seems to determine whether you want to use Displacement or Normal maps. Here I went with Offline as it provided both Normal, Displacement and Bump maps. I wanted to try all three out.
The displacement maps provided in the free samples are 8-bit JPG files - this can cause "stair-stepping" artifacts. It looks like the paid-for samples come as 32-bit EXR files.
Whether to use Displacement, Normals or Bump is largely up to what you want to do, each have there benefits.
There is the potential to use all three at once, displacement to do low frequency geometry changes with normals/bump to do high frequency details.
I saw this as presenting the following questions "do you want a map that is ready to use?" or "do you want a map that is good for flexibility?"
I went with Specular on this one, although having the Cavity map provided with a Metalness workflow would be handy to have around.
These is largely personal preference here as these are the inverse of each other, I find it it easier to talk about how material properties in terms of how "rough or smooth" it is rather than how "glossy" it is.
In order to get consistent shading it's really important to make sure your adjusting your material properties in scene where your not constantly changing the lights and cameras.
My setup typically includes the following...
The really important part about this is once it's all setup, the only thing you then modify is the shading network - you avoid touching the geometry, camera and lighting as best you can.
If you want to get started straight away, the following connections will get you most of the way there.
Although to help you make adjustments and tweak your work here are a couple of useful things to setup in your shading network. The network I've come up with looks like this...
To have greater control over the the Diffuse contribution. It helps to have include a few additional patterns to allow for easy tweaking.
I found the original saturation of the albedo maps slightly over-saturated, so toned most of them down to a saturation value of 0.67 by default. In the example below I've set the rock and clay to the same adjusted saturation, although I'd probably increase the saturation back up on the clay.
The following example shows the use of PxrMix to switch between the texture map and a constant grey colour. You'll notice it's much easier to see the specular highlights without the diffuse albedo.
For the specular controls I do a very similar network, although I replace the PxrHSL with a PxrRemap.
On PxrSurface I prefer Specular Fresnel Mode set to Physical and Specular Model under advanced to GGX. Setting the fresnel using an Index of Refraction value has become intuitive for me and GGX produces nicer specular tail which matches up pretty closely with photographic reference.
The specular section of the shading network looks like this.
Using a PxrRemap to tweak the Specular Roughness, by default the values in a) the original roughness map are too rough and produce b) a render which produces no smooth reflections, lifting the input min value to 0.8 produces c) which provides more contrast in the roughness map resulting in d) which contains a mix of rough and smooth reflections.
To find your specular roughness values, it oftens helps to output a "wedge" which animates the specular roughness from 0 to 1 across several frames. You can then use this image sequence to help figure out the range of values you want use for your specular roughness map.
Setting up the displacement was the easiest to setup in terms of shading network and then the trickiest thing to figure out about what encoding was used for the displacement. Each of the sample displacement maps I had seem to work differently, despite the Megascans FAQ pointing out the following values should be used White = 10 cm, Gray = 0 cm and Black = -10 cm. The network itself looks like this in the node graph.
The settings I used for the clay ground looked like this...
The PxrDispTransform was the tough bit to get the settings right, going off the Megascans FAQ, the displacement height-depth should have been 10-10 and remapping set to centred. For all of the free samples I found two settings that generally worked well.
The normals setup I used looked like this:
In a production environment it's often really helpful to provide additional AOV passes to the compositing team in order to allow them to fine tune the composite - these passes go by lots of names - I've heard them called 'helpers', 'utilities', 'secondaries', 'isolates' or more commonly 'AOVs' (A-O-Vees), which stands for Arbitrary Output Variables.
To set this up in Renderman requires two steps. The first is to create a PxrMatteID pattern and connect up your texture inputs into it. Then the PxrMatteID.resultAOV is connected to the PxrSurface.utilityPattern.
You may have noticed I've not connected up anything to Matte Texture 0 in the node graph yet I've set Matte ID 0 as an attribute to green. This is a constant colour ID based on the geometry. The end result looks something like this...
The magenta colour represents that the input texture is missing and not available - this is useful for debugging, as it's much easier to spot a bright magenta colour than a black colour.
Once I was happy with my shading network I wanted to create a material that I could quite simply re-use again and again without having to rebuild each time. To do that, I removed any asset specific parameters I had set (texture paths, saturation, displacement, etc) and set my PxrMix pattern so they read in a constant value rather than a textured value. This means my Megascan material will by default render as a grey plastic material, so in order to set it up for rendering properly I have to point it to the right textures and then switch the PxrMix patterns to read the textured value.