ZBRUSH TO MAYA - 3D Links · PDF file3 1. Introduction Welcome to the ZPipeline ZBrush to Maya...

37
ZBrush To Maya 32-Bit Displacement Guide Scott Spencer November 10, 2005 © 2005 Pixologic, Inc. All rights reserved. Pixologic and the Pixologic logo, and ZBrush and the ZBrush logo, are registered trademarks of Pixologic, Inc. Photoshop is a registered trademark of Adobe Systems, Inc. Maya is a registered trademark of Alias, Inc. All other trademarks are the property of their respective owners. Please mail comments or suggestions about this document to [email protected].

Transcript of ZBRUSH TO MAYA - 3D Links · PDF file3 1. Introduction Welcome to the ZPipeline ZBrush to Maya...

ZBrush To Maya 32-Bit Displacement Guide

Scott Spencer

November 10, 2005

© 2005 Pixologic, Inc. All rights reserved.

Pixologic and the Pixologic logo, and ZBrush and the ZBrush logo, are registered trademarks of Pixologic, Inc.

Photoshop is a registered trademark of Adobe Systems, Inc.

Maya is a registered trademark of Alias, Inc.

All other trademarks are the property of their respective owners.

Please mail comments or suggestions about this document to [email protected].

2

1. INTRODUCTION ....................................................................................................................................... 3 2. MAYA MODEL PREP............................................................................................................................... 3

2.1. MODEL REQUIREMENTS FOR ZBRUSH .................................................................................................. 4 2.1.1. Fixing Overlapping UVs ............................................................................................................... 4 2.1.2. Cleaning the Mesh Topology........................................................................................................ 6

2.2. EXPORTING FROM MAYA....................................................................................................................... 6 3. SCULPTING IN ZBRUSH ........................................................................................................................ 7

3.1. UV REGIONS AND POLYGROUPS ......................................................................................................... 10 3.2. FINAL UV ADJUSTMENTS AND VERTEX ORDER ................................................................................ 12

4. DISPLACEMENT MAPS AND THE ZBRUSH ALPHA DISPLACEMENT EXPORTER ....... 13 4.1. GENERATING A DISPLACEMENT MAP ................................................................................................. 14

4.1.1. Creating a comparison Image to check your Maya Renders ................................................... 17 5. BACK TO MAYA ..................................................................................................................................... 19

5.1. MAYA SETUP FOR RENDERING............................................................................................................ 19 5.2. CREATE .MAP FILES ............................................................................................................................. 21 5.3. RENDERING WITH A SINGLE MAP........................................................................................................ 21

5.3.1. Lighting and Test renders ........................................................................................................... 24 6. MULTIPLE DISPLACEMENT MAPS................................................................................................. 27

6.1. SETTING UP UV REGIONS IN MAYA.................................................................................................... 27 6.2. MAKING THE DISPLACEMENT MAPS IN ZBRUSH................................................................................ 29 6.3. APPLYING MULTIPLE DISPLACEMENT MAPS IN MAYA...................................................................... 30

7. BUMP AND DIFFUSE MAPS ................................................................................................................ 32 7.1. USING THE BUMP VIEWER MATERIAL. ............................................................................................... 32 7.2. APPLYING BUMP MAPS IN MAYA......................................................................................................... 34 7.3. CAVITY MAPS AND THE DIFFUSE CHANNEL....................................................................................... 35

3

1. Introduction Welcome to the ZPipeline ZBrush to Maya guide. In this manual Scott Spencer will guide your through a process of exporting your sculpt in ZBrush, for use in Maya with Mental Ray. Scott illustrates the processes he uses to work seamlessly between the two applications. This guide will focus on 32-bit displacement maps which enable real world displacement (no arbitrary scaling factors necessary) and produce the best possible results in achieving the look of your original ZBrush model.

2. Maya Model Prep If your model started as a mesh in Maya, begin by loading your model in the Maya workspace. We will need to export the geometry as a generic 3D format that ZBrush can read. Maya will export OBJ files for this purpose. The OBJ exporter is a plug-in which must be loaded. The mental Ray renderer is also a plug-in we will load at this stage so it will be available when needed.

Figure 1. Model Loaded Into Maya

To load the object exporter and the Mental Ray renderer go to Window>Settings and Preferences> Plug-in Manager. This will load the Plug-in Manager window as seen below. The OBJ plug-in is called objExport.mll and the Mental Ray plug-in is called

4

Mayatomr.mll. Click the loaded checkbox next to each to load them now, you may also want to click auto load so they are available every time Maya starts.

Figure 2. Plugin Manager Window

2.1. Model Requirements for ZBrush There are two requirements your model and UV map must require before they can be used in ZBrush:

The mesh may only have one UV set and the UVs may not overlap at all. Overlapping UVs will cause unexpected crashes when you are extracting your displacement map and they are easy to miss.

and

The model should consist of just quads and tris, with the tris being in well-hidden regions.

