Zbrush to Game Export Pipeline (Part 1)

Ok,

so this has been a lot of trial and error, but as I make progress and can reproduce the results I will list them here; so when I come back and have to do this for ALL of the models I have created in Zbrush there will be a system.  If anyone else can use this, feel free and remember where you found it.

Step one:  Inspect your model and decide which part you are exporting

This method lets you export any character you create from Zbrush to game engines (UDK, Unity, etc) but HOW you go about the process is essential.  Even if you build your characters from scratch in Zbrush with no UVs, this method works, but you have to separate each component that sticks out from the character.


In this example, the character has wires and cables sticking off of him. For models with extra accessories (shoes, armor, hats, cables, wonky extra limbs, helmets, etc) it is wise to go through the following process for each of those components that will be rejoined to the mesh later.  The Remesh feature in Zbrush doesn't work very well when there are gaps or holes in the mesh, so keep in mind it's smart to leave those separate so each accessory can fit back together without any funky artifacts.

For the purpose of this tutorial, we won't go with such a scary character model to start with, but instead will opt for a clean character with no gear.

Abanshi Model by: Cheshire (Tools by BadKing.com)
Poly count: 3,902,392
Polypaint with no UV/Mapping

Step Two:  Remeshing

Getting a mesh ready to export for game use is easy, even if you didn't know to plan ahead or deleted your lower subdivision levels, leaving your model at almost 4 million polys.  If you don't have a low res game-ready mesh with low subdivision levels, here's how you go about making one from the high-res character you have already worked up.

1.  In your Tools>Subtools make sure that all the eyes icons that you want visible are on for the Subtools you want to create new meshes from.

EDIT:  For this example I'm making a single .obj, so I want all tools visible for the re-mesh.  If you are going for exporting multiple meshes that will be exported as an FBX, then make all the Subtools Eye icons OFF, except the one you have selected for remeshing.  Remember that you'll have to go through this full remeshing and UV process with each component of your model.



2.  Tools>Subtools>Remesh click OFF the little X on the Remesh All button, and change the Resolution (Res) to 1024 and click ReMesh All.  This may take a minute, but when it is done, it will make a globby-looking mesh that fits to the shape of your character and all of the subtools you left visible.  Check the fingers, toes, or anything sticking out to make sure there are no artifacts, and to make sure that parts you want to move later are smooth and not stuck together.


3. Select your new mesh.  Zplugin Tab (at the top) Decimation Master.  Do the following, in this right order:
                         1.  2-Pre-Process :  Click Pre-Process Current.  You don't need to Freeze Borders unless there are holes/hollows you have put in the mesh.

                         2.  3-Decimate = 10k polys (this can change based on your desired polycount)

                         3.  3-Decimate = Click Decimate Current.  If it gets it right the first time, do a little dance. If not, repeat steps above, adjusting for desired level of polycount, and get it where you
 want.  It won't look great at first, but remember that game models have to be lower poly to be less processor intensive.

Final Decimation that I was happy with:
12k polys 


4.  Tools>Subtools>Geometry :  Leave Smooth (Smt) OFF. Click Divide until the polycount is back up to near where your original character was before creating your ReMesh.  I have redivided the mesh above back to 2,303,616 polys (sDiv 5), so I can project the texture back on to the model.  For now, leave the ReMesh on the new highest sDiv, as it will help with projection in Step 3.

If you are doing this to multiple parts that will eventually be reattached to the character (accessories), the cut-and-dry rule for converting models for games is to keep them as low poly as possible.  The model I have decimated above is 12,000 polys.  All of her gear, clothing and stuff I add to her shouldn't exceed 15,000 polys (that's 3k poly allotment for gear if you're bad at math).  This self imposed poly budget will keep the character low budget for memory in your chosen game engine.

Step Three:  Projecting Textures

Now we get to Project Textures and poly-painting back onto the new mesh.

1. Tools>Subtools>Project.  Change Distance (Dist) to .03125.  This will keep your ReMesh tight to your old mesh, kinda like vacuum molding the new mesh to the finished model.  This should prevent artifacting, but change the distance if needed to keep the ReMesh tight to the character.  Click ProjectAll.  It will ask if you want to Project PolyPainting to the active Subtool, and the answer is Always YES.  This will take a couple of minutes, depending on the poly count of your original character mesh/tools.

Be sure to check between fingers or parts to make sure there is no weird artifacting.  Change the distance if you have to to get a finer Projection.  For my example, I changed the distance to .02 and smoothed a little of the artifacting between fingers.

You now have a single character mesh comprised of all of your subtools, textured (sill no UVs), almost ready for export.

Step Four:  Creating UVs & Maps

There are a lot of ways to do this using programs like XNormal (and I plan to post about that pipeline when I get it working, because I've heard it's faster) but Zbrush will export all of your maps correctly if you know how to do it right.

Now that we have a mesh that can be reduced to low subdivision levels while still having high-poly texture data, we can create UV maps for the low poly game-ready mesh that will match up to the coordinates of our high-poly texture data.

1.  Tools>Geometry: Reduce the Remesh back to it's lowest subdivision level.  DO NOT DELETE HIGHER or we'll have to start all over.  Just slide the level back to 1.  Check the mesh one more time to make sure there are no holes or artifacting.

2.  Zplugin Tab at the top> UV Master.  Under 3-Utilities, Click on "Work on Clone".  This will create a new tool in a new file all by its lonesome for you to work on without messing with the Remesh you just created.  If you don't do this, Zbrush will complain that you have several subdivisions (and don't we hate it when it complains?)

