The Textures Naming Convention Nightmare!
In the wonderful world of VFX, if you are a Texture Artist you are probably jumping between Mari, ZBrush and Mudbox, resulting in a lot of friction when it comes to import textures from a package into another.
Why the hell did The Foundry, Pixologic and Autodesk decide to use a different naming convention?
Mari: Color.1001.exr, Color.1002.exr, Color.1010.exr...
ZBrush: Color_u0_v0.exr, Color_u1_v0.exr, Color_u9_v0.exr...
Mudbox: Color_u1_v0.exr, Color_u2_v0.exr, Color_u10_v0.exr...
Notice how ZBrush and Mudbox are BFFL and make your job easier by having a cute offset!
Ultimately I prefer Mari one for the following reasons:
You can deal with your textures as if they were images sequences, making Nuke an excellent texturing companion or any compositing package for that matter.
Easy to shift the UVs shells without too much thinking.
Fast to read and understand.
If you have 3 UVs shells, fine you can rename your textures manually, but what if you have around 100 UVs shells like on Prometheus Magellan and Juggernaut spaceships or multiple hundreds like on some Avatar vehicles?
A few years back I wrote a simple command line Python script to convert from ZBrush to Mari, but since I have been working with Mudbox recently, I decided to refactor it to convert in any directions.
Here it is: renameTextures.py
Given the following directory content:
~/textures » ls -l
total 0
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:56 Color_u0_v0.exr
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:57 Color_u1_v0.exr
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:57 Color_u9_v0.exr
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:57 Color_u9_v1.exr
Assuming those textures are coming from ZBrush, you can issue the following command to convert them to Mari:
python renameTextures.py -i zbrush -o mari *.exr
And you should have an output similar to this one:
'renameTextures' | Rename '/Users/kelsolaar/textures/Color_u0_v0.exr' texture to '/Users/kelsolaar/textures/Color_1001.exr'.
'renameTextures' | Rename '/Users/kelsolaar/textures/Color_u1_v0.exr' texture to '/Users/kelsolaar/textures/Color_1002.exr'.
'renameTextures' | Rename '/Users/kelsolaar/textures/Color_u9_v0.exr' texture to '/Users/kelsolaar/textures/Color_1010.exr'.
'renameTextures' | Rename '/Users/kelsolaar/textures/Color_u9_v1.exr' texture to '/Users/kelsolaar/textures/Color_1020.exr'.
Now your directory content should be the following:
~/textures » ls -l
total 0
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:56 Color_1001.exr
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:57 Color_1002.exr
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:57 Color_1010.exr
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:57 Color_1020.exr
Changing from Mari to Mudbox would be done like this:
python renameTextures.py -i mari -o mudbox *.exr
You can also decide to rename the files using the -n parameter:
python renameTextures.py -i mari -o mudbox -n Nemo_ *.exr
Your new directory content should be the following:
~/textures » ls -l
total 0
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:57 Nemo_u10_v1.exr
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:57 Nemo_u10_v2.exr
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:56 Nemo_u1_v1.exr
-rw-r--r-- 1 kelsolaar admin 0 20 Dec 23:57 Nemo_u2_v1.exr
If you want to strip the name entirely and just keep the UVs shells identifiers, you can do this ( Don't forget the quotes! ):
python renameTextures.py -i mudbox -o mari -n "" *.exr
If you only want to only preview your changes you can use the -p parameter:
python renameTextures.py -i mari -o mudbox -p *.exr
Now if you don't have Python on your system ( You should really install it :) ) you can use your Maya or Softimage Editor but it will be a bit more convoluted!
Assuming the renameTextures.py script is in your preferences or anywhere in your PYTHONPATH, you need to list your textures and call the renameTextures function on them:
import os
import re
import renameTextures
DIRECTORY = "/Users/kelsolaar/textures"
PATTERN = "\.exr$"
TEXTURES = filter(lambda x: re.search(PATTERN, x), [os.path.join(DIRECTORY, texture) for texture in os.listdir(DIRECTORY)])
renameTextures.renameTextures(TEXTURES, input="mari", output="zbrush", preview=True)
Last thing but not the least, Jens Kafitz offers a Perl script that does a very similar job: maprename
I gave a try at it on my Mac Os X and it was fine, but was having issues on Cent OS 6 at work!
That's it!
Don't hesitate if you have any questions, requests, issues or whatever! :)