PDA

View Full Version : Render Big Images with Mental Ray (Tile Rendering)


freelancer-2
09-20-2004, 07:36 AM
Finale I find decision how to render regions with Mental Ray.
A lot of thanks to Sergey Ptitsin (russian Maya instructor)

here's a secret attribute for render region:
create some dynamic attributes (integers) in the 'node
mentalrayGlobals' and name them:
regionRectX
regionRectY
regionRectWidth
regionRectHeight
they will work in the interactive rendering.

The Mayatomr command has a *documented*
http://localhost:4446/Maya6.0/en_US/Commands/Mayatomr.html?hl=mayatomtor (http://localhost:4446/Maya6.0/en_US/Commands/Mayatomr.html?hl=mayatomtor)
render region support option named -rr/regionRectangle (integer).
Note that you must use the -rr
option in conjunction with -vw, the render preview option, they take
precedence over the former global attributes. In addition, the region
is sticky, so you only need to do another region render, and it will
retain the region you previously specified. To return to normal
behavior when using the global attributes, you must delete them.

Jozvex
09-20-2004, 11:29 PM
Cool! Thanks for the tip!

joie
09-21-2004, 11:25 AM
Does this work with MAYA 5.0?

mthemelis
09-22-2004, 12:39 PM
Can you please explain these attributes?

rectXY are the dimensions of the region to be rendered?
rectWidth/height is the total resolution?

please some help!!

mthemelis
09-22-2004, 12:40 PM
It's a very cool tip!!!

mthemelis
09-23-2004, 09:06 PM
ok, it's an extremely helpful tip, but how does it work?
(can someone please explain those integers, pleeeeaaaase???)

thanks in advance,
mike

Daniel Whitton
09-23-2004, 10:25 PM
I too would like to know how to use this, in a way that understandable for people who are not familar with code.

Thanks in advance.

Dan

Goon
09-23-2004, 10:44 PM
Integer is a numeric whole value, eg. 1, 2, 3, 4, 5, ... 199993923, not 1.2334, 3.144, n, 1.3E12

I haven't given this a go yet, but you should be able to add the attributes from using "Add Attribute". Use F1 to find it. I don't remember the menu.

Undseth
11-03-2004, 08:59 PM
Here is some stuff wich also mention region rendering, but I want to know if it is possible to set the render regions with command prompt.

http://www.lamrug.org/maya6tips.html

(the node "mentalrayGlobals" can be found with the fast "sel" input tool on top of the screen.)

I can save a scene file with a region set for rendring, and then doing a batch render, but I can't figure out if it is possible to set custum values for region render with command prompt.

This doesn't make any sense to me.

Please, can somebody clarify? And if it is possible, what is the proper syntax?

zuao
11-03-2004, 11:00 PM
this is nice. stucked with that issue some time ago. now finally solved :)

as for using (e.g. changing values) this in batch rendering I would suggest to use some render script, which would be called before rendering.

In my experiences I couldn't get the "-preRender" option to work with MR. Some snappy tests with MR's "-pre" batch render parameter were unsuccessful too.

Have a look on this example (it presumes you've created the Attr's already as describe above):

# The Renderscript

// Start
miCreateDefaultNodes();
select mentalrayGlobals;
setAttr .regionRectX 0;
setAttr .regionRectY 0;
setAttr .regionRectWidth 400;
setAttr .regionRectHeight 288;
mrBatchRender(1,0);
// mrBatchRender(int $numThreads, int $useMaster)
// $useMaster for network rendering classification
// End


# The Rendercall

mayabatch -file "regiontest.mb" -proj "z:\prj\maya_tests" -script "Z:\prj\maya_tests\regionset.mel"


You could control nearly any parameter (even create it) at render call.


try and optimize,
nando.

ps for Maya 5.0, there was a mel command "mrBatchRender_v5" to start rendering (without any needed options). Is there in Maya 6.0 such?

Undseth
11-04-2004, 12:19 PM
The prerender script-thing is interesting.

Im not sure what commands are necessary besides the following:

select mentalrayGlobals;
setAttr .regionRectX 0;
setAttr .regionRectY 0;
setAttr .regionRectWidth 400;
setAttr .regionRectHeight 288;

In maya 6.01 I type the following to start a batchrender:

render -r mr -pre "c:\pr.mel" yay.mb

But I get a syntax error.

Error: c:\pr.mel;
Error: Syntax error

zuao
11-04-2004, 12:47 PM
...
render -r mr -pre "c:\pr.mel" yay.mb

But I get a syntax error.
...
As I said, I also couldn't get it to work with the "-pre"-option nor the "-preRender"-option. That's why I skipped the render.exe. It just calls mayabatch.exe in the end. Of course, this render.exe-thing should make batch-rendering more comfortable, but unfortunately it doesn't, because you don't get access to all the render parameters someone would have to set by the batch.
So, forget render.exe. You don't need it, if you seriously want to use a render script.