2.1.1. Fixing Overlapping UVs It is entirely possible to use ZBrush AUV tiles or other automatic options for our mapping but as you will see having UVs laid out in Maya will open up several workflow possibilities not otherwise available.

Here is an example of overlapping UVs in the toes of this model. This must be corrected before the displacement map may be extracted. Otherwise this small overlap could cause a crash.

5

Figure 3. Overlapping UVs in the Maya UV Editor Window

It is important to note that unless you are painting color maps ZBrush is not concerned with UV coordinates until you extract the displacement map. This leaves you free to model in ZBrush then lay out UVs later or change your UV layout without losing all the work you applied to your model. ZBrush also offers a tool to check for overlapping UVs under the tools palette, Tools:Texture:UV Check. Clicking this button will highlight in red on your model any overlapping UVs so you know where to look for errors back in Maya. When performing an inspection like this in ZBrush, make sure to rotate your model to view all surfaces.

It is also possible at this phase to place your UVs outside the 0 to 1 texture space. This will allow you to map your mesh in ZBrush for easy masking and hiding as well as allow you to maximize texture space and extract maps for each body part instead of a single map for the entire model. This is discussed in section 6.

Again, remember you are never locked into a UV set with ZBrush if you are just sculpting. You can import your OBJ at level one with any UV layout as long as the vertex order of the mesh remains unchanged. (Generally, this means that you can move points in the level one OBJ, but cannot add or remove points or edges, otherwise change the geometry of the model.) More information on vertex order can be found below.

Below is an acceptable layout, using the mesh with automatic mapping. The UV shells are all in the dark gray square, the 0 to 1 range. This will generate a single map in ZBrush that applies to the entire mesh. Later we’ll talk about how to spread the mapping across multiple meshes by mapping out side the 0 to 1 UV coordinate range.

6

Figure 4. UV Map with U and V Coordinates Each From 0 to 1

2.1.2. Cleaning the Mesh Topology The mesh needs to be clean. By clean I mean it should be all quads or at least nearly all quads. Avoid tris, poles (points where 5 edges or more meet) and n-gons (faces with more than 4 edges). If you find you must have a tri, hide it in an inconspicuous area. Leaving in any of the above elements may cause artifacts at render time. You also want to ensure your vertices are all welded and there are no nonmanifold or lamina faces. All of these mesh issues can be resolved with the cleanup tool. Go to the Polygons menu in the modeling subset and select the cleanup option box.

Figure 5. Opening the Cleanup Menu

This will open the Cleanup menu. If you set to Select and check only the 4-sided faces option box, Maya will select all the quads in your mesh. You can then use Edit>Invert Selection to select the non-quad faces. Often I will assign another color to these faces to keep them visible and keep working with the topology until I have an all quad mesh.

In the same cleanup menu choose the Select and Cleanup option and select Nonmanifold Geometry and Lamina faces. Click Cleanup and this will resolve any of these issues which often arise when modeling with the extrude tool. Cleaning up your mesh now can save a lot of headaches later on.

2.2. Exporting from Maya With the UVs and the topology ready you can now export the mesh from Maya. To export go to the File>Export selection option box and select the OBJ option from the drop

7

down menu. Click Export Selection and save the model. You are now ready to import the mesh into ZBrush as a Ztool.

Figure 6. Export Options

3. Sculpting in ZBrush Let’s begin by opening your Ztool in ZBrush. Models in ZBrush are defined as tools. If you are beginning with a mesh that was initially modeled in another application, import it as an OBJ file by using the Import button under the Tool menu.

Figure 7. Import Model Button In ZBrush

Now, click and drag on the canvas to draw your tool. Immediately go into edit mode to allow the tool to be edited as a 3D object; right click on the canvas to open the contextual menu and select the edit button or press the ‘t’ key on the keyboard or press the Edit button on the top part of the shelf.

With the tool in edit mode you are now able to tumble, add subdivision levels, and use any of ZBrush’s sculpting tools to detail your mesh.

8

ZBrush is a multi resolution editing tool, meaning that changes you make at the higher subdivision levels will telegraph back down to the lowest subdivision level, somewhat changing the shape of the original mesh. In some cases you may want to access your original mesh shape again; for example, you may want to generate a displacement map against the shape built in Maya, as opposed to the somewhat different level 1 shape that will result after sculpting in ZBrush. To do this, follow the instructions below.

On the other hand, after sculpting you can simply export the reshaped level 1 mesh from ZBrush and use that. Its geometry will be unchanged, only the shape will have been somewhat altered (and since that shape will be closer to the final sculpted shape, this may well be what you want to do).

To ensure you can return to the original Maya shape in ZBrush, after sculpting, store a morph target before you begin sculpting. Simply press Tool:Morph Target:StoreMT before you start modifying your model. After sculpting, you can use Tool:Morph Target:StoreMT to switch back to the original shape.

Figure 8. ‘StoreMT’ button in the Morph Target Subpalette

