Displacment maps. Maya. Combined, the two words sends shivers down the spine of any CG artist. It’s a topic I’ve spent countless hours trying to wrap my head around. In this tutorial we’ll look at a reliable way to use 32 bit displacement maps in Vray for Maya generated in ZBrush. The advantages of using a 32 bit map vs a 8 0r 16 bit are two in particular:
- You dont have to worry about fiddling with the displacement amount, as long as your Zbrush and Maya model are the same size. with 32 bit maps, the displacement amount will replicate your Zbrush model as closely as it can automatically.
- You have significantly more data to work with so your displacement will be more accurate and will contain more information.
I’ll assume you know the difference between a normal, bump and displacement map, and why a displacement map is necessary. If not, you have some googling to do.
Let’s get started.
Here is the mesh in Zbrush which I want to transfer to Vray. It has been retopologized to make sure that the topology is good, and it has UVs with little to no stretching. It’s extremely important that your UV map is good, otherwise you’re going to see nasty artifacts and stretching in the render once you apply your maps.
We’re going to use Multi Map Exporter (MME), which is a relative recent plugin in ZBrush. You can find it under Zplugin in your top menu. This is your friend and you should know it well. Before we had this thing of beauty, we had to export every map manually, which is a tedious process. With the MME, you can export several maps at the same time where you have more control over them.
It also supports multiple UV tiles. This is a huge thing when you’re working in a production and your UVs are laid out over several tiles. Traditionally, multiple tiles are hard and convoluted to work with in ZBrush, so this is wonderful.
Open the plugin up and you should hopefully not be too overwhelmed by the wall of text and buttons. Check Displacement in the very top. Here you can adjust your size, export map for all visible subtools, et cetera. Set the size to whatever you need, in my case I need a 2k map. Enable Flip V which will flip the maps vertically, which you always have to do in Zbrush due to some weird voodoo by Pixologic.
Next, hit the friendly looking button which says Export Options. This is where the options for the various maps can be found. You want to click Displacement to bring up the options for the displacement map.
Now we have a couple of settings which we need to know about
SubDiv Level: This dictates which subD level the displacement map will be generated from. You normally want this set to 1 as the displacement will then be generated from the lowest level, meaning that the map will have the difference between the lowest and highest level. This overrides the current subD level your model is currently in, which means that if your model is set to level 5 and your SubDiv is set to level 1, then the map will be generated from level 1. I sometimes use this to make bump maps. If I set my SubDiv level to 4 out of 6, the displacement generated will only include the finer details, so it can be used as a bump.
Adaptive: If pressed, the map will be of higher quality, but it will take longer to generate. I always have this on when exporting a final displacement. I leave it unchecked when doing tests.
DpSubPix: Now this is an interesting one. Initially I thought this was only a quality slider, where 0 was the worst and 4 was the best. It’s not. This is what Matthew Yetter from Pixologic writes about it.
This is most likely unnecessary and is definitely a significant drain on resources. DPSubPix is mostly a dinosaur, held over from when ZBrush couldn’t handle models in the 10′s of millions of polygons. What that slider does is to virtually subdivide the model a number of times equal to the slider setting before then creating the map. Its purpose is to let you create a larger map than what your current number of polys would allow.
A 1 million poly mesh is ~ equal to a 1K texture map. If you want a 4K map, that would mean that you’d get a lot of artifacting caused by interpolation while the map is being created. You’d want to divide the model twice to bring it to 16 million polys, which is ~ equal to the number of pixels in a 4K map. In ZBrush 2, you couldn’t get to 16 million polys so you’d use a DPSubPix value of 2 and get a nice, clean map. With ZBrush 4.x you CAN hit that many polys easily and so you can subdivide the model yourself, do some more detailing and then create the displacement map without DPSubPix.
Now if you have a 20 million poly model and you’re using a DPSubPix value of 4, guess what happens? You’re telling ZBrush to first calculate over 5 billion polygons and then create the maps. Even just a DPSubPix value of 1 is enough to hit 80 million polys. Not only will it make most any computer puke, it’s also calculating WAY more data than the displacement map could possibly hold.”
The TL;DR version? Disable it. It takes A LOT longer to extract the map. One test I did took 23 seconds with it disabled and 5 minutes with it set to 4. The quality was identical.
Smooth UV: This will smooth your UV, as you might have guessed. Might or might not be preferable, depending on your project. If unpressed, your UVs will be rigid, which might be what you want. If you want to have your uvs rigid, make sure that the UVs in Maya aren’t being smoothed. You can change the UV interpolation under the shape node of the object in maya – Smooth Mesh- Extra Control and uncheck Smooth UVs and change Map Borders to Do not Smooth
Mid: This is the mid range for the displacement. When using 32 bit maps, you want your mid range to be set to 0. By default the mid range will be 0.5, meaning 50% grey, which makes no sense when using 32 bit images.
3 Channels: Will give the displacement information in all channels instead of just the red one. Enable this.
32 Bit: Enable this. Otherwise you cant get a 32 bit map.
Scale: Don’t touch this.
Intensity: Don’t touch. There is a way where you can use the intensity with 32 bit maps, but frankly, there’s no need to do so.
16 Bit Scale: Only relevant when using 16 bit maps.
Get scale: Can be handy, but don’t touch this for this particular workflow.
Now hit Create All Maps and chose the directory you want to save it to. You can only create Tiff files, but they should provide you with sufficient data. Give it a couple of minutes and you should be set. As a general rule, I never touch the computer while Zbrush is calculating. Sometimes it freezes and crashes when you touch it.
Leave the ZBrush window active while the maps are being generated. This will make the maps generate faster, according to the developer of MME. It will generate regardless of ZBrush being the active window, but it will slow down if you Alt+Tab to something else.
Export your base mesh at the level you want, preferably the lowest one. The only thing you have to change before you export is to go under Tool – Export and make sure that Grp is unchecked. If this is checked, then ZBrush will try to export your polygroups, which will result in a mesh which has been split into several parts completely at random.
There are two directions we can go with displacement, both of which have pros and cons. However, you should know how to do both. The first one will be based on applying the displacement map to the shading group of the material. The advantage to this is that if you export your shader to another scene, the displacement map will follow. However, it’s based on the shader, so if you decide to make some additional passes where you have to assign different shaders to it, the displacement map will not follow. This can be a huge issue if you don’t remember to re-assign it.
The other way of doing it is to assign the displacement map on an object basis. This is really handy, as you can then make additional passes on the fly without worrying about the displacement following. You can also apply a single displacement map to multiple objects, independent of their material. I’ll go through both ways. Personally I prefer doing it this way, as I have far more control over my displacement.
Whenever you’re testing out things like displacement for the first time, do it in a clean scene. This makes it so much easier to debug and analyze what’s happening if it’s not working.
Make a new scene and import your base geo and name it. Change your render engine to Vray and make sure that Displacement is enabled under Vray – Global Options – Displacement. Disable Render Viewport Subdivisions. Also, make sure that GI is disabled when testing displacements, as that’s adding to your render time.
Give your model a new material. I’m assigning a Vray Material to it.
The Shader Way (i.e the bad way)
Now go to the shading group of the material, go to the displacement port, assign a file node and find your freshly made displacement map. Sometimes Maya wont load the Tiff file for some reason. The fix here is to take it into Photoshop and changing it to RBG from Greyscale under Image – Mode – RGB Color. Also change the compression to LZW.
Before you can start to render and see if your displacement is working, you need to add a light. I’m using a vray rect light. As a pro-tip, never scale your vray lights. Use the U and V size in the attribute editor. If you scale them, they wont work as expected.
This is what my model looks like at this point, after a quick render. Definitely not there yet, but you can see that it’s doing something.
Go to your shape node on the model you want to displace – Attributes – Vray – Subdivision and Subdivision and Displacement Control
The Edge Length is a quality control. The lower it is, the higher the quality, and higher the render time. By default it’s set to 4, but you might want to set it to 2. Max subdivs is how many times your model should be subdivided. If my model is subdivided 5 times in Zbrush, I prefer setting the Max subdivs one level higher, meaning 6 here.
This is what our model looks like. Almost there!
We now have to add a Allow Negative Colors as well on the shape node.
The last thing we have to do is to go under the file node for our displacement texture – Color Balance and check Alpha is Luminance.
If you dont see anything at this point, the issue is probably scale. A 32 bit map is based on the scale and if the model now is significantly bigger than the ZBrush model was, you’re not going to see it at all. Sometimes you have to changer the scale for whatever reason and this WILL cause problems with the displacement. The fix is simple though: For the displacement file node, set the Alpha Gain to the number you’ve scaled the model with. For instance, if you’ve scaled the model 100 times, you set the Alpha Gain to 100.
The Object Way (i.e the good way)
Apologies for using a different model for this example; I’m writing this months later than the first way and I don’t have the source file available. Anyway, moving on.
This is that the model looks like without any displacement.
This method revolves around using the VRayDisplacement node. It can be found under Create- V-Ray – V-Ray Displacement - Single vrayDisplacement node to selection. Select your model and apply the displacement node.
You’re now going to see a vrayDisplacement node in the Outliner.
Now we have to apply the image map to the displacement node. This is very easy to do.
The first step here is to make a file node in the Hypershade. Give the node an appropriate name. This might seem redundant, but you’ll thank your former self later when you start to get a lot of nodes.
Select your texture.
Now go to the beautiful vrayDisplacement node in the Outliner. Here you’re going to see an empty Displacement Mat. slot. This is where you pipe in your file node with the texture map. Drag it from the Hypershade while holding down the MMB into the displacement mat. slot.
This is what the model looks at this stage. As you can see, something is very wrong. It appears that it’s only using the positive values of the map and not the negative ones.
To fix this, go to your file node – Attributes -VRay – Allow negative colors. This will allow Vray to use values below zero, which we are doing. Remember how our Mid Value from ZBrush was set to Zero? This is where this becomes important.
Nearly there now. Visually it looks just fine now, but under the hood there are still some things we need to change. Go to your vrayDisplacment node in the Outliner. Attributes – Vray and enable the following check boxes. This allows you to control your displacement in an accurate manner.
These are the settings I normally chose. What you should be aware of:
Displacement Amount: This is the strength of the displacement. If you’ve scaled your model 10 times up, you set this to 10. By default you shouldn’t change this though, as 32 bit maps have scale built in.
Filter Blur: Disable this. It blurs the texture.
Render as Subdivision Subsurface: Enable. This smooths the model.
Subdivide UVs: This depends heavily on which UV interpolation you’re using. In this case, my texture and displacement map were generated based on rigid uvs, meaning they dont smooth when you smooth the model.
Override Global Settings: It’s pretty self explanatory. It overrides any other displacement settings you might have enabled.
Edge Length: This is important. The edge length determines the quality of your displacement. Basically the smaller it is, the smaller the edges in the displacement will be, thus producing sharper details. In short, lower number = higher quality. By default it’s set to 4, but two will yield better results. Set it to 2 only for final renders though as it will increase render time.
Max Subdivs: This is how many times Vray will smooth the model. I normally set this number to the same amount of subvisions I have in ZBrush or one above. By default this is set to 264, which is ridiculous. This can seriously impact your render time, particularly if you have closeups.
And there we go! That’s how you successfully render a displacement map from Zbrush in Vray for Maya.
If you want a more in depth tutorial on exactly what a 32 bit map is, or just a variation on this tutorial, feel free to check out this excellent tutorial on the same subject, by Akin Bilgic.
If you have questions, corrections or general comments, feel free to email me at henning.sanden [at] gmail.com