Ptex workflow with arnold and mari

ptex_mari_maya_arnold

Ptex has been around for a few years now, but the lack of support in major render packages and 3D programs made it difficult for freelance artists to integrate into their own pipeline. I decided to give it a try in my current project and see the pros and cons by myself. So in this post I am going to show you how I painted ptex textures in mari and the workflow you need to follow if you want to test it on your own projects. Along the way a few photoshop and mari tips.

I am using arnold render but if you are using vray or a recent version of mental ray you should be able to follow along. Arnold doesnt have yet official support for ptex, but I found a website where you can download the arnold ptex plugin, just search in the plugins/download sections and if you can’t find a compatible version for you Mtoa, email the developer and he will send it to you.

Why Ptex

maya 3d scene ptex

So ptex as you may know is a way to texture paint 3D models without making any UV’s, each face has an “ID” and it stores all the texture information in a “.ptx” file. I decided to try ptex because I have a lot of individual objects to texture. Since most of the objects will be seen from distance a procedual aproach would be a good choice, but you never know if you will need a close-up render. Anyway, I thought that I could merge some objects in some logical way,paint them inside mari and export as a ptex texture instead of dealing with uv’s or any procedual texturing complex networks. I will only use this in the objects that are closer to the camera or need a more “textured look”.

Exporting the models

maya ptex export obj

As a first test I combined these 3 objects to be exported. The first limitation, at least in arnold, is that you need export your models already subdivided, no render time subdivisions. So, use the smooth mesh preview options in the shape node of your objects and then Modify >> convert >> smooth mesh preview to polygons. Do this step before you combine the obejcted so you can have individual control of the smooth level. You could create individual ptex textures for all of your objects, but I want to keep the “file management” and shading networks simple.

Projections camera and reference material

maya camera fbx reference

One advantage of having good uv’s is that you can paint decals/text details with ease since the uv’s are in 2D space. So I found a good idea to export an animated camera with 3 frames representing the 3 objects. I just used the view >> align camera to polygon and then dolly out. The idea was to have front projections bookmarks instead of orbiting around the models in mari. Just export your camera as .fbx. Also created a reference image at this point to use in mari.

Inside mari

mari ptex

Create your mari project, then you will get pop-up windows asking about ptex. Make sure you set force Ptex, and chose uniform face size ,  in my case I used 32×32 and you can always change the face texture size later. Now import you fbx camera exported from maya by selecting camera >> load camera. Make sure you have the play controls visible selecting view >> palettes >> play controls, this way you can jump between frames. Use this camera only for projections, to orbit around your scene use the default perspective/orthographic views.

Using quick projection in mari and photoshop

mari quick projection photoshop

So I wanted to project some text detail into my first obejct, and for that I will use mari projectors with photoshop. Go to camera >> quick projection settings, set the resolution and the psd file path (ex: …/project_text.psd). Then go to camera >> quick unproject. Open your psd file in photoshop, create a black background if you need, a reference image and maybe setup some guides.

photoshop path text

In this parrticular case I need text to flow around a circle. To do this in photoshop is really easy, just create an ellipse shape at the right positing and hover the ellipse shape path with the text tool selected and just type anything you need. In case you need text facing other direction you can use edit >> transform path >> flip h/v. Create any other texture pattern/details to project inside mari. Then you will need to save the psd file,  I like to merge all the layers unless I need to project into separated layers inside mari, if for any reason you want to edit the text or any particular layer of this psd, save a copy of it or you can use the the undo after. Hide your the “helper” layers and merge everything you need, make sure you also hide any background or mari exported texture.

Mari face masks and projections

mari face masks

Now back to mari, before we project anything, we need to create a group to mask the individual objects. So select the faces of your object, make a group in the layers palett, select it and right click >> layer mask >> add mask >> hide all. Now set your foreground/background color to white and in the ptex menu choose fill faces foreground. Create all the textures for this object inside this group

Let’s get back to the projection, go to your projection camera bookmark/frame, create an empty layer and select camera >> quick project front.

mari projection

Now use the painting tools and procedual layers like color and tri planar projection to create your final textures. Use the same masking aproach to texture and isolate the other objects, you can also paint other types of maps like specular, creating a new channel.

mari textures ptex

When you have your textures ready right click on layers palett empty space, and choose export >> export all layers flattened. Chose the location of your ptex file and give it a name, in my case I used prefix.$CHANNEL.ptx.

Ptex in maya with arnold

faceid ptex arnold mtoa

Now inside maya, create a aiBeshaPtex node and chose the location of your ptx file. Now just use it as a normal file texture in your shading networks. you will need to apply a gamma correction of 0.4545 depending on your color space workflow.