An alternative way of returning to the original Maya shape, which does not require storing a morph target, is simply to reload the Maya model after sculpting, as the level 1 mesh of your sculpted model. This will work as long as vertex ordering has not changed, which should be the case so long as you have not added or removed points or edges. The morph target method is generally preferred because some programs can, on occasion,

9

alter the order in which they write model vertices on export, even when the model has not changed at all.

Having a morph target stored is also helpful as it allows you use the morph brush at subdivision level 1 (Tool:Geometry:SDiv = 1) to dial back changes to the original form.

It is also important to note that using tools like the Transform:Nudge and Transform:Pinch brush will make changes to the mesh that will not necessarily translate well into the maps created when setting a DPSubPix value as opposed to those generated using Adaptive mode (these settings will be discussed in detail later). This is why, in many cases when using these tools on your mesh, it is beneficial to use the slightly shape-modified level 1 mesh for your base in Maya as opposed to the original morph target. The little vertex changes the multi-resolution editing makes at level one makes it easier to render their effects in Maya with a DPSubPix map. You may also use adaptive mode to create your map but as you will see later in the guide, DPSubPix mode and the level 1 mesh is a preferable approach. In any case always apply your displacement map to the geometry you generated it from in ZBrush1.

If your base mesh is already rigged and cannot be changed in Maya, export the ZBrush level 1 mesh as an OBJ import into your Maya scene, and add it as a parallel blendshape to reshape the original mesh to the Level 1 form exported from ZBrush.

Some workflow tips I use in ZBrush to help the sculpting process:

• Often I set the background of the document to black (using Document:Back, with black selected in the color palette). This helps me read silhouette as well as see shadows better.

• It also helps to choose Material:BasicMaterial as the material used to display the object, and turn down the Specular component of that material a bit. This gives a better idea of surface changes and helps call attention to errors in form that may be easier to miss in the flat fast shader.

1 It’s worth repeating what we said just a bit ago; if your displacement map must be generated for exactly the shape of the model as it came from Maya, return the level 1 ZBrush model to that shape either by restoring a level 1 morph target, or by reimporting the Maya mesh for the level 1 model, before generating the displacement map.

However, given that your sculpting presumably brought the shape of the model closer to the ideal shape, it is worth considering using the modified level 1 shape back in Maya.

10

Figure 9. Material Settings for a Clearer View of the Model

3.1. UV Regions and Polygroups If you laid out your UVs in Maya in regions, you can turn on polymesh groups and interactively hide parts of the mesh. Click Tools:Polygroups:Uv Groups, and then turn on frame mode by activating the Frame button in the shelf (or press Shift-F on the keyboard, or the Frame button in the Transform menu).

11

The areas of the mesh that are in separate UV coordinates will now have different colors assigned to them.

You can Ctrl-Shift-Click on these areas to hide or show them, allowing you easier access to tighter areas on the model, and increased performance at higher subdivision levels (since less of the mesh needs to be drawn).

TIP: Be aware that sculpting across the seam where the model is hidden will cause artifacts in your sculpture, since sculpting is only applied to the visible portion of the model. Use caution here. You may also group the mesh interactively in ZBrush by using the Group Visible button for use as simply a modeling and masking tool but UV groups offer better control over the groups and are easier to maintain.

Figure 10. Body fully visible, and then hidden by ctrl clicking on UV grouped regions

12

3.2. Final UV Adjustments and Vertex Order When your sculpting is complete you are now ready to export displacement maps. If you need to change your UVs this is the last chance to do so. The process to transfer a model from ZBrush to Maya and back to ZBrush seamlessly is as follows. The OBJ file may be moved endlessly between applications as long as the vertex order remains unchanged. (Vertex order is changed by cutting new faces, deleting faces, or reordering on import.) You may change UVs and vertex position without destroying your sculpture. This even includes reposing your mesh! Use the following process any time you transfer your model between Maya and ZBrush.

1. In ZBrush set Tool:Geometry:SDiv to 1. Export using Tool:Export. 2. Save the mesh as an OBJ file. 3. In Maya go to the File>Import option box and select OBJ for file type.

Make sure that Create Multiple Objects is set to False on this screen. If this is checked Maya will not preserve the point order and your model will not reimport into your ZBrush.

13

Figure 11. Maya Import Options

4. Make any positional or UV changes you want and export the OBJ again. 5. In ZBrush at Tool:Geometry:SDiv = 1, and with the tool corresponding to

your model selected, go to Tool:Import and select the new OBJ file. The UVs will automatically update to the ones in your new OBJ file.

4. Displacement Maps and the ZBrush Alpha Displacement Exporter

The new Alpha Displacement Exporter2 (abbeviation: ADE) plug-in permits exporting displacement maps in many formats. In addition, the Multi Displacement 2 (abbreviation:MD2) plugin, which is part of the ADE package, provides two important extra capabilities:

• When exporting 32-bit displacement maps with MD2, scaling will be ‘baked into’ the exported displacement maps, so you no longer need to record an alpha depth factor.

