Page 1 of 2

Automation

Posted: Thu Nov 11, 2010 8:22 pm
by w i l l
I'm wondering if anyone could give me some advice on automating a render.

I would have a scene setup with a book. I want to create some kind of interface (or easier way/not manually using Maxwell) whereby someone can simply swap the image for the book cover and click render.

Maybe they would select the scene, select the image and click render within the interface... and it links to Maxwell and renders that scene without the client actually having to go into/use Maxwell.

Re: Automation

Posted: Thu Nov 11, 2010 8:28 pm
by Half Life
Would it be possible to work it like material previews and simply replace the "preview material" for the bookcover with whatever cover you want... if all other parameters stay the same it might be as easy as simply replacing the image(s) used for the reflectance maps.

Best,
Jason.

Re: Automation

Posted: Mon Nov 15, 2010 11:30 pm
by Aji Enrico
Hi Will

This is possible if
*Client uses the mxs file that has a material with an external image file.
*Client replaces the image file with another image and keeping the same name.
Then you only need to reload scene in Maxwell and restart the render. The scene will use that new image for rendering just as you wanted(?).

With this solution client need Maxwell installed locally but the task can simply be replaced by a batch file, so no need to click in the Maxwell application.
Is this what you where looking for? Or are you looking of a different complete solution?

Aji

Re: Automation

Posted: Tue Nov 16, 2010 8:35 am
by w i l l
Hi,

Yeah that is what I'm looking for? Could you give me any tips on how to do it?

Thanks

Re: Automation

Posted: Tue Nov 16, 2010 2:19 pm
by Aji Enrico
Hope this is not too technical. Create a bat file with this commands below
Code: Select all
cd %MAXWELL2_ROOT%\
maxwell.exe -mxs:c:\testfolder\cornell_v2.mxs -sl:8
This will use the cornell scene located in c:\testfolder\ and use sample level of 8
Other switches you might wanna use is -time and -nogui. All of the switches can be found if you type maxwell.exe -help in console.

As i said previously, you need to setup a scene where it uses an external image so that the client can replace it. (make sure the image is referenced correctly in the mxs file)

Let me know if I just confused you, this is a bit technical with the .bat file and switches.

Re: Automation

Posted: Tue Nov 16, 2010 9:23 pm
by w i l l
Nice one, thanks. That worked.

Can it be done so that the user selects a folder of images with various file names (but all the same size though) and it auto pulls those onto the book cover, then renders each image?

Re: Automation

Posted: Wed Nov 17, 2010 4:01 am
by Aji Enrico
w i l l wrote:Nice one, thanks. That worked.

Can it be done so that the user selects a folder of images with various file names (but all the same size though) and it auto pulls those onto the book cover, then renders each image?
Yes it can, and now it gets really complicated :)
By the way, let me know if I made the explanation too complex.

2 Things to keep in mind!

1)
Maxwell script can do this in numerous ways. One way is to render each scene fully the other way is interactive, and that is really neat! :)

The interactive way will react to when the client changes images on the fly and will rewrite a new mxi (you can keep the old one or overwrite it)
If you want to have a good start with the interactive mode, you can use the progressive script as a starting point.
I made one script as a proof of concept based on that script and it works, big code shown below. This concept can do animation as well.

2)
To enable the "select a folder of images with various file names" you would possibly need to use an external application with maxwell script command:
Code: Select all
int launchProcessAndWait (string execPath, array arguments);
Like command/batch file is one solution: (where sceneImage.bmp would be the image Maxwell uses that you need to replace.)
Code: Select all
cmd /c del c:\folderWithImages\sceneImage.bmp
cmd /c ren c:\folderWithImages\clientImage1.bmp sceneImage.bmp

followed by:

cmd /c del c:\folderWithImages\sceneImage.bmp
cmd /c ren c:\folderWithImages\clientImage2.bmp sceneImage.bmp
etc..
Or forget all of the above and you could control it all from an external application... but then it has to be a custom written application :) Just like my MXM Updater is for updating material previews http://www.maxwellrender.com/forum/view ... 97&t=35515


Now to show you how I did that interactive script, I will share my Maxwell script code as I explained above as proof of concept. The one based on progressive_animation.ms. The quick and dirty solution I did was to make Maxwell react to changes in number of files in inputFolder (c:\mxm\m). I know that's not the most elegant way but as proof of concept it works. There are other ways but hey, short on time here ;)
Code: Select all
//  This script gets all the mxs's located in the folder "input"
//  Renders them until a desired Initial SL, to get a first version of the whole sequence, allowing the user to start the postproduction process 
//  Then continues refining the sequence until the Final SL, advancing in certain steps (slStep), offering continuous refinement 


// Edit the following lines with your own project Input and Output folders 

var inputFolder = "C:\mxm\m\";
var outputFolder = "C:\mxm\m";

