Tuesday, May 22, 2012

Mudbox PTEX to Houdini Mantra

In order to export a PTEX from Mudbox to Houdini (for rendering with Mantra), the workflow is at first similar to the Mudbox PTEX to Maya Renderman tutorial I wrote.  The main difference being that there will be more hijinks in Houdini to get the displacement to work correctly.

To add another level of complexity, I have chosen to also work with PTEX color maps.  Here is my sculpt with the painting on it in Mudbox.  I tend to paint in many layers, but have merged them for the sake of simplicity in this tutorial.

I have switched the Display to Flat Lighting in order to better show the color, this allows us to make sure the color PTEX in Houdini is mapping properly.

Without Flat Lighting:

Flat Lighting on:

To prepare your model for PTEX, step the mesh down to level 0 (navigate levels using the Page Up or Page Down buttons on the keyboard), go to Mesh and select PTEX Setup... from the dropdown menu.


A blue and white grid will appear on your model.  Increase or Decrease at will to find a happy medium between a clean blue line and a small file size.


Select Done when ready, the program will spend some time calculating.
As stated before, I have merged all my paint layers to simplify this next step.
Select your paint layer and Right Click on it.  On the menu that pops up, click on Export Selected...


Save your file as a PTEX file.  The folder will default to the Mudbox files on your computer, it may be necessary to redirect first.


Go to Maps, Extract Texture Maps, and select New Operation...


Unlike the Renderman process, this time select Displacement Map on the popup window.


Make sure the Target Model is set to level 0 and the Source Model is set to your highest level.
Next to Search distance, click the Best Guess button.
Under Output option, be sure to identify the Base File Name.


In the popup Save As window, be sure to to change the Save as type to .ptx


After hitting Save, click the Extract button on the Extract Texture Maps window.
This may take some time.
Finally, before leaving Mudbox, export your mesh as an .obj at the lowest possible mesh level.

Now, on to Houdini!
For the purposes of this tutorial I will be using Houdini 12.0.543.9, but I am sure the essentials will translate to other versions.

To start things off go ahead and select File, Import, then Geometry and select your .obj model.


This will create a geometry node, my model imported as a very giant scale so you may need to move around to find your sculpt.


Dive into the node by double-clicking it.  Hit the Tab button to bring up the node menu and start typing Reverse.  Connect the Reverse node to your imported file.

This is going to re-arrange the vertex order in the model in order to better orient it for the PTEX textures later.


Jump back up to the object level and select your geometry node.
In the object's pallette, under the Render tab and the Geometry sub-tab, make sure the Polygons As Subdivision tab is checked.


Now that we have our model set up, it is time to customize our shader.
Open up the Material Palette and drag a Mantra Surface material onto the /shop pane.


Click the ball icon on the material to open the attributes above it.
On the Surface tab select the Diffuse tab.  Check the Use Color Map box and load your color map .ptx file into the Base Color Map section.


Inside your geometry node, attach a Material node to the bottom of the Reverse node and point the Material to your Mantra Surface shader.


If you render at this point, the texture will look like a confused game of Tetris.


To fix these issues we have to re-jigger the material.  Jump into the shop network and dive into your mantrasurface node.

 ^^Double-Click this to reveal...^^

^^MADNESS^^




Don't panic.

Press l to organize if you wish, but don't worry too much about aesthetics at this point.  Click the magnifying glass icon in the top right corner of the pane and type the word diffuse.

Then click Select Matches and all your navigation issues are over!
Simply zoom into the newly selected node.

 
The first thing we will do is to Tab a PTexture into existance above our diffuseColor node.


On your diffuseColor node, there are a number of little nibs sticking out the side.  Each of these is a hidden node you can pop out of the larger node.  We are going to be using the hidden node Base Color Map on the diffuse Color.

 Middle mouse button click on the dot next to the Base Color Map to select it, it should light up yellow.  Then right click on the newly colored nib and click Expose Input(s) on the menu that pops up.

It will seperate as a new little node.


There is no need to delete any nodes, just leave them as is and connect the following.

Connect the Base Color Map setting from the baseColorMap node to the PTextu... input on the ptexture1 node.      

Connect the Textur... setting on the ptexture1 node to the Diffuse Color input on the surfaceModel node.  This will automatically detatch the previous connection, that is fine.

                                   
Re-render and you will find the orientation of the texture is now correct.


Now to fix the displacement.

Still in your /shop/mantrasurface network, click the magifying glass icon in the top right corner of the pane.  Type in textureDisp and hit Select Matches.

It should take you here.


Tab in another PTexture node.
Middle mouse click to select the top red nib on the textureDisp node and then right click, extract to reveal the hidden displacementMap node.  Connect the top option (Displacement Map) to the top option on your ptexture2 node (PTextu...).


Now take the output of your ptexture2 node into the only inputs on the luminanceDisp and RGBDispChannel nodes.


We are now done with the shop network.
Go back into the Material Palette and select your Mantra Surface material.
Select the top Displacement tab in the attributes.

Check the Enable Displacement Map box and load your displacement PTEX file.
At this point I am getting results, but they are not good ones.
I suspect this is because the Displacement Bound is linked to the Displacement Scale.


There is an expression set to the bound by default, go ahead and break that.

I set my Displacement Scale to -5 and my bound to 0.
I fiddled with the numbers a great deal, but was unable to pull much detail from it.

Here is the render and what is in the viewport.

Hope this helped get you started, I would much rather use the PTED to Maya Renderman Method (as the results are near perfect) but the Houdini route will suffice if you do not have access to Renderman.

Happy Displacements,
Josh Evans

4 comments:

  1. thanks !! Josh Evans!!
    this is very useful tutorial!!
    may I ask for facebook or other messenger app??
    ur really a amazing guy!!!!!
    thanks again!!

    ReplyDelete
  2. Sure thing man, here is my facebook art page: https://www.facebook.com/pages/Josh-Evans-Digital-Artist/194855337261334

    Here is my web site: www.joshrevans.com

    I am glad the tutorial helped out. Please let me know if I can be of assistance in the future!

    ReplyDelete
  3. hi Josh ! thanks for your mentoring , is it possible to see images ?

    ReplyDelete
  4. Hello Vito, I'm using chrome on a pc right now and can see all the images...are you accessing this on a mobile device?

    ReplyDelete