• And, MD2 allows the generation of multiple displacement maps, corresponding to multiple external objects, in a single pass.

Since we are rendering in Mental Ray for Maya, which supports 32 bit floating point displacements, we’ll use MD2 all the way. There is no reason to use 16 bits since the quality is lower than what we will achieve with 32 bits. However, there are some times when you might not want to use MD2, and below is a brief summary of the ways in which displacement maps may be generated in exported from ZBrush, and the advantages and disadvantages of each.

2 Available at www.ZBrushCentral.com.

14

Basically, you could choose any of the following methods for generating your displacement maps:

• Use MD2, as we’re doing here. This lets you generate multiple displacement maps in a single pass. Also, if your pipeline can make use of 32-bit displacement maps, using MD2 allows you to forget about using the alpha depth factor from ZBrush; you’ll always enter 2.2 for the Alpha Gain in Maya.

On the other hand, if you don’t need those abilities, using MD2 is a little more complicated, and it also doesn’t place generated displacement maps in the alpha inventory.

• The original method of generating displacement maps is to use the Tool:Displacement subpalette to generate the map and place it in the alpha inventory, then export that map and use it along with the alpha depth factor in your render. This doesn’t permit the higher-quality 32-bit maps, does require you to use the alpha depth factor, doesn’t permit multiple map generation in one go, and (with some external programs) may require converting the exported map into another format.

But, if you don’t want to or can’t use 32-bit maps, and generating maps one at a time is OK, then this is probably the simplest way to go.

• Finally, you can use the ADE without using MD2. This is very similar to the ‘classic’ method of making displacement maps (you’ll still use the controls in Tool:Displacement to generate them), except that you have a wide range of options as to the precise TIFF format in which they are exported, plus a number of other options.

Complete documentation on the ADE (and MD2) is included as a PDF in the ADE package.

As we go through the map generation, we’ll give the steps for using MD2, but mention a few points that apply if you don’t use MD2 in your pipeline.

4.1. Generating a Displacement Map First, let’s go back to our knowledge of the ‘old’ way of generating displacement maps, and take note of the following:

Maps generated with MD2 will be affected by the various settings in Tool:Displacement. In fact, some of the controls that appear in Tool:Displacement also appear in the Multi Displacement 2 controls. In particular, the Tool:Displacement:Adaptive setting (on or off) also affects displacement maps generated with Multi Displacement 2. If Adaptive is off, you should set the DpSubPix level in the MD2 menu, not in the Tool:Displacement menu. For my work, I use Adaptive off and DpSubPix = 2. Tool:Geometry:SmoothUV will also affect the final result.

15

OK, our model is all done in ZBrush and we’re ready to generate a displacement map. The Multi Displacement 2 plugin is found under the Zplugin menu, as shown below:

Figure 12. Multi Displacement 2 Plugin

Here’s how to use it.

1. First, adjust the settings according to the following (this is to generate a single displacement map, but we note how the controls apply to multiple map generation; this will make sense later):

UDim is the number of additional regions in U (left to right). Leave this as 0.

InitialFileIndex is the number assigned to the first map generated. Leave this as 1001. It will increment as each file is generating giving them unique names. The last digit will correspond to the UV region in which the shell lies starting from left to right.

MaxMapSize is your map resolution. Set this to 4096 or 2048. Lower numbers will be faster but lower quality.

MapSizeAdjust should be set to 0.

DpSubPix governs the number of times the mesh is subdivided as the displacement map is generated. Set this to a value above 0. 1 subdivides once, 2 twice and so on. Be aware that this will be memory intensive the higher it is set.

Border thickness (overpaint in the generated map) can be left at 8.

Export Options opens the Alpha Displacement Exporter window.

16

2. Just to be sure, press GetMeshInfo and make sure your model has just 1 UV region. The number of UV regions corresponds to the number of maps that will be generated. A single UV region (UVs laid out in 0 to 1) will generate only one map and only one tile will be shown when you click this button. If you have more than one UV region, you need to jump ahead to section 6 on generating multiple displacement maps :-)

3. Now, press the Export Options button. This brings up the ADE window, shown below.

Figure 13. Displacement Exporter Options

4. Select the R32 option and enter the DE-LBEK-EAEAEA-R32 Quick Code to set the 32-bit export options that are ideal for Maya, or set them manually as shown above. Click Close.

5. You may now switch to your original morph target and generate your mesh based on subdivision level 1.

6. Click the Create All button in the MD2 menu and ZBrush will ask you for a destination folder and base file name, and automatically export the map based on these settings as it works.

7. All done! A few notes if you’re not using MD2, or are using MD2 but aren’t using 32-bit displacement maps. In these cases, you will need to record Alpha:Alpha Depth Factor, to use it later as the Alpha Gain in Maya. If you generated a displacement map with Tool:Displacement:Create DispMap, no problem; the displacement map shows up in the alpha inventory, so just select it and make a note of Alpha:Alpha Depth Factor. If you’re using MD2 to generate multiple displacement maps, it’s a bit trickier, because then the maps are written directly to disk. In that case, you’ll also need to generate a single displacement map into the alpha inventory, to get the alpha depth factor. This is covered in the PDF that comes with the ADE.