Nevertheless back to these options, the batchrender help says about them:


-preRender string Executes this Mel script after loading file
-pre string Mel code executed before each frame
So, these are different as you can read and it would be nice to get both to work, right.

What's interesting too - "-preRender" wants a "Mel script" (as we like it) and the other one seems to want "Mel code" just put in the command-line, or what? I couldn't test it now, will do that later.

Sofar,
nando.

j00ey
01-07-2005, 01:31 PM
Thanks for all the pointers

I got this to work from the command line like this:

render -r mr -rt 4 -preRender "setAttr mentalrayGlobals.regionRectWidth 800; setAttr mentalrayGlobals.regionRectHeight 640; setAttr mentalrayGlobals.regionRectY 0; setAttr mentalrayGlobals.regionRectX 0;" C:\path\file.mb

having first added the mentalrayGlobals attributes as described above

scottsch
01-09-2005, 04:43 PM
Has anyone got the batch render part of this to work with Maya 5? Render region works in renderview, but in batch rendering it either renders the entire frame or a blank grey image.

zuao
01-09-2005, 10:36 PM
I almost went nuts to get this to work for batch rendering in Maya 5.0. I admit, I gave up - switching to Maya 6.0, which was painful too, because I had this complex scene created with Maya 5.0 ... you know the deal.

So, afaik it's not possible, although I still can't understand why, because it's alright with the preview region mode in the render window as scottsch mentioned.

Oh yeah, there is some possibility. Export .mi-file, patch it.
Sorry, but not for me this time ;)

regards,
nando.

_david
01-12-2005, 02:53 PM
thank you guys so much, you saved my life with render region in MRbatch!!:thumbsup:

tonytouch
02-07-2005, 07:13 PM
hey , but it would be also possible to make an expression in expression-editor

in the expression write :

-------
if (frame == 1)
{

select mentalrayGlobals;
setAttr .regionRectX 0;
setAttr .regionRectY 0;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}

if (frame == 2)
{

select mentalrayGlobals;
setAttr .regionRectX 320;
setAttr .regionRectY 0;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}
if (frame == 3)

{

select mentalrayGlobals;
setAttr .regionRectX 0;
setAttr .regionRectY 240;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}
if (frame == 4)

{

select mentalrayGlobals;
setAttr .regionRectX 320;
setAttr .regionRectY 240;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}


---------------------
and then simply batch-render without a pre-mel-script (of course : all frames must have the same CAMERA-attributes (translation / rotation / focalLength / ...)

---------------------
i am still trying to use "Mayatomr -preview -region -rr 0 0 2000 2000;"
on maya5 , but i cant figure out how to save the image after rendering . in batchrendering through the command line , it seems not to work . i can batch render with "mayarender_with_mr c:\temp\myScene.mb" but 1. cant use premel 2. cant save the "partial-image" of the renderregion.

so this method seems only to work in Maya6 with "render -r mr ...." but not in maya5 - is it possible to render with "Mayatomr ..... ;" and saving the "part of the image" on HD ? so it would be easy then.....

have a nice week !

tonytouch
02-07-2005, 07:24 PM
hi ,

this is my first "message" .

you can also write an expression (in window / animation / expression editor)

write :

//------------------------------------start
if (frame == 1)
{

select mentalrayGlobals;
setAttr .regionRectX 0;
setAttr .regionRectY 0;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}

if (frame == 2)
{

select mentalrayGlobals;
setAttr .regionRectX 320;
setAttr .regionRectY 0;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}
if (frame == 3)

{

select mentalrayGlobals;
setAttr .regionRectX 0;
setAttr .regionRectY 240;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}
if (frame == 4)

{

select mentalrayGlobals;
setAttr .regionRectX 320;
setAttr .regionRectY 240;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}

//--------------------------end

and then simple batch render ... but be sure that the camera does not change within the frames that you declare .(rotation / translation in the attribute editor - it is just meant for a single shot -POSTER_SIZE_PICTURE)

is there a way to use the "Mayatomr ...;" - command and save the renderregion i just rendered ? such as the mel-line "Mayatomr -preview -region -rr 0 0 320 240" ( so it would work in maya5 too ... ???)

this setAttr-method DOESNOT work in Maya5 , but the "Mayatomr" does , so how can i save the image in the end ????

have a nice week ...

visjes
04-07-2005, 07:38 AM
It seems that the method of using -preRender "select mentalrayGlobals; ..." works, even though the documentation says it should not! Doesn't it say that -preRender wants a mel filename, while -pre wants the code? Using -pre with mel code doesn't work, lol. Even with maya 6.5 which says that it supports -reg when you run Render -r mr -help, that does not work. The only method which seems to work is using -preRender.

A note as well. It seems that the regionRectX and regionRectY parameters are taken from the bottom left of the image. So .regionRectX = 0, .regionRectY = 0, .regionRectWidth = 100, .regionRectHeight = 100 will render a 100x100 square in the bottom left. Just something to keep in mind.

Ash-Man
04-09-2005, 12:10 PM
For Maya 6.5
The following command line render flag will be required to render out a
section of the larger image.

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

for ex. to tile an image that is 800*600 to 4 tiles us the following

render -r mr -reg 0 400 0 300 myfile.mb
render -r mr -reg 0 400 300 600 myfile.mb
render -r mr -reg 400 800 0 300 myfile.mb
render -r mr -reg 400 800 300 600 myfile.mb

Brick-top
04-10-2005, 02:09 PM
Hi everyone, I have been having a similar problem with rendering large images with mental ray, this tip is of great use but I don't seem to be able to make it work with a batch rendering, I have tried the examples in previous posts but I get all kind of syntax errors. Another question I have is what can I do to make an FG file so that when I render the regions I don't get diferent "lighting?" on them? I understand I have to turn off "rebuild final gather" but If I can't render with high resolution how can I create an FG file for the resolution I want?

Hope my bad english doesn't confuse anyone....

Thanks :)

