Complex UV Layout in Maya
Over the last couple of years UV layout in Maya has changed for the better. In this course we're going to be taking a look at some of those changes as we UV map an entire character
# 16 31-08-2011 , 08:24 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
thank you so much for taking the time to help me.

unfortunately the 'oldOutf' error still persists.

Code:
string $renderedFilename = ($folder + "/" + $outputFolder + $layer);
        if (`filetest -e $renderedFilename`)    // image exists. delete it.
            sysFile -del $renderedFilename;
doesn´t work either. I probably did something wrong.
but renderings are now outputted into specific folders + into the temp folder. weird...
I´ve tried all different kind of fu**Ups today with the scipt. it´s just getting worse..

Code:
C:/.../maya/renderOutput/PSDmuster1_/PSDmuster1_obj_A
# Error: file: C:/Program Files/Autodesk/Maya2011/scripts/others/renderWindowPanel.mel line 663: ImageFormats instance has no attribute 'oldOutf'
# Traceback (most recent call last):
#   File "<maya console>", line 1, in <module>
#   File "C:\Program Files\Autodesk\Maya2011\Python\lib\site-packages\maya\app\general\createImageFormats.py", line 185, in popRenderGlobals
#     cmds.setAttr("defaultRenderGlobals.outf", self.oldOutf)
# AttributeError: ImageFormats instance has no attribute 'oldOutf' #
could it be that the renderWindowPanel.mel is hacked dead by the autodesk crew? just a question, lol - error is most likely on my side.

to make things easier I´ve added a very simplified projectFolder for you. I hope the script editor still holds executed script and error results when you open it. you´ll find the adapted mel script in the mel folder as well. I guess after a quick look at the scene from your side you´ll find a solution pretty fast.

PS: don´t mind the animated camera- and lightsetup. there will be 3 different scenes in the end with static cameras.

besides the annoying oldOutf error, I´d have one more question for you if I may:
to speed up rendertimes in the end I´d like to flag some renderlayers with -reg <int><int><int><int>
right now there is this for ($layer in $renderLayers) loop which takes all layers at once into account. what if i were to tell maya instead of

Code:
render -l $layer shotCAM01;
something like this

Code:
render -l obj_A shotCAM01;
render -l obj_B shotCAM01;
render -l obj_C shotCAM01 -reg <int><int><int><int>;
render -l obj_D shotCAM01 -reg <int><int><int><int>;
render -l obj_E shotCAM01 -reg <int><int><int><int>;

but still make the script pop out folder- and file names correctly? it is not a must, but it could save way more than 50% render time for this project.


all best for now! and I hope to stop stealing your time soon user added image

Attached Files
File Type: zip maya.zip (363.0 KB, 424 views)

everything starts and ends in the right place at the right time.

Last edited by Falott; 31-08-2011 at 03:42 PM.
# 17 31-08-2011 , 11:58 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
I said, the oldOutf error is not a problem. Ignore it. It's handled.

What do you mean by -reg<int><int><int><int>? There is no such flag.


Imagination is more important than knowledge.
# 18 01-09-2011 , 04:05 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
if you say it´s handled, then ok. just thought when maya renders 1 sec for each layer and creates a black image, while popping out these errors..

sorry, i meant:
-reg int int int int Set sub-region pixel boundary of the final image:
left, right, bottom, top

because there are a lot of small parts to be rendered. but again, it is no must. there are just 3 categories of objects to be rendered with sub-region boundary. for these I can create 3 different scene files with the script adapted like
Code:
render -l $layer -reg int int int int shotCAM01;
priority is to make mental ray render the images which it doesn´t yet. all renderings are black right now.


everything starts and ends in the right place at the right time.

Last edited by Falott; 01-09-2011 at 04:37 AM.
# 19 01-09-2011 , 02:53 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Oh. You mean when you send it through the command line, not through MEL. That's what confused me.


Imagination is more important than knowledge.
# 20 01-09-2011 , 03:19 PM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
sorry for being so imprecise.. I am use to look at mel code for years, but I just start to really learn that right now, since there is a demand for it at my new office. I am a modeller/texturer, little bit of animator naturally. but here it´s all about rendering, and that´s a completely new field of work for me.

basically I dont need to send it over the render farm. would be nice though, but if that code works on local machines only and does what needs to be done I am absolutely fine with it.

else