17

4.1.1. Creating a comparison Image to check your Maya Renders When comparing your Maya renders with the ZBrush view port it is important to note that in ZBrush the diffuse channel of the material is governed by a curve. This helps create gorgeous renders and it is also not something that is the default in Maya. To help approximate the look of your final render from Maya we can make some material adjustments in ZBrush. To use ZBrush’s perspective and get a reference image that you can use to judge your Mental Ray render against, I do the following. You can customize the steps to your liking.

1. In Document: Set size to 2048 x 2048, click Resize. 2. Draw your object on the canvas. 3. Press “t” to enter edit mode. 4. Position the model to best reflect the detail of your model or the area of interest. 5. In Material: select the Basic Material. In the options that become visible for that

material in the Material palette, set Ambient to 0 and Specular to 0, then click the DiffuseCurve box to open the curve and click Reset to flatten the curve out.

6. Increase the resolution to the highest level. 7. Press “t” to exit edit mode. 8. In Draw: Press Perspective and set the Distortion slider to 18. 9. Press “w” to enter Gyro mode and activate perspective. 10. Press “q” to drop your model to the canvas. 11. Set the color to black. 12. Document: Press Back (makes the back of canvas black).

13. In Light: Turn off all lights but the first one to the right of the light positioning control. Set Ambient to 0. Position your light to give you the best view of your displacements

14. In Render: Press Shadow and Best. 15. Press AAHalf on the shelf to the right of the canvas to anti-alias the image. 16. Use Document:Save As to save a ZBrush document for later adjustments. 17. Use Document:Export to export a TIFF file. (This will be used to compare against

the rendered Maya image).

18

Figure 14. ZBrush Settings for Generating the Triceratops, and the Resulting Image.

.

19

5. Back to Maya

5.1. Maya Setup for Rendering Back in Maya re-import the ZBrush level 1 mesh, or if in ZBrush you generated your maps from a stored morph target, use the original model you exported from Maya. If you are importing a mesh back into Maya remember to go to File>Import and select OBJ for file type. Make sure that Create Multiple Objects is set to false on this screen. Always be aware of vertex order and the importance of maintaining it between applications.

With the mesh selected press Ctrl-a to open the attribute editor. Under Displacement Map in the shape node uncheck feature displacement.

Figure 15. Turning Off Feature Displacement

We now need to add a Subdivision Approximation to the mesh to tell Mental Ray how to subdivide at render time so there is enough geometry to support the displacement detail we need.

To do this we use the Approximation editor. Go to Window>Rendering Editors>Mental Ray>Approximation Editor.

20

Figure 16. Mental Ray Approximation Editor

With the mesh selected, click the Create button to the right of the Subdivision Approx setting. The Edit button will now become active, click this to open the options in the attribute editor.

Figure 17. Subdivision Approx Attribute Editor

Change the Approx Method To Spatial, set the min and max settings to 3 and 5 and length to 0.100. The subdivision approximation will smooth the base mesh at render time and insure there is enough geometry to support your displacement map. These settings are flexible and work as a good start.

The settings above were selected to provide good results while not demanding too many resources. If your machine can support it, you could set max to 6 and length to 0.01 or even 0.001. The min and max settings tell Mental Ray the minimum and maximum number of tris to subdivide your model into at render time. The length value tells Mental Ray the longest any triangle edge can be and helps insure large protrusions and areas of high displacement render well; the lower this number is the smaller the tris in the mesh. Be careful, because Mental Ray will overrun RAM and crash if these settings are too high.

21

You may also wish to experiment with the Parametric setting. It has only one slider to control Approximation making it simpler but offering less control over the final output.

5.2. Create .map Files Your displacement maps from ZBrush will perform far better, faster, and with more stability in Mental Ray, if you convert them to the Mental Ray .map format. This is especially apparent with higher resolution maps. Mental Ray comes with a command line utility called imf_copy, which will allow us to convert the TIF files to .map format.

For the sake of safety you may want to perform this on copies of your original files. You can also find batch files to automate this process online at www.ZBrushcentral.com

Open a command window in the folder where your tiff files are located and use the following command line to convert to .map format.

Imf_copy –p originalfile.tif newfilename.map

This creates a map file optimized for Mental Ray and readable as 32-bit floating point. Perform this on all displacement maps you plan to use.

To check details on your maps, Maya provides a nice utility in the Maya/bin directory called imf_info.exe. You can use this program at the command line to read detailed information about your displacement map.

Also, imf_disp.exe is another utility that will display maps and offer info on them, but with a graphic interface.

5.3. Rendering with a Single Map This example uses the single map we generated using MD2 with the displacement scale baked in. First, Open Hypershade by going to Window>Rendering Editors>Hypershade.

