Beer glass scene creation
This course contains a little bit of everything with modeling, UVing, texturing and dynamics in Maya, as well as compositing multilayered EXR's in Photoshop.
# 1 25-07-2011 , 04:13 PM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095

File name prefix and Layer names

what first seemed to be an easy task turned out to break my head right now.
What I need to do is (for many many files and layers) to output rendered files in a special folder structure:


folder name = "myName"+"currentTime"
image name = renderLayer


I have no idea how to output files in these custom folders exept for <Layer><Scene><Camera><Version>, and the documentation is kind of a 2 sentence loop. (using maya 8.5) I also seems to be impossible to put mel code into the File name prefix input field..

many thanks in advance!


everything starts and ends in the right place at the right time.
# 2 17-08-2011 , 05:37 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
myName being what? Your windows username?


Imagination is more important than knowledge.
# 3 20-08-2011 , 06:15 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
Hi pal,

"myName" will be derived from the textures used at render time. in this case:

textureFolder001
textureFolder002
.
.
.
textureFolder260

thanks for your participation!


everything starts and ends in the right place at the right time.
# 4 20-08-2011 , 07:55 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
So for example, you have a texture folder named textureFolderA, and you're rendering frame 1, and rendering the diffuse pass. Should it look like this?

textureFolderA001/diffuse.tga?

What exactly are you trying to do?


Imagination is more important than knowledge.
# 5 21-08-2011 , 09:47 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
to be more precise:


I have a model of a shirt broken up into many different parts like torso (slim, medium, large, and different shapes), long and short sleeves, many different collars and cuffs. these objects are arranged on renderlayers to make a big PSD file out of all layers per texture. there will be 260 different textures which all have to be applied once to all geometry variations. I was thinking that objects (renderlayers) x textures (timeline) is a good way to start.

I need a one PSD file with all objects in single layers per texture in it. so in the end there will be 250 PSD files named like Pattern001.PSD, ..., Pattern260.PSD containing something like 200 layers called:

shirtFront1_slim_pattern132
..
shirtBack3_medium_pattern132
..
collar24_pattern132
..
cuff18_pattern132


I hope this helps to understand. I dont render passes with shadows, diffuse, specular, etc. just a complete beautypass per object (on renderlayers named like "shirtBack3_medium_", etc...) but I want to make maya output all layers in a per frame (per texture) way. then I could simply import all textures of one folder into Photoshop via Scripts-> Load Files into Stack. the layers will have the same name than the files. voilá! mission accomplished!

thanks!


everything starts and ends in the right place at the right time.
# 6 21-08-2011 , 04:08 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Sorry mate. Would it be possible for you to create a test file, so I can try to figure it out?


Imagination is more important than knowledge.
# 7 22-08-2011 , 07:12 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
if you´re so kind to invest your time, that would be really great. I´ll put a scene together for you later today. thanks a lot man!


everything starts and ends in the right place at the right time.
# 8 22-08-2011 , 08:32 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
ok, here is a simple test scene. all geometry parts are assigned to the correspondent render layers. I´ve also added a info group node which tells again what I would need to do.

thanks for taking the time again!

Attached Files
File Type: zip shirtTestScene.zip (375.9 KB, 198 views)

everything starts and ends in the right place at the right time.
# 9 23-08-2011 , 03:10 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Cool, thanks. I'll take a look for ya!

Just to be clear, you want to use this on a renderfarm right? And is this the only way for this to work?


Imagination is more important than knowledge.

Last edited by NextDesign; 23-08-2011 at 03:16 AM.
# 10 23-08-2011 , 06:52 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
that´s the only way I could imagine. if you find an easier solution, I´m up for anything that works. and in case of correctional work (which will come for sure!) I don´t want to make tons of manual changes. keep in mind that I have at least (because the project is growing since it started):

150 objects on 150 layers
260 textures on timeline

for each variation 3 camera perspectives (3 single scenes)

equals 1.170.000 stills for now.

a must is to have 1 folder for every texture containing all geometries, with the objects named after the layer they´re applied to.


everything starts and ends in the right place at the right time.
# 11 23-08-2011 , 05:49 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Hey Falott. This won't work on the farm, but it will work on your local machine. Better to have something being rendered while we try to figure this out user added image

(Also, by the way, you have 17,550,000 renders in total. 150*150*260*3 user added image)

Set your basePath, texturePath, first, and last frame, turn off file sequence and delete the expression in your texture, and you'll be good to go.

Code:
string $texture = ($texturePath + "shirt_" + $i + ".png");
Is where you'll set the names of the textures (in this case, shirt_[firstFrame->lastFrame].png)

Code:
string $basePath = "G:/Projects2011/shirtTestScene/renderedTextures/";
string $texturePath = "G:/Projects2011/shirtTestScene/textures/";

int $firstFrame = 1;
int $lastFrame = 5;

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

// do stuff
for ($i = $firstFrame; $i <= $lastFrame; $i++)
{
    string $folderName = ("pattern" + $i);
    
    string $texture = ($texturePath + "shirt_" + $i + ".png");
    
    // change texture
    setAttr -type "string" file1.fileTextureName $texture;
    
    for ($layer in $renderLayers)
    {
        if ($layer == "defaultRenderLayer")    // ignore the default render layer
            continue;
        else
        {
            string $folder = ($basePath + $folderName);
            
            if (!`filetest -e $folder`)    // folder doesn't exist. create it.
                sysFile -makeDir ($basePath + $folderName);
                
            print ($folder + "/" + $layer + $folderName + "\n");
                
            render -l $layer; // render
            
            catch(eval(renderWindowSaveImageCallback ($renderPanel, ($folder + "/" + $layer + $folderName), `getAttr defaultRenderGlobals.imageFormat`)));
        }   
    }
}
Hopefully it does what you want! user added image