if you ever need help with something modeling related at any time (be it reviewing tasks, testModels, whatever...) please don´t hesitate to ask me. I´d be happy to offer any kind of support. you´re really saving my life here dude! I couldn´t have done this without your help for sure.

all best!


everything starts and ends in the right place at the right time.
# 21 01-09-2011 , 09:19 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
And they don't have a TD? Strange...

Also, usually if I knew this was for a studio, I'd charge. Don't worry about it this time though, my fault for not asking! user added image

Here are the fixes.

Code:
string $basePath = "/usr/Desktop/maya/renderOutput/";
string $texturePath = "/usr/Desktop/maya/texture/";
string $textureFormat = "png";

string $renderLayers[] = `ls -type "renderLayer"`;

int $firstFrame = 1;
int $lastFrame = 2;

// check for render panel
string $renderPanel;       
string $renderPanels[] = `getPanel -scriptType "renderWindowPanel"`;

if(size($renderPanels)) 
    $renderPanel = $renderPanels[0];
else
{
    $renderPanel = `scriptedPanel -type "renderWindowPanel" -unParent renderView`;

    scriptedPanel -e -label "Render View" $renderPanel;
}

// get the image format in the render globals
int $format = `getAttr "defaultRenderGlobals.imageFormat"`;
string $extension = "";

switch($format)
{
    case 0: $extension = "gif"; break;
    case 1: $extension = "pic"; break;
    case 2: $extension = "rla"; break;
    case 3: $extension = "tif"; break;
    case 4: $extension = "tif"; break;
    case 5: $extension = "sgi"; break;
    case 6: $extension = "als"; break;
    case 7: $extension = "iff"; break;
    case 8: $extension = "jpg"; break;
    case 9: $extension = "eps"; break;
    case 10: $extension = "iff"; break;
    case 11: $extension = "cin"; break;
    case 12: $extension = "yuv"; break;
    case 13: $extension = "sgi"; break;
    case 19: $extension = "tga"; break;
    case 20: $extension = "bmp"; break;
    case 22: $extension = "mov"; break;
    case 30: $extension = "pntg"; break;
    case 31: $extension = "psd"; break;
    case 32: $extension = "png"; break;
    case 33: $extension = "pict"; break;
    case 34: $extension = "qtif"; break;
    case 35: $extension = "dds"; break;
    case 36: $extension = "psd"; break;
}

// do stuff
for ($i = $firstFrame; $i <= $lastFrame; $i++)
{
    string $outputFolder = ("PSDmuster" + $i);

    string $myDiffuseTexture = ($texturePath + "DT_" + $i + "." + $textureFormat);
    string $myNormalTexture = ($texturePath + "NM_" + $i + "." + $textureFormat);

    for ($layer in $renderLayers)
    {
        if ($layer == "defaultRenderLayer")    // ignore the default render layer
            continue;
        else
        {
            string $folder = ($basePath + $outputFolder);

            if (!`filetest -e $folder`)    // folder doesn't exist. create it.
                sysFile -makeDir ($basePath + $outputFolder);

            string $renderedFilename = ($folder + "/" + $outputFolder + "_" + $layer);

            if (`filetest -e ($renderedFilename + "." + $extension)`)    // image exists. delete it.
                sysFile -del ($renderedFilename + "." + $extension);
                
            // change texture
            setAttr -type "string" tex.fileTextureName $myDiffuseTexture;
            
            // render - nasty hack
            render -l $layer;
            renderWindowRender redoPreviousRender renderView;

            if (`getApplicationVersionAsFloat` >= 2011)    
                catch(eval(renderWindowSaveImageCallback ($renderPanel, $renderedFilename, $format)));
            else
                renderWindowSaveImageCallback ($renderPanel, $renderedFilename, $format);    
        }   
    }
}


Imagination is more important than knowledge.

Last edited by NextDesign; 01-09-2011 at 09:23 PM.
# 22 05-09-2011 , 03:36 PM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
thank you man. I´ve altered the script just a tiny little. it´s working perfect now.

I will post a final version of the script here as soon as I have finished all model/texture work. then I will see if the texture node thing needs some adjustment. (I´ve added an extra attribute "textureRealName" to the fileNodes, since they have to be named according to timeline right now.)

Code:
string $renderCAM = "shotCAM01";
string $basePath = (`workspace -q -rd` + "renderOutput/");
string $textureFormat = "png";
string $renderLayers[] = `ls -type "renderLayer"`;