Then, Create a Lambert material by dragging it to the workspace from the left side window. Middle-mouse-button drag a displacement node over it. Select Displacement Map from the connection editor window that appears. You will now double click the displacement node to open the attributes.

22

Figure 18. Maya Hypershade with Lambert shader and displacement node visible

We need to tell the shader it will use a file for displacement. Click the checker box (to the right of the Displacement entry box) and select the file from the popup window.

Figure 19. Displacement Node

Figure 20. Choose File Option Window

23

This creates a file node in which we can place our displacement map. You can graph your shader by selecting Lambert and then in the Graph menu select Input and Output connections.

Your shader graph will now appear like the image below:

Figure 21. Network for a displacement shader.

In the file node we will add our displacement map. It should open automatically when you click the file button but if not double click the node in the hypergraph (the one pictured as black above)

Figure 22. Attribute Editor

Click the folder icon to the right of Image Name to browse to the .map file we want to use for this map.

24

For all 32-bit maps exported from ZBrush using Multi Displacement 2, the alpha gain in Maya will be the same; just set it to 2.2. However, if you didn’t go through MD2, you’ll still need to set the alpha gain based on the alpha depth factor from ZBrush

So, assuming a 32-bit map exported with MD2, open Color Balance on this screen and set Alpha Gain to 2.2 and Alpha Offset to -1.1. The latter setting accounts for the fact ZBrush creates a map where 50% gray is no displacement, but Maya sees black as no displacement. We need to shift that value to allow the mesh to be pushed in and pulled out by the map, so the alpha offset will always be (-½*alpha gain).

Figure 23. Setting Alpha Gain and Alpha Offset

If you get unexpected results from your rendered surface, you may also want to turn off filtering at the top of the screen. It defaults to Gaussian and in some rare instances this may cause artifacts. It’s also helpful to lighten the color of your shader to be closer to the surface color of the model in your comparison image.

5.3.1. Lighting and Test renders

5.3.1.1. Setting up Test Render Lighting I find it beneficial to set up a single spotlight or direction light raking across the surface of the model to help spot details that tend to be lost in flat lighting. If you have a comparison image from ZBrush, try to approximate the same lighting setup in Maya as you had with the single light in ZBrush.

Figure 24. Test Render Lighting

25

In some cases you might even want to change your shader to a Blinn and dial down the specular color to a dark gray to nearly black. The subtle specular highlight in the render helps pick out tiny details that might otherwise be overlooked and considered lost.

Figure 25. Highlighting Details Specular color set to dark gray will give us subtle highlights to accentuate finer details on the render that might otherwise be overlooked or lost.

5.3.1.2. Render Globals Go to Window>Rendering Editors>Render Globals to open your render globals window. If it is not already set, choose Mental Ray from the dropdown box.

Figure 26. Maya's Render Globals window

Under the Mental Ray tab there is a rollout option called Translation. Open this and set Export Verbosity to Progress Messages. This will tell Mental Ray to report useful information to the output window when it renders. This includes the final triangle count, which when divided by two is the face count of your subdivided model at render time. Compare this to the final face count in ZBrush to determine how close to the ZBrush subdivision you are getting with you Approximation settings. You may adjust them as needed.

26

Figure 27. Maya Output Window with Progress Messages

Memory and Performance is another menu of interest here. As you start rendering more maps you may want to research BSP optimization especially when ray tracing shadows.

Using the .map file format will also increase your speed at render time because they use Mental Ray’s memory caching features. This speed increase is only apparent when rendering locally. If you are on a renderfarm with your scene folder on a remote machine from the nodes this advantage is negated.

Taking care with how Mental Ray handles memory will speed up renders and make for far better performance.

5.3.1.3. Test Renders Open the render view and start a render. You may keep the image in the render view for real-time comparisons.

Your initial renders will most likely not be sufficient and you will need to adjust settings in the approximation editor. Check your output window to make sure you are getting enough geometry at render time.

If you see bloating in your render then there is a mistake with the alpha gain and offset. Usually you have forgotten to set one or both, or the offset is not set to -½ of alpha gain.

Figure 28. Displaced mesh rendered in Maya using Mental Ray.

27

5.3.1.4. Troubleshooting Renders and Artifacts In some cases you may see artifacts in your renders. Small spikes on UV seams can be remedied by using the SmoothUV option in ZBrush under Tool:Displacement.

Pinches in the mesh are apparent where you have tris, poles, or faces with more than 4 vertices. These should be hidden in inconspicuous places during the modeling process or removed completely. If you find such an artifact on your render applying a smooth to the mesh before rendering can help. This will increase render time and you may want to lower your Approximation settings as a result.

6. Multiple Displacement Maps ZBrush’s Multi Displacement 2 (part of the Alpha Displacement Exporter plugin) allows you to generate, in one pass and with consistent scaling, displacement maps for a set of models that are used as a unit externally. In our example, we’ll be doing this with a dog that actually consists of four separate meshes in Maya. Before MD2, each model would have to be processed individually in ZBrush, which was not only more work, but also generated different alpha depth factors for each map.