Imagination is more important than knowledge.

Last edited by NextDesign; 23-08-2011 at 08:03 PM.
# 12 24-08-2011 , 07:45 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
OH MAN! THANK YOU!

unfortunately I can soonest try this script at the beginning of next week , because I am on vacation this week. user added image but I will examine this script and try to understand it so I can kick it off asap. dude, this piece of code is appreciated so much!

the only thing I want to ask is, where do I put this mel code? into the preRender/preRender Frame section?
because if so - I can tell vertext muster to use this code as well, and everything would be fine.


everything starts and ends in the right place at the right time.
# 13 24-08-2011 , 05:48 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
It's actually just run in your script editor. As I said, it won't work on the renderfarm, unless you send different scripts to each machine.

Eg.

Machine 1: startFrame = 1 endFrame = 10
Machine 2: startFrame = 11 endFrame = 20
Machine 3: startFrame = 21 endFrame = 30
...

You MIGHT be able to put this into the pre-render frame, with startFrame and endFrame set to `currentTime -q`


Imagination is more important than knowledge.

Last edited by NextDesign; 24-08-2011 at 05:52 PM.
# 14 29-08-2011 , 04:36 PM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
after stealing some of your code from other places user added image I have my script almost working as it should. there are a few things which still give me head ache though.


Code:
string $renderPanel;       
string $renderPanels[] = `getPanel -scriptType "renderWindowPanel"`;
string $basePath = (`workspace -q -rd` + "renderOutput/");
string $renderLayers[] = `ls -type "renderLayer"`;
int $firstFrame = `currentTime -q`;
int $lastFrame = `currentTime -q`;


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




// do stuff
for ($i = $firstFrame; $i <= $lastFrame; $i++)
{
 //   RenderViewWindow;
 //   tearOffPanel "Render View" "renderWindowPanel" true;
    string $outputFolder = ("PSDmuster" + $i + "_");
    string $myDiffuseTexture = "DT_" + `currentTime -q`;
    string $myNormalTexture = "NM_" + `currentTime -q`; 

 
//connectAttr -force ($myDiffuseTexture + ".outColor") shader_gamma.value;
//connectAttr -force ($myNormalTexture + ".outAlpha") shader_bump2d.bumpValue;
    
    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);
                
            print ($folder + "/" + $layer + $outputFolder + "\n");
                
             render -l $layer shotCAM01; // render



   
           
            if (`getApplicationVersionAsFloat` >= 2011)    
                       
                catch(eval(renderWindowSaveImageCallback ($renderPanel, ($folder + "/" + $outputFolder + $layer), `getAttr defaultRenderGlobals.imageFormat`)));
                
            else
            
                renderWindowSaveImageCallback ($renderPanel, ($folder + "/" + $outputFolder + $layer), `getAttr defaultRenderGlobals.imageFormat`);


            
// catch(eval(renderWindowSaveImageCallback ($renderPanel, ($imagesDir + “/renderView.” + ($maxImageIndex – $i)), `getAttr defaultRenderGlobals.imageFormat`)));




        }   
    }
}


#1
in case files get overwritten, how can I integrate an "auto-YES, please overwrite that file" into the script?


#2
Code:
# Error: AttributeError: ImageFormats instance has no attribute 'oldOutf' #
if I replace
Code:
`getAttr defaultRenderGlobals.imageFormat`
with
Code:
"PNG"
result:
Code:
// Error:  // 
// Error: Syntax error //
without any further information on that error

basically the directory is created, rendered frame is named and placed correctly, but it is black.


#3
Code:
//connectAttr -force ($myDiffuseTexture + ".outColor") shader_gamma.value;
//connectAttr -force ($myNormalTexture + ".outAlpha") shader_bump2d.bumpValue;
if the corresponding textures are already applied,
Code:
// Warning: 'DT_2.outColor' is already connected to 'shader_gamma.value'. //
and the script stops there. I tried to make use of the catch() command, but maya always returns
Code:
// Error: Invalid use of Maya object "connectAttr". //


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

Last edited by Falott; 30-08-2011 at 10:08 AM.
# 15 30-08-2011 , 03:05 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988

#1
in case files get overwritten, how can I integrate an "auto-YES, please overwrite that file" into the script?

Before "if (`getApplicationVersionAsFloat` >= 2011)", put:

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

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

#2

Code:
# Error: AttributeError: ImageFormats instance has no attribute 'oldOutf' #
if I replace
Code:
`getAttr defaultRenderGlobals.imageFormat`
with
Code:
"PNG"
result:
Code:
// Error:  // 
// Error: Syntax error //

The AttributeError is not a problem. It still renders.

Replace `getAttr defaultRenderGlobals.imageFormat` with 32 (the file extension enumeration index).

Eg.

Code:
renderWindowSaveImageCallback ($renderPanel, ($folder + "/" + $outputFolder + $layer), 32);

#3

Code:
connectAttr -force ($myDiffuseTexture + ".outColor") shader_gamma.value;
connectAttr -force ($myNormalTexture + ".outAlpha") shader_bump2d.bumpValue;
if the corresponding textures are already applied,
Code:
// Warning: 'DT_2.outColor' is already connected to 'shader_gamma.value'. //
and the script stops there. I tried to make use of the catch() command, but maya always returns
Code:
// Error: Invalid use of Maya object "connectAttr". //

Not sure what the problem is there. Did you put:
Code:
catch(eval(connectAttr -force ($myDiffuseTexture + ".outColor") shader_gamma.value));
?


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