Improve Your Organic Textures With a Cavity Map
In this article, I’m going to share with you a cool technique to create a cavity map in Mudbox and Zbrush that can be super helpful for your organic texturing/shading process. It is also considered an Auxiliary Map along with the Ambient Occlusion map and Curvature Mask.
There are many other ways to extract a cavity map, using renderers, Mighty Bake, etc. But for this tutorial I'll only focus on Zbrush and Mudbox, since these are the methods I am more familiar with.
The model used in this tutorial was sculpted by my talented friend Daniel S. Rodrigues. We did this collab project back in school called The Southern Cassowary. You can check the final result on the link below:
And if you have missed my latest articles and tutorials, check out this page! I hope you enjoy the reading.
Are you ready? Let’s go:
What is and Why do I Need a Cavity Map?
Cavity maps are essentially a black and white mask which will give you access to crevices and high-frequency details on your model. As you will notice when we are baking the map in Mudbox, the cavity map is an Ambient Occlusion operation, but with a “sharper” and darker look into holes and recesses.
The Cavity Map can be handy if you have an organic sculpt and you want to mask pores or other similar details. You can also blend it on top of your diffuse to add more complexity to your textures.
Keep in mind that these techniques I’m going to showcase are focused on VFX assets which have UV's. So before you start make sure to check if your asset has proper UV's otherwise you might have problems.
Using Mudbox
Pros
- Clean map
- Not a lot of options (which will also be a con)
- Simple to use
Cons
- Naming Convention
- Not a lot of options
1 - Import your mesh
Open Mudbox and import your HIGH RES geometry.
2 - Rebuild Your Mesh Subdivisions
Click on “Rebuild subdivision levels” like the image below so you can have multiple subdivision levels in your mesh.
If this process works, you will be able to see all the subdivision levels on your mesh.
Common errors: Sometimes this option doesn’t work properly because Mudbox is sensitive to mesh errors. But don’t worry, if that’s your case, simply bring the same mesh with a lower resolution and you’ll be okay.
3 - Extracting
Go to UV’s & Maps > Extract Texture Maps > New Operation.
Choose Ambient Occlusion Map. Here you can also name your extraction operations if you end up having more than one.
Okay, so this part might get a little bit confusing but don’t worry, I will try to get your head around this part without getting too technical. After a ton of experiments, these are the setting that I’ve been for almost everything.
On the screenshot below I highlighted the areas that you should pay more attention while adjusting your settings.
1 - Here you can add your LOW res mesh or the lowest level of your HIGH res. (If you rebuilt the subdivision level on step 01 it will give you a few options)
2 - Add your HIGH res mesh.
3 - Change your quality to Best and your method to Subdivision.
4 - On Image Properties, just make choose to select the resolution you desire. In this case I choose 4K just for the sake of this tutorial, but it is up to you.
5 - Here’s where the magic happens. The only option that I modify is the filter. The default option is 0.01, but to force the AO map get into the crevices, we are going to lower the filter to something around 0.000001. You can play with this value and see if you can get different outcomes.
6 - The final step is to choose your bit depth and your output folder. I usually keep it simple and choose 16-bit RGBA TIFF maps as my output. You can also keep the “Preview as diffuse” option checked so you can see how the map looks like in Mudbox.
If your mesh doesn’t have any problems, you should get a window like the ones below.
And if you have selected the “Preview as diffuse” option, you will see a preview of your map like this one:
Now you are ready to go! If you want to use this map in MARI, you will have to rename it manually to UDIMs; or you can use this awesome renaming method created by my friend Jens Kafitz.
Using Zbrush - Method 01 - Multi Map Exporter
Pros
- Fast
- If you’re gonna be painting in MARI, it gives an exporting to change the extension to UDIM.
- Simple
Cons
- Hard to predict the output
1 - Import Your Mesh and Add Subdivisions
Import your mesh into Zbrush. Make sure it has enough subdivisions (4 million polys or more)
2 - Multi-Map Settings
Go to Zplugin > Multi-Map Exporter.
On the screenshot below I highlighted the areas that you should pay more attention while adjusting your settings.
1 - Check the Cavity Option
2 - Select the desired resolution
3 - Here you can find the main settings for your Ambient Occlusion. The settings above are the ones I usually use, but it takes a lot of trial and error. Below you can see the information from the Zbrush Documentation website
Cavity Blur: Higher Cavity Blur values will soften the cavity map effect.
Cavity Int: Higher Cavity Intensity values give a harder edge and greater contrast. Negative values will give an inverted map.
Use Curve All SubTools: The Cavity Curve for the current subtool will be used on all visible subtools. Only applies If the ‘SubTools’ option is on.
16Bit: When on a 16 bit single channel file will be exported; when off the file will be 8 bit with 3 channels.
Colors: When on, the Cavity map will be generated using the main and secondary colors in the Color palette(only available as an 8 bit file). Turn off for black and white.
4 - Click on File Names and choose your UV tile ID format
5 - When you’re done, click on create all maps to extract your map.
Using Zbrush - Method 02 - Texture From Polypaint
Pros
- Fast
- If you’re going to be painting in MARI, it gives an exporting to change the extension to UDIM.
- A lot of control over your output
- You can see your map before exporting it
- More options than the other two methods
Cons
- More options than the other two methods
1 - Import Your Mesh and Add Subdivisions
The first step to this tutorial is to import your mesh into Zbrush and add a few levels of detail. The amount of subdivisions will vary from asset to asset and you’ll know if it’s enough when you see that your mask/model isn’t faceted.
2 - Change Your Render Mode to Flat
This step will allow you to preview your mask accurately without any light/shadow information.
3 - Masking
Go to Tool> Masking > Masking by Cavity. Here’s where the magic happens.
As you can see, one of the greatest things about this method is the fact that you have a lot of control over your map. It might be confusing for some people, so if you want understand what these settings do, here’s a quick explanation from Zbrush Docs:
Blur - The Blur slider will apply a blur to the cavity mask. By setting the slider to 100 the cavity masking will be softened. To best view cavity masking, set Preferences>Edit>Masked Object Dimming to 5 and change the material to Flat Color.
Intensity - The Intensity slider creates a harder edge around the cavities. Negative values will invert the Cavity Mask.
Cavity Profile - The Cavity Profile curve controls how the cavities on the mesh are masked. The left side of the curve is the base of the cavities, the right side is the surface. The dark area of the curve is the masked area and the light area is unmasked.
With that in mind adjust the values accordingly and press Mask by Cavity.
If you followed the steps correctly, you should see something similar to the image above. The mask preview is surprisingly fast and accurate. Now we can start adjusting our mask.
4 - Editing your mask
By default, the mask by smoothness already give us a great map, but luckily we can go even further and get a better result. On top of the masking tab, you can see a variety of options to adjust your mask. You can use blur, grow, sharpen and shrink to get a result that suits your needs. Go ahead and test each one.
Another great thing about this method is the fact we can invert the mask before exporting it.
5 - Filling Your Mask with Colors
When you’re finally happy with your mask, it is time to bake colors onto the mesh so we can export it later. With your mask selected, invert it so the white area can receive the color and go to the Color menu and change your color to Black and press Fill Object.
Now clear your mask and you’ll see that your mask is now a texture baked into your geometry, ready for export.
6 - Exporting the Cavity Map
If your mask result looks similar to mine, you’re ready to export your map. Go to Zplugin > Multi-Map Exporter and select Texture From Polypaint. This step is very similar to the second extracting method we tried before.
Press OK and click on Create All Maps. Select your output directory, and you’re ready to go, and don’t forget to change your extension name to UDIM’s.
Being Creative With Your Mask
While baking your map, keep in mind that you don’t have to use just one option. When I’m working on my textures, I usually like to export two or three different masks.Since the baking process doesn’t take too long, I benefit from that to create multiple versions which can be very helpful later on.
How to Use a Cavity Mask?
Like I mentioned above, the cavity map can be especially useful when you are working with organic models. If you have a good sculpt, you’ll be able to have access to pores and crevices without effort.
Having the mask can help you improve your dirt mask, like the one shown below:
Or you can overlay it on top of your diffuse channel, giving a more interesting look and enhancing your colors with details from your sculpt.
Another great use of a cavity map is to apply it to your rough/gloss maps. It can give you a nice highlight breakup in the recessed areas.
That being said, it doesn’t mean you can’t use it for hard-surface objects. If you have a piece which has a sculpt pass on it and you want to get into cuts and scratches, the cavity can come in handy there as well.
Final Thoughts
I hope you found this article useful. This technique can be used in so many ways, and I'm excited to see how you guys are going to use it! Please send me a message if you used it creatively or if you need any help with the process.
I want to keep sharing things that I’ve learned in the past two years that I’ve been in the VFX industry. If you enjoyed reading this article, don't forget to share it with your friends. And if you are interested in more content like that in the future, make sure to follow me on social media!
Do you have any suggestion for my next articles? Write your comment below and let me know what you are interested to learn about the VFX industry.
I'll be happy to spread the knowledge!