Let’s say we’re working with models A, B, and C, which together make up some larger object. The basic workflow for processing all of these in MD2 is:

1. In Maya, set up a single map coordinate space for all models, where each model has it’s own 1x1 block of the coordinate space. For example, A might get the space where U goes from 0 to 1 and V goes from 0 to 1; B would get the range where U goes from 0 to 1 but V goes from 1 to 2; and so forth.

2. Then, combine those models into a single OBJ and take that into ZBrush. You’ll still retain your original models for use when you’re done with ZBrush

3. Go ahead and sculpt. 4. Now you can use MD2 as previously, but when it sees vertices outside the

standard 1x1 UV range, it will process those areas individually and generate a separate displacement map for each.

5. Finally, the separate displacement maps can be applied to your original meshes back in Maya.

6.1. Setting up UV Regions in Maya To generate multiple maps with Multi Displacement 2, it is necessary to place your different models into different UV regions in Maya. UV regions simply mean your UVs are outside the standard 0 to 1 range that is displayed in Maya by the gray box in the UV Texture Editor.

To display beyond just 0 to 1, go to the View>Grid option box and raise the Length and Width value to 5. This value may be higher or lower as needed. You may also want to set Grid Lines to 1 to visually clarify where each region begins and ends.

28

Figure 29. Setting Grid Options

To shift UVs from 0 to 1 select a shell and in the Maya command line or the script editor enter the following MEL command (note the capital letters)

polyEditUV -u 1 -v 0

This moves the shell one unit to the right and 0 vertically. You may repeat for each shell you want as a separate map or UV Group, placing each in its own quadrant. Increment the U number for the number of quadrants to move in each direction.

In this example the dog’s body mesh (model by Dan Fine), teeth, upper gum, and lower gum, are separate objects. We can however combine them and import into ZBrush as a single object with UV Groups active.

Figure 30. Dog Model with Four Separate Mesh Parts (model by Dan J. Fine)

29

6.2. Making the Displacement Maps in ZBrush Once you’ve layed out UVs as described above, the steps to generate displacement maps using ZBrush are as follows.

1. Save the new Maya scene (with the maps separated into UV regions) separately from your original, as it will be used only by ZBrush. The generated maps will then be applied to your original multiple mesh Maya geometry.

2. Now we will create a combined object file to use in ZBrush. Select each separate object and click Polygons>Combine to create a single mesh from these objects. Your UVs will be intact and still in separate regions (see image).

Figure 31. Combined Objects and UVs Note: The figure below shows just the mouth parts combined, to make more visible the fact that these parts are combined into a single mesh.

3. In ZBrush import the combined mesh and activate Uv Groups under Tool:Polygroups. Turn on Frame mode to view your grouping. If the colors ZBrush chooses are too similar to distinguish from each other, Ctrl-Click to isolate the group you want to change color for and then click Tools:Polygroups:Group Visible to cycle through other options. You may also want to enable Tool:Display Options:Double to display geometry double sided in the view.

4. Ctrl-Click the body polygroup to hide it and render the teeth visible for sculpting. Detail your mesh as normal. You may want to turn off Tool:Geometry:Smt (Subdivide Smooth) to prevent your mesh parts from shrinking as you sculpt.

30

Figure 32. Dog Teeth Parts of Model with Polygroups Assigned (Body is hidden)

5. Finally, use the Create All button in the MD2 menu to create the displacement maps. Details are found in section 4.1.

6.3. Applying Multiple Displacement Maps in Maya

In the previous sections we created a separate map per body part to increase quality in the final product by allowing more texture space per body part and the use of multiple high-resolution maps. To assign the maps we need to create a displacement shader for each map we will apply to the model.

Be sure to check the place2DTexture node attached to your displacement map and be sure that Wrap U and Wrap V are checked. This will tile the maps outside 0 to 1.

31

This model has 8 UV regions so 8 maps are generated. The resulting 32-bit TIF files will be ready to apply to the mesh in Maya and should render exactly as seen in ZBrush. To make sure each map is applied to the correct region of the creature open the UV Texture Editor as seen above.

Drag-select one quadrant of UVs and go to Select>Convert>Faces (or Ctrl-F10 on the keyboard). You can select a few UVs from one shell then use Select>Select Shell to enlarge the selection to the whole UV shell. Now in Hypershade apply the shader with the corresponding map to the set of faces. You can quickly assign shaders to selected faces by right-clicking on your shader in Hypershade and selecting Assign To Selection from the marking menu that appears

You can determine which map is for which quadrant by looking at the filename index number for each map; 1001 is for quadrant one, 1002 for 2 and so on. It helps to name shaders descriptively as you create them.

And that’s it! With the displacement maps all generated and attached back to the original meshes in the dog project, you should be able to on with your rendering or other work as usual.

32

