Maya relative texture paths

Hello

I have a game project that uses textures from multiple different folders. I would like Maya to use file paths that are relative to the .ma file. I cant get it to work. This is how I’m attempting to get it to work

I set the project to where the .ma file is located.

I modify the workspace.mel to find the extra texture folder
workspace -fr “images” “../../../Art/Shared_Textures/Tools”;
(I might have the number of ../ wrong here)

Textures that are below or inside the folder that contains the .ma file have a path similar to this
Textures/PhoenixRacewayLogo_d.png

Textures in ‘external’ folders display the full path name eg
/Users/fob/F1-Clash/Art-Source-Repo/Art/Shared_Textures/Tools/UV_grid.png

Q1. I’m assuming if it’s working correct I shouldn’t have a forward slash at the begining of the file path?

thanks

I can get the file node to use the relative path (and it displays the texture in the viewport)

but I cant get the filepath editor to display the relative path

only way to get relative paths to work is through altering the .ma file
when you open the file in maya all textures should be linked correctly if you altered the paths correctly, the problem is that when you save the file, the relative paths turn into absolute paths again.

1 Like

You can use environment variables in Maya.env. If you have:

C:\texture_root\one\path\to\my\texture.tga
C:\texture_root\another\path\to\my\texture.tga

you can add an environment variable line to your ../Documents/maya/20XX/Maya.env file

TEXTURE_ROOT=C:\texture_root

and then reference the textures using $TEXTURE_ROOT in the filenode path field

$TEXTURE_ROOT\one\path\to\my\texture.tga
$TEXTURE_ROOT\another\path\to\my\texture.tga

you can even do this multiple times for different roots.

EDIT: Some pipeline frameworks can’t handle this.

1 Like

@Mambo4 Brilliant. I can can confirm this works on MacOS.

(for anybody reading this in the future, I used this Autodesk doc to set the .env Help)

For anybody else reading this in future, another possible solution is to set the Maya project further up the path tree so

instead of the setting the Maya project to /art_repo/Maya/Fire_And_Ice_World/

set it to /art_repo/Maya

so fingers crossed if there are textures referenced inside the Fire_And_Ice_World AND /art_repo/Shared_Textures/ Maya should find them all with relative paths