Home Technical Talk

Auto Texture Refresh for Maya?

polycounter lvl 18
Offline / Send Message
JKim3 polycounter lvl 18
Is there a plug-in or a MEL script that would allow for auto texture updating, or updating with a press of a custom button? Like, anything so I don't have to keep going into the attribute window of the shader node and such and such to refresh. I've tried looking for one and even through the settings, but I guess I'm not searching for the correct words or something.

Replies

  • CheeseOnToast
    Offline / Send Message
    CheeseOnToast greentooth
    I have one that works for Maya 4. Haven't tried it yet on later versions. I can send it on, PM me if you're interested.
  • Snowfly
    Offline / Send Message
    Snowfly polycounter lvl 18
    David Keegan's reloadTexture script. Just look it up on the page.

    http://www.highend3d.com/maya/mel/?section=rendering&sort=dt_modified+desc

    Warghoul/the EA guys have a version too.
  • JKim3
    Offline / Send Message
    JKim3 polycounter lvl 18
    Whoo. Thanks a bunch, Snowfly. Works great.

    Thanks, though, Cheese.
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    JKim3: You know, I was gonna post the exact same link Snowfly did. Guess how I found it?

    Google -> "Maya reload texture script" ... it really is as easy as that. Saves time and effort on everyone's part if you just Google it before making a new thread wink.gif

    MoP
  • JKim3
    Offline / Send Message
    JKim3 polycounter lvl 18
    Hey, I did google it. Like I said, I probably used the wrong words. I was searching for 'refresh' and 'plug-in'
  • Steve Schulze
    Offline / Send Message
    Steve Schulze polycounter lvl 18
    You can just bind the right-hand-side toolbar menu that has texture info on it, inluding the reload button, to a key. Then you won't have to have that annoying little menu with one button on it cluttering up your screen.
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    Or make a new hoykey with this as it's script:

    <font class="small">Code:</font><hr /><pre>
    //global proc CRupdateTexAll(){
    {
    waitCursor -state on;
    string $fileTextures[] = `ls -tex`;
    int $count=0;
    source AEfileTemplate.mel;
    for ($node in $fileTextures)
    {
    if (`attributeQuery -node $node -ex fileTextureName`)
    {
    AEfileTextureReloadCmd ($node+".fileTextureName");
    $count = ++$count;
    }
    }
    waitCursor -state off;
    print ("Reloaded "+$count+" textures"+"\n");
    }
    </pre><hr />

    I wrote this about 5 years ago smile.gif
  • Phobos
    Offline / Send Message
    Phobos polycounter lvl 18
    Thanks Whargoul.
    Just used that script for a new key smile.gif Saves a ton of time.
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    Many thanks, Whargoul! I used to have that saved but didn't have it backed up before I had to get a new hard drive...

    Is there any way that it could be set up to just reload a specific texture with a hotkey, instead of all textures in a scene?
    Like if I was to call my texture node "WIP_Texture" or something similarly identifiable, could I edit the script to affect only that specific texture node?

    MoP
  • Snowfly
    Offline / Send Message
    Snowfly polycounter lvl 18
    MoP, david keegan's script lets you do exactly that.
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    I think it's pretty fast at reloading anyways, if you only change a single texture. I never noticed any big slow-downs when reloading a scene with multiple texutre, with only 1 changed. But maybe I'm lucky smile.gif

    If you wanted to just reload a single texture node, just change it like this:

    <font class="small">Code:</font><hr /><pre>
    //global proc CRupdateTexAll(){
    {
    string $node = "myNode";
    waitCursor -state on;
    source AEfileTemplate.mel;
    if (`attributeQuery -node $node -ex fileTextureName`)
    AEfileTextureReloadCmd ($node+".fileTextureName");
    waitCursor -state off;
    }
    </pre><hr />

    And change "myNode" to the name of the node you want reloaded.
  • malcolm
    Offline / Send Message
    malcolm polycount sponsor
    Reloading all textures eats up all the ram really quick on both my home pc and the ghetto one I have at work. Ryan wrote me a script which reloads textures on selected objects which is pretty nice except it has a work around on which is annoying. Do you want to write a better one?
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    What's the crappy work around? It should be pretty easy to make one reload only selected object's textures.
  • Jeff Parrott
    Offline / Send Message
    Jeff Parrott polycounter lvl 19
    mmmm... script to reload selected object's textures. Lemme show a full blown Mel scripter this thread and see if he can whip that up.
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    I like Whargoul's version - I just name my WIP texture node "working", and hit Alt-R to run the script. Since I'm only ever working on one texture at a time, it leaves all the others in the scene untouched and only reloads the one I'm using - fast and easy. Also means I get to tear off and maximise a viewport smile.gif
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    I wrote the selected object texture refresh for malcolm already. I'll post it later. (it's on my work machine)
  • Whargoul
    Offline / Send Message
    Whargoul polycounter lvl 18
    Here's one I wrote for just updating the textures on the selected objects:

    <font class="small">Code:</font><hr /><pre>
    //global proc CRupdateTexSelected()
    {
    waitCursor -state on;
    source AEfileTemplate.mel;
    string $mats[];
    string $files[];
    string $sel[]=`ls -sl -tr -l`;

    for ($node in $sel)
    {
    string $shapes[] = `listRelatives -f -s -ni $node`;
    for ($shape in $shapes)
    {
    string $sgs[] = `listConnections -d 1 -s 0 -p 0 -t "shadingEngine" $shape`;
    for ($sg in $sgs)
    {
    if (`connectionInfo -id ($sg+".surfaceShader")`)
    {
    string $matCon = `connectionInfo -sfd ($sg+".surfaceShader")`;
    $mats[`size($mats)`] = `match "[^.]*" $matCon`;
    }
    }
    }
    }
    $mats = `stringArrayRemoveDuplicates $mats`;
    for ($mat in $mats)
    {
    string $nodes[] =`listHistory $mat`;
    for ($node in $nodes)
    {
    if (`nodeType $node`=="file" || `nodeType $node`=="psdFileTex")
    $files[`size($files)`]=$node;
    }

    }
    $files = `stringArrayRemoveDuplicates $files`;
    int $count=0;
    int $count2=0;
    for ($file in $files)
    {
    if (`attributeQuery -node $file -ex fileTextureName`)
    {
    string $theFile = `getAttr ($file+".fileTextureName")`;
    if (`filetest -r $theFile`)
    {
    AEfileTextureReloadCmd ($file+".fileTextureName");
    $count++;
    }
    else $count2++;
    }
    }
    if ($count2) print ("Reloaded "+$count+" texture"+ ($count>1?"s":"")+", skipped "+$count2 +" texture"+ ($count2>1?"s":"")+"\n");
    else print ("Reloaded "+$count+" texture"+ ($count>1?"s":"")+"\n");
    waitCursor -state off;
    }
    </pre><hr />

    I added a few nice things:
    * It does file nodes & psd file nodes
    * It does all maps in the shader heirarchy
    * Doesn't try to reload missing map files (when you get stuff from other people, eg.)
  • Jeff Parrott
    Offline / Send Message
    Jeff Parrott polycounter lvl 19
    Great Whargoul.
  • AstroZombie
    Offline / Send Message
    AstroZombie polycounter lvl 18
    As a loyal Max user I will take this as a small victory tongue.gif
  • Jeff Parrott
    Offline / Send Message
    Jeff Parrott polycounter lvl 19
    Bah!

    Works great Whargoul, thanks.
Sign In or Register to comment.