7. Bump and Diffuse Maps In many cases you will want fine details on your mesh like pores and small wrinkles. These can be added into the geometry itself and ultimately the displacement map but doing so is inefficient and usually not necessary. Finer details can be added in a bump map and rendered over the displacement in Mental Ray. This takes a huge load off the renderer since you don’t have to subdivide nearly as high to get finer details to appear. A good rule of thumb is if your detail will change the silhouette of the model, displace it. If it is not visible in the profile, add it as a bump map detail instead.

Figure 33. ZBrush Sculpt Before Bump Map Applied

Figure 34. Same Mesh with Bump Map (viewed using the Bump Map Material)

7.1. Using the Bump Viewer Material. ZBrush has a little known but very helpful method for viewing bump maps directly in ZBrush, using a special material called the BumpViewerMaterial, which can be loaded from the Zmaterials directory that is part of the ZBrush distribution. Applying this material to your model will then cause it to render in ZBrush using the currently assigned

33

texture as a bump map, rather than a normal texture. This allows you to use all the tools available in the Projection Master or elsewhere in ZBrush, and easily see the result.

Here’s the procedure for using this:

1. With your tool open and in 3D Edit mode got to the Material Menu and click Load.

2. In the Zmaterials folder of your ZBrush install folder you will find the file BumpViewerMaterial.zmt. Load this and the material will be applied to the model.

3. To create a texture for the bump viewer open the system color palette by pressing the SysPalette button to the left of the workspace…

…and select 50% gray (RGB value 128 128 128). The system color palette window may vary, depending on your operating system.

4. Then go to the Texture menu, set width and height to 4096 (or whatever is appropriate to your needs) and click New. A gray texture will be created.

34

5. You may now enter Projection Master with only color enabled and paint with black or white on your model, varying intensity to adjust bumpiness.

6. When you leave Projection Master, the modifications to the texture will appear as bumps on the model’s surface.

Make sure that you enter Projection Master with only the Colors option checked, and your brushes are using RGB only, do not use ZAdd or ZSub. This will ensure that you do not inadvertently modify geometry as you paint the bump map.

7. Once the map is done, you can export it and use it in Maya.

7.2. Applying bump maps in Maya To apply your bump map in Maya go to the Attribute Editor for the material on your mesh. Here there is a Bump Mapping slot. Click the checkered box to the right and select the bump map file from the popup window.

This will create a bump2D node. Bump Depth is the “volume” control for the level of the bump. The initial value of 1 is usually too high so I start testing with a value of .5

Click the arrow next to Bump Value to access the file node where you will load your bump map. Remember that, like the displacement map, this is based on 50% gray corresponding to no bump, so be sure to set your alpha gain to 1 and offset to -.5 under color balance in the file node.

35

Figure 35. Before Applying Bump Map, and After

7.3. Cavity Maps and the Diffuse Channel Using cavity shading in ZBrush, you can generate diffuse maps which when used in Maya can help support the displacement by accentuating shadows in the recessed areas.

Figure 36. Render Without Diffuse Map, and With

Cavity map generation will soon be automated with future releases but as of ZBrush 2.0 you can make cavity maps manually by altering material settings. Begin by creating a displacement map with Tool:Displacement and selecting it that map in the alpha inventory popup.

Next, select Material:BasicMaterial and click Alpha:CropAndFill. This causes the canvas to be erased, resized, and filled with the selected alpha (the displacement map), but with a

36

ZBrush twist. The alpha is not applied to the canvas as grayscale intensities, but as depth, which means the contents of the canvas will be sensitive to the lighting conditions.

Turn Ambient all the way up. With Render:Best on, adjust the CavityColorize, CavityRadius, and CavityIntensity until the wrinkles in your model are shaded as you like. (CavityIntensity is probably a good one to start with.) You should get a posterized effect denoting where the areas of the map will be cavity-shaded.

Once you have a diffuse (cavity) map to your liking press Texture:GrabDoc to make the document into a texture, and then export using Texture:Export.

The diffuse map can be added in Maya similarly to the bump map. In the attributes for your shader attach a file node to the diffuse channel. Dark areas will render darker and light areas will be normal. You may want to adjust the map in a photo editing package if the effect appears too strong or adjust the file node settings.

Figure 37. Example diffuse map.

Thanks for reading this guide! If you have any suggestions or corrections I can be found at www.scottspencer.com, at ZBrush Central, and the “ZBrush in Production Pipelines” forum at www.highend3d.com. Happy sculpting!

Special thanks to!!:

Pixolator, Jaime, Ryan, Aurick, Ken and the Pixologic team! [Pixologic editor’s note: No, Scott is the person who gets special thanks. This is our job, but his much-appreciated contribution.]

37

Sunit, Ricardo Ariza, Bill Spradlin, Dave Cardwell, Dick Smith, Monstermaker, Aminuts, Zack Petroc, Will at HighEnd3D, Pendulum Studio, Marcus Civis, Antropus, Svengali, and the countless other artists on ZBC who are always inspiring!

All models by Scott Spencer except Bulldog by Dan J Fine.