LeonardoSchubert
04-10-2005, 04:21 PM
hi ,

this is my first "message" .

you can also write an expression (in window / animation / expression editor)

write :

//------------------------------------start
if (frame == 1)
{

select mentalrayGlobals;
setAttr .regionRectX 0;
setAttr .regionRectY 0;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}

if (frame == 2)
{

select mentalrayGlobals;
setAttr .regionRectX 320;
setAttr .regionRectY 0;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}
if (frame == 3)

{

select mentalrayGlobals;
setAttr .regionRectX 0;
setAttr .regionRectY 240;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}
if (frame == 4)

{

select mentalrayGlobals;
setAttr .regionRectX 320;
setAttr .regionRectY 240;
setAttr .regionRectWidth 320;
setAttr .regionRectHeight 240;
}

//--------------------------end

and then simple batch render ... but be sure that the camera does not change within the frames that you declare .(rotation / translation in the attribute editor - it is just meant for a single shot -POSTER_SIZE_PICTURE)

is there a way to use the "Mayatomr ...;" - command and save the renderregion i just rendered ? such as the mel-line "Mayatomr -preview -region -rr 0 0 320 240" ( so it would work in maya5 too ... ???)

this setAttr-method DOESNOT work in Maya5 , but the "Mayatomr" does , so how can i save the image in the end ????

have a nice week ...

Pardom my ignorance... but I have a simple question. After following your instructions, I'm getting an error that I don't know how to fix=
// Error: No object matches name: .regionRectX //

What am I missing? how do I create an "object" that would match .regionRectX?
(If it's explained in previous posts, then I don't get the explanantion... I have been trying to figure out this for hours "with my limited knowledge in maya")

Thanks a lot!
Regards,
Leonardo

zuao
04-10-2005, 04:48 PM
// Error: No object matches name: .regionRectX //

What am I missing? how do I create an "object" that would match .regionRectX?


The answer is in your posting.
The missing "object" is "mentalrayGlobals" - the one, which is selected and for which the Attr ".regionRectX" is set.

So, the question is, why it is missing.

Please provide some more informations. What's your Maya Version? You know, that the script wants to render with mentalRay, you should too ;)

Perhaps you should open your scene and go into MR's renderglobals at least once (if you didn't already), because that step will create the object "mentalrayGlobals". If you got error messages at this point, post them and we'll get that straight.

Another more sexy possibility would be to add "miCreateDefaultNodes();" at the beginning of your script.

Try it.

ciao,
nando.

LeonardoSchubert
04-10-2005, 08:11 PM
The answer is in your posting.
The missing "object" is "mentalrayGlobals" - the one, which is selected and for which the Attr ".regionRectX" is set.

So, the question is, why it is missing.

Please provide some more informations. What's your Maya Version? You know, that the script wants to render with mentalRay, you should too ;)

Perhaps you should open your scene and go into MR's renderglobals at least once (if you didn't already), because that step will create the object "mentalrayGlobals". If you got error messages at this point, post them and we'll get that straight.

Another more sexy possibility would be to add "miCreateDefaultNodes();" at the beginning of your script.

Try it.

ciao,
nando.

I'm running Maya6.0

Now let me go stept by step to see if you can see what am I doing wrong.

-I create a new scene (place a couple of objects and a camera)
- Then I go to Render Global settings:
swith to Mentalray; (Frame/Animation Ext)= name.#.ext; (end Frame)= 4; (Camera)= Camera1; (REsolution)= 640x480
- Then I go to: Window / Animation Editor / Expression Editor: and I copy/ paste the expression that tonytouch posted.