3. Still in UV Master, under 2- Painting, Click on Enable Control Painting.  The Click on Protect. While active, Control Painting "Protect" lets you paint red where you want the UV map seams to NOT be.  Selecting "Attract" instead of Protect will let you paint in blue to tell Zbrush where you would prefer your seams to be laid.  Selecting Density instead of Protect or Attract will let you paint on where you want more pixel density when your UV displays Textures or Color mapped to those polys.  This can allow you to paint a little more on the face or hands to allow for better close-ups in game later on.


4.  Still in UV Master, click Unwrap.  You have now unwrapped your UVs and created a UV map. if you want to see what it looks like, click Flatten.  Click Unflatten when you are done oohing and ahhing, and then click Copy UVs.  This will copy the UVs from this clone we created, so we can apply them to the  lowest subdivision of our Remesh in the original file.

5.  Click back to your original file with the Remesh in it.  Make sure your ReMesh is the one selected in your Subtools, and the go back to Zplugn Tab>UV Master.  Click Paste UVs.  This will Paste the UV map you have just created onto your Remesh with the matching topology of your clone.  If you did it right, Zbrush will indicate in the upper left hand corner that either the file imported successfully or that it is updating subdivision geometry (both mean you're happy).

Now you have a low-res model with high-res texture information and a UV Map.
You Stud.


Step Five:  Creating Maps (Diffuse, AO, Cavity, Normals, etc)

So ya have a model, and it has UVs.  Now you get to export it.

EDIT:  Substance Painter and Quixel use Ambient Occlusion Maps, Cavity Maps, Normals, and Base Color (Albedo).

1.  While on it's lowest subdivision, with only your low-poly game mesh visible, export it by clicking Export in the top of the Tool pallet.  Save it somewhere you won't lose it.  Once exported, set the model back to it's Highest level of subdivision.  This will make the exported maps nice and high-res pretty.

2  .  Zplugin Tab>Multi Map Exporter.  We will click on Displacement, Normal, Texture from Polypaint, Ambient Occlusion, and Cavity.  Some engines use Vector Displacement, so this is optional, but DO NOT click on Export Mesh (We already exported the low poly mesh we need for game, doing it now would export the highest subdivision, defeating the purpose of making the model "game-ready".

3.  Still in Multi Map Export:  Click on 2048 or 4096 for the map size.  Most game engines use 1024 or 2048 maps, but the idea is always to make it bigger first, because shrinking images is always easier than increasing their resolution.

4.  Still in Multi Map Export:  Click the Flip V button, and make sure the Map Border slider set to 10.

5.  Still in Multi Map Export:  Expand the Export Options button, and set all of the following:
                        Displacement Map: SubDiv Slider to 1, and select Adaptive, Smooth UV, and 32 Bit
                        Normal Map:  Select Tangent, Adaptive, & Smooth UV.
                       (Note for UDK & 3DSMax users:  Select Flip G because that's how they process Normals.                         You can always fix the Normal map later in Photoshop by opening the Normal map,
                        selecting the Green Channel, and inverting it.)
                       Cavity: Int Slider to 40

6.  Click Create All maps, and give it a place to save them.  They will save as various types of files.  Be organized; I suggest saving the mesh (.obj) and maps all in one folder per character.  Some engines may require .png.  You can go into the settings in Zbrush and change what file type you save the maps out as.



If all went well, you have an OBJ mesh, an .mtl (material) file, and all the maps you exported in a single folder.  They'll come in handy further down the line.

If you try to re-import the model & reload the texture in Zbrush, sometimes you have to load the texture two or three times for Zbrush to look at the other files in the same folder and read the other maps.  Until it reads correctly, Zbrush will show your model with a texture that looks way too bright, so just reload the texture after importing it; no need to re-import it, just select it from the list of other loaded textures.  Also, you'll have to go into the UV map settings (under the Tools menu) and Adjust / Flip V after importing the Texture map to make sure it fits correctly.  It also helps to load and place the Displacement mep (You only really need Displacement, Diffuse/Texture, and Normals maps for most game engines).  I've found that adjusting your Displacement map to .025 usually works well, but play with your levels to see what effects you can come up with and what looks good).


Final game ready model and texture with Normal, Diffuse (Albedo), and Displacement Map (.002 setting for the Displacement map)

UPDATE NOTE:  You now have a UV and mapped mesh ready for import into Substance for more tweaking (You'll wind up re-baking some of your maps for better materials in Substance); or straight into Unity or Unreal for set up with materials and PBR.  This setup can also be exported to Marmoset, Sketchfab, etc.


I started writing this tutorial at Midnight, and the sun is just coming up outside my office, so I'm going for a nap.   Thanks for your attention.  More to come.

If this helped you or you like the characters, pitch me a couple bucks for my project:  www.patreon.com/sqproject


Thus endeth the lesson.

Comments

  1. This is an amazing resource - exactly what I was looking for. Thanks for sharing a little bit of your expertise with a beginner like me!!

    ReplyDelete
    Replies
    1. Glad I could help! Nobody else out there had done one of these I could find, so this was made out of necessity more than anything else. Keep a couple of things in mind as you use this:

      1. For all of Step 2, it's better to manually re-topologize your meshes, instead of using Zbrush's Remesher, AND THEN Subdivide and project your high poly detail. This gives you ultimate control over where your model's polys are placed. This tut was made when I wasn't so good at re-topo with Zspheres, so it presents a simpler (and much faster) method at the slight sacrifice of quality. You can also use Zremesher if you like; some people have great success with it instead of standard Remeshing or manual re-topology.

      2. A new version of Zbrush has been updated since this tutorial was made. Now you can go through each step for maps and export the final low poly model as an .FBX (preferred with any engine because it carries animation and rig data and STILL comes out smaller than an .obj.) with all of the subtools included with the mesh.


      If you hit any snags, post here again and I'll try to help.

      Delete

Post a Comment

Popular posts from this blog