int $firstFrame = 1;
int $lastFrame = 3;

// check for render panel
string $renderPanel;       
string $renderPanels[] = `getPanel -scriptType "renderWindowPanel"`;

if(size($renderPanels)) 
    $renderPanel = $renderPanels[0];
else
{
    $renderPanel = `scriptedPanel -type "renderWindowPanel" -unParent renderView`;

    scriptedPanel -e -label "Render View" $renderPanel;
}

// get the image format in the render globals
int $format = `getAttr "defaultRenderGlobals.imageFormat"`;
string $extension = "";

switch($format)
{
    case 0: $extension = "gif"; break;
    case 1: $extension = "pic"; break;
    case 2: $extension = "rla"; break;
    case 3: $extension = "tif"; break;
    case 4: $extension = "tif"; break;
    case 5: $extension = "sgi"; break;
    case 6: $extension = "als"; break;
    case 7: $extension = "iff"; break;
    case 8: $extension = "jpg"; break;
    case 9: $extension = "eps"; break;
    case 10: $extension = "iff"; break;
    case 11: $extension = "cin"; break;
    case 12: $extension = "yuv"; break;
    case 13: $extension = "sgi"; break;
    case 19: $extension = "tga"; break;
    case 20: $extension = "bmp"; break;
    case 22: $extension = "mov"; break;
    case 30: $extension = "pntg"; break;
    case 31: $extension = "psd"; break;
    case 32: $extension = "png"; break;
    case 33: $extension = "pict"; break;
    case 34: $extension = "qtif"; break;
    case 35: $extension = "dds"; break;
    case 36: $extension = "psd"; break;
}

// do stuff
for ($i = $firstFrame; $i <= $lastFrame; $i++)
{
    string $outputFolder = ("PSDmuster" + $i + "_" + $renderCAM);
    string $textureNode = ("DT_" + $i);


    for ($layer in $renderLayers)
    {
        if ($layer == "defaultRenderLayer")    // ignore the default render layer
            continue;
        else
        {
            string $folder = ($basePath + $outputFolder);

            if (!`filetest -e $folder`)    // folder doesn't exist. create it.
                sysFile -makeDir ($basePath + $outputFolder);

            string $renderedFilename = ($folder + "/" + $outputFolder + "_" + $layer);

            if (`filetest -e ($renderedFilename + "." + $extension)`)    // image exists. delete it.
                sysFile -del ($renderedFilename + "." + $extension);
                

            catch(`connectAttr -force ($textureNode + ".outColor") shader_gamma.value`);    // --> catch(`connectAttr`) <-- if fileTextureNode is already connected to gammaCorrectNode, continue.
          
            // render - nasty hack
            render -l $layer $renderCAM;
            renderWindowRender redoPreviousRender renderView;



            if (`getApplicationVersionAsFloat` >= 2011)    
                catch(eval(renderWindowSaveImageCallback ($renderPanel, $renderedFilename, $format)));
            else
                renderWindowSaveImageCallback ($renderPanel, $renderedFilename, $format);    
			}
		}
	}


everything starts and ends in the right place at the right time.
# 23 06-09-2011 , 05:48 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Why are you changing the texture node each iteration? Why not just change the texture's path? It'll be faster.


Imagination is more important than knowledge.
# 24 06-09-2011 , 05:05 PM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
ah, it´s simply because each tileTexture isn´t tiled 1:1. about 80% of all textures have a tiling of 2,83 : 2,65 and so on. another advantage of this method is that I can add an extra attribute "realTextureName" to the fileNodes. this attribute could be called then to add another string to the rendered image files and the destination folder. because names like texture_1 to texture_250 is somewhat meaningless.


everything starts and ends in the right place at the right time.
# 25 07-09-2011 , 02:50 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Ah, alright, awesome. Glad it worked out for you!


Imagination is more important than knowledge.
# 26 07-09-2011 , 06:50 PM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
thanks to you! Couldn´t have done that alone. this correspondence with you really encouraged me to learn MEL now. I am used to fighting with mel script since years now but I never was able to wrap my brain around it. this is the first time for me that getting into mel was kind of fun and not just a pure pain in the ass.

You Rock Dude!


everything starts and ends in the right place at the right time.
# 27 08-09-2011 , 01:57 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
No problem mate, glad to help user added image

MEL scripting is definitely a useful skill, not just for TDs, but artists as well.


Imagination is more important than knowledge.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off