Same error!
Am I missing something?? :D

Regards,
Leonardo

zuao
04-10-2005, 09:18 PM
yes, you are missing something. read the first post please. you'll have to add these attributes by hand. there don't exist by default, but will be translated to mr. magic!
go for victory ;)

LeonardoSchubert
04-10-2005, 10:26 PM
IT WORKS!! but it doesn't work :D

I fugure out how to add Integers!! (on the attributes menu ) and when I put everything together, each frame (1 to 4) renders a different section according to which region I assigened.... So it WORKS!!

However, When I do a batch-render, it only renders the first one

regionRectX 0;
regionRectY 0;
regionRectWidth 320;
regionRectHeight 240;
four times!!!
Mentalray end up rendering Name.1.tif, Name.2.tif, Name.3.tif, Name.4.tif, using the same region ?? :eek:
With doesn't make much sense, because when I go over the time slider to frame #2 or 3, the numbers in mentalrayGlobals/Extra Attributes also change


Regards,
Leonardo

zuao
04-11-2005, 12:07 AM
Sounds like the "lazy-expression-evaluation"-case. :)
You would have to force Maya to evaluate the expression EVERY frame. A friend of mine once told me how to do this, but I forgot, because I never did this by myself. Unfortunately I've got no time to try something out, but I remember that it was a trick like: Animating some attr of some object, which links into the expression, which would force Maya to evaluate the whole expression every frame. OMG, sound really non-sense ... but I experienced that kind of problem like yours in my render-region-tests some time ago, too.

At that time I found a better solution. I wrote a melscript with a procedure ("mrRegionRender"), that would get some parameters for a region and set them in a scenefile AND start the rendering. This one went to the maya script folder. The batch render call then looked like this:

"mayabatch -command "mrRegionRender(0,0,320,240)" -proj "c:\mymayaproject" -file "myscene.mb"

The really cool thing about this is, that you never have to use the ugly render.exe again, because you now have your own render routine, which is able to do all the settings, you could do inside maya.

ciao,
nando.

LeonardoSchubert
04-11-2005, 01:20 AM
OKay now I'm confuse again :D lol


At that time I found a better solution. I wrote a melscript with a procedure ("mrRegionRender"), that would get some parameters for a region and set them in a scenefile AND start the rendering. This one went to the maya script folder. The batch render call then looked like this:

"mayabatch -command "mrRegionRender(0,0,320,240)" -proj "c:\mymayaproject" -file "myscene.mb"


I'm a little confuse, from there... how do I tell mayabatch to not only render (0,0,320,240), but the next four frames like (320,0,320,240).

Sorry, if this a dumb question

Regards,
Leonardo

zuao
04-11-2005, 10:10 AM
I'm a little confuse, from there... how do I tell mayabatch to not only render (0,0,320,240), but the next four frames like (320,0,320,240).

Sorry, if this a dumb question

Regards,
Leonardo

Only a little bit dumb ;) ... you're right. How to set the Start/Endframe you could find out very easy by yourself now. Read my last post more carefully!

"...which is able to do all the settings, you could do inside maya."

ciao,
ndo.

LeonardoSchubert
04-12-2005, 02:09 AM
Only a little bit dumb ;) ... you're right. How to set the Start/Endframe you could find out very easy by yourself now. Read my last post more carefully!

"...which is able to do all the settings, you could do inside maya."

ciao,
ndo.

ndo, thanks lot!! I'll keep :banghead: myself until I get it!! lol

Regards,
Leonardo

tonytouch
09-14-2005, 01:13 PM
in the meanwhile i found out , that that renderregion-method with adding new attributes in maya6 does not really work so good . if you go in resolutios like 8000 x 8000 mayaBatch.exe crashes . so i do not reccommend the method , that i described some months ago , anymore . it really only works for resolutions lower than 6000 x 6000 .

i did not test the "render -r -mr -reg ...." until now , but i guess that this could work ,like it always worked in maya software -renderer . it seems to be new in maya6.5 (just testing this right now ... -> for me it does not really work well . rendering really big resolutions, errors occur .)

if not , then the only possiblity is to set up many cameras with certain adjustments in order to create TILE-cameras , like in this small script (which does 2x2 tiles and 3x3 tiles , if you want more , than you have to write a proper 4x4 or 5x5 script - in the end you will also have hard work to put those tiles together again - because it is really "highresolution" and may take several minutes to load and save from/to your harddisc. but it works (at least) to get images in 18000 x 18000 (if anyone needs that big renders ... LOL)

chz
09-15-2005, 02:49 PM
Thanks for the info...

CGTalk Moderation
09-15-2005, 02:49 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.