Finally 2 important steps. Select you object and in the uv texture editor or edit uv’s menu item, choose polygons Unitize , and the final step is to check Export faceId in the arnold tab of your object’s shape node.

Ptex or not Ptex

ptex viewportrender maya

If you follow the steps everything should be rendering fine by now. So is it worthed? I elaborated a list of pros and cons based only in this simple test and arnold workflow, but feel free to experiment and play with it, may come in handy in your own projects.

Pros

  • No UV creation/editing required
  • No texture stretching or seams
  • Add texture resolution where you need (per face resolution)
  • No modeling limitations “thinking” about uvs
  • Full set of mari painting tools for ptex
Cons

  • You can’t change vertex count/position after exporting for painting
  • Identical objects might need different ptex depending on world position(arnold specific?)
  • Still under development and implementation
  • Lack of support of the full ptex feature set
  • Compositing workflows may require Uv’s
  • Ptx files not editable in photoshop

I think Ptex has amazing potential, and yet, already production proven. Of course when solidangle release official support for ptex we should be able to do more and have less limitations of the current workflow. Well, for now it works and you can definitely use it on your next project. Please leave a comment if you have any questions or want to share your experience/opinion. See you next time.

Some of you asked me about vray and mental ray support for the viewportRender tutorial/tool. I have updated it a few days ago, and it can now support any render engine that works with maya. Make sure you download the latest version of the tutorial and tool.

  • Pingback: Maya | Ptex Workflow Using Arnold Render and Mari

  • Raskal Robbin

    how do you install the shader? The directions in the ‘readme’ is in some strange encypted language.

    • therenderblog

      Just upload to google translate the readme.txt. I installed in the shaders folder(ex: C:solidanglemtoadeploy2014shaders)

      • Raskal Robbin

        I’m trying to get the geo to show the displacement but the ‘aiBeshaPtex’ node doesn’t show the displacement on render. It doesn’t default connect a displacement node with the ‘aiBeshaPtex’ so I tried to run connection to no avail. The Ptex works in mentalRay displacement but not color, it also works in both vray displacement and color. Maybe I installed incorrectly or not but can you do a displacement test on aiPtex?

        • therenderblog

          hey, displacement working fine here, but make sure you disable “auto-bump” in the displacemente shader. If the connection doesnt create a disp shader for you, create it manually and connect yourself. :)

          • Raskal Robbin

            is the connection via aiBeshaPtex.outColor -> displacementShader.displacement? because the disp channel is grayed out in connection editor. However the outColor R channel is greenlit yet no displ shows on render. I believe it’s gotta be a bad installation if your seems to work. I’m on win7 (w/o sp1) via maya2014 x64 (MtoA) v0.25.2. I guess I’ll wait out the next arnold update for ptex. Congrats on your early discoveries, and thanks for the reply!
            RR

          • therenderblog

            Yeh, you have to use only one channel, I used outColor R. Well, just connect the ptex to the dIffuse color of the material and see if it works, if not then it is an install problem. I am using a more recent version of MtoA, the better option is to contact the developer if you are facing any issues.

            Cheers

  • Snzn

    Hey, thanks for the tut. When I try to get to the download though I keep getting a russian wordpress login window. Did you just log in with a normal one?

    • therenderblog

      Use the browser translate features, but yes, it’s just a wordpress login :)

      • Snzn

        Takes a while for the comments to be put up… :)

        I managed to get the file a couple minutes later…but now after putting the ddl and the mel file where they belong theres no aiBeshaPtex node to be found… perhaps I have to set up some paths or something?

        • therenderblog

          I have to approve the comments, maybe I should change that. :)

          Can you check the output window for any shader/dll error? Maybe the shader avaliable is not compatible with your mtoa version. If that’s the case, in the referenced forum, there is a thread about the wip of arnold ptex. Grab the developer email and ask for a newer version, that’s what I did recently ;)

          Cheers

          • Snzn

            Yeah you’re right..He’s compiled it against an older arnold version. A quick kick -av revealved that I am running 4.1.3.2 … guess I have to go write a russian email now. Great blog btw ;)

          • therenderblog

            In english is fine :D

          • Snzn

            Ugh, he told me to download an older arnold build instead. No thx. This current one is so much faster than the old ones. Guess I’m going to have to pass and wait for a proper arnold build supporting ptex.

  • http://www.sijen.ru sijen

    I dont have Export faceId option( arnold 1.0.0.1 4.1.3.3

    • therenderblog

      Did you install the plugin?