var mxsCount =  FileManager.getNumberOfFilesInFolder( inputFolder, "*.mxs" );
var mxsList = FileManager.getFilesInFolder( inputFolder, "*.mxs" );

RenderEvents["renderFinished()"].connect(renderHasFinished);

// The following SL values can be customized to fit your needs

var initialSL = 1;
var finalSL = 12;
var slStep = 1;
var currentSL = initialSL;
var initialNum = FileManager.getNumberOfFilesInFolder(inputFolder,"*.*");
var currentNum = FileManager.getNumberOfFilesInFolder(inputFolder,"*.*");


var i = 0;
var isRendering = 0;

while( currentSL <= finalSL )
{
  for( i = 0; i < mxsCount; i++ )
  {
    renderScene();
    while( 1 )
    {
      if( isRendering == 0 )
      {
          break;
      }
    }
  }

  currentSL += slStep;
}



//////////////////////////////////////////////////////////////////

function renderScene()
{
  var mxsFile = mxsList[i];
  var imagePath = outputFolder + "\" + FileManager.getFileName( mxsFile ) + ".png";
  var mxiPath = outputFolder + "\" + FileManager.getFileName( mxsFile ) + ".mxi";

  Maxwell.print( "***************************************************rendering Mxs file: " + mxsFile );

  Maxwell.openMxs( mxsFile );
  Scene.setImagePath( imagePath );
  Scene.setMxiPath( mxiPath );
  Scene.setSamplingLevel( currentSL );
// Uncomment the following lines if you want to set a different resolution than the indicated in the MXS scene file 
//  Scene.setResX( 400 );
//  Scene.setResY( 400 );
  currentNum = FileManager.getNumberOfFilesInFolder(inputFolder,"*.*");
  Maxwell.print("***************************************************:initial vs current: " + initialNum + currentNum);

  if(currentSL == initialSL)
  {
    Scene.setResumeRenderEnabled( false );
  }
  else
  {  
    if(initialNum == currentNum){
      Maxwell.print("***************************************************:initial == current: " + initialNum + currentNum);
      Scene.setResumeRenderEnabled( true );
    }
    else{
      Maxwell.print("***************************************************:initial != current: " + initialNum + currentNum);
      Scene.setResumeRenderEnabled( false );
      initialNum = currentNum;
    }
  }
  isRendering = 1;
  Maxwell.startRender();
}

//////////////////////////////////////////////////////////////////

function renderHasFinished()
{
  isRendering = 0;

  Maxwell.print( "***************************************************Render finished!!" );
}

//////////////////////////////////////////////////////////////////


Re: Automation

Posted: Wed Nov 17, 2010 4:07 am
by Half Life
:shock: This has the be the coolest thread ever! :D

Thank-you, again.

Best,
Jason.

Re: Automation

Posted: Wed Nov 17, 2010 1:03 pm
by Mihai
Great post Aji! Thanks for taking the time...

Re: Automation

Posted: Sun Nov 21, 2010 1:27 pm
by w i l l
Wow thanks! I'll try it.

Re: Automation

Posted: Mon Nov 22, 2010 2:55 am
by Aji Enrico
Hi again Will :)

After some PMs between Will and me (PM in plural :P), and after some thoughts about the concept, the idea which Will brought up... I just thought "Why not?"
I really liked his idea that much so I made myself a prototype version of it:
Screenshot.png
Wills_Automation.zip
What you do, how to use it:
1) Browse to your MXS file.
2) Select the image which you want to swap in each render.
3) Chose the folder that contains the images you want to swap with, each image will produce one render
4) Select the output folder for each render.

Things to know about the application:

1) Use at your own risk!

2) You should use Pack & Go and update the reference paths in the mxs scene file. I'm guessing Maxwell has a bug with handling references "-bitmaps:[path]" doesn't work

3) You should, but don't need to, use the default folder structure described below
Code: Select all
Example_Folder\client_images - add all of the images the client would like to use here
Example_Folder\designer_files - place your MXS scenes and images here (use pack and go)
Example_Folder\output_folder - output folder of all scene renders, mxi + jpg
Probably some bugs here and there, just let me know if you want them fixed.

Aji

Re: Automation

Posted: Mon Nov 22, 2010 2:59 am
by w i l l
Ha...... jokes.

Re: Automation

Posted: Mon Nov 22, 2010 3:03 am
by Half Life
Yikes! :shock: :shock: :shock: :lol: :cry: :shock: :shock: :shock: :mrgreen:

Too cool, this is definitely an awesome thread and you are so awesome for sharing!

Best,
Jason.

Re: Automation

Posted: Mon Nov 22, 2010 3:09 am
by w i l l
I'm wondering if you could help me. I'm looking for an application, similar to Maxwell Render, but at least 30x as fast. Could you code that for me? Deadline is 2am tomorrow. Thanks very much.

Re: Automation

Posted: Mon Nov 22, 2010 3:12 am
by w i l l
.... and I want it to be named 'Will's Render'.