PDA

View Full Version : MaxScript, VRay and Rendering


trankillity
06-22-2006, 05:49 AM
Hi there everyone!
I'm working on my first MaxScript but am quite experienced in many other scripting languages so the constructs are nothing new to me. I'm hoping that someone can help me with a few problems with my script.

We are currently involved in a lot of different architectural visualisation projects and use VRay as our renderer. We pre-generate VRay Lightcaches and Irradiance Maps for all our scenes. Setting these scenes rendering is quite an arduous task sometimes taking up to one hour per camera to set rendering because we first have to set the light cache rendering then set the imap rendering with the light cache as a pre-requisite then finally set the render going with both the light cache and the imap as the pre-requisites.

What I'm attempting to do is automate this process by creating a MaxScript that prompts a user for a single output directory then changes the relevant settings and effectively renders the scene three times (once for light cache, once for imap and finally for the render itself) to an RPF stream in the selected output directory. The MaxScript will also prompt the user for a base RPS file to determine the quality settings to be used for the render.

So far I'm able to prompt the user for the destination directory, prompt the user for the render preset file, change all the relevant rendering settings in common properties and in VRay renderer properties and I am able to output the .vrlmap (light cache), .vrmap (imap) and .rpf (render) files.

Unfortunately these can only be done one at a time as it currently stands and I have only managed to achieve this in a fairly rudimentary way. I am using the render() command for the light cache and imap but if I use render() for the frames themselves it appears to ignore the render dialog box settings and doesn't output the .rpf file. This is the first of my issues, which are all inter-related and can probably all be solved by solving the major issue I have; NetRendering.

I wish to be able to farm this process off to our render farm but am not entirely sure of the process to achieve this. The MaxScript documentation on NetRender functionality is confusing and doesn't make sense to me. I would love to be able to automate it such as is loosely outlined below:

Render "vray.vrlmap" Light Cache file on a specific machine in a network render cluster with a critical priority level
Render "vray.vrmap" Irradiance Map file on the same machine as step 1 with a dependancy on step one being complete also having a critical priority level
Render "frame0000.rpf" final rendered output on all machines in the render cluster being dependant on steps 1 and 2 having a custom specified priority level
I would like the above steps to be submitted from a single machine using a one-button approach with my script.

The main things that I wish to know are; (a) Can I get Max to act as if it just hit the render button in the render dialog box? This solution would be superb as I can already change all the properties in the render dialog and (b) How can I set up a relatively advanced net rendering system as I have outlined there that will take the render settings from the current render settings without having to parse them all through the net render commands?

Thanks in advance for any assistance on this matter, if you require any further information or clarification don't hesitate to ask.

Cheers,
Sebastian

trankillity
06-22-2006, 11:44 PM
Anyone at all got any ideas on this? I'm fairly stumped.

bernieLomax
06-23-2006, 01:11 AM
amaizing just what i´d been looking for... hope you can succeed in doing your task...
the maxscript reference is quite extensive anyway, and vray help online also helped me quite a bit....
good luck to you.
hugs bern.

trankillity
06-23-2006, 05:35 AM
OK, so I now have everything minus the dependancies working. Unfortunately this is one of the most key requirements of my script. There is no documentation whatsoever in the MaxScript reference about setting dependancies. Anyone able to shed some light on this final issue?

48design
06-23-2006, 06:04 PM
I have no clue @all, sorry.
I'm going to write a script that has also something to do with vray,
but @ the moment I don't know an answer...

Do you think about sharing this script with the community?

bernieLomax
06-25-2006, 11:01 PM
here is what i don´t understand :
"renders the scene three times (once for light cache, once for imap and finally for the render itself)" why?
i´m trying to do that also but render the irradiance map first on the network and the send the final job with a dependency to the network machines....
it is quite simple actually.. but i´m trying to automate it also...

bernieLomax
06-25-2006, 11:06 PM
oh something i remenbered...
the render setting can be pre-made and stored as a default setting somewhere in the max directyorys.
so you would end up with:
setting one: "render the imap"
setting two: "render light cache"
setting three: "render final animation"
these could be reletively simple setting pre made that you would store as a default action for all your animation.
try thinking photoshop actions maybe it will help you hugs bern:

bernieLomax
06-26-2006, 05:24 PM
ok so i went on this crusade for myself and i´m working on this one button soluttion...
i´ll soon post some results...

Hughg
06-27-2006, 12:45 PM
macroScript MultiCamRender

category:"Cooper"

tooltip:"Multi-camera rendering for Vray"

buttontext:"MultiCam"

(

local mycams

on isenabled return (findstring (renderers.current as string) "vray") != undefined

on execute do

(

go_next = false

undo off

(

------VrayCam

mycams = #()

for q in cameras where ((superclassof q == camera) and (q.name != "VrayCam")) do if not q.ishidden then append mycams q

if mycams.count > 1 then

(

animationrange = (interval 0 (mycams.count-1))

if $vraycam == undefined then

(

vraycam = freecamera name:"VrayCam"

vraycam.position.controller = linear_position()

vraycam.rotation.controller = linear_rotation()

)

else vraycam = $vraycam

with animate on

(

for c = 1 to mycams.count do

(

CamProps = getpropnames mycams[c]

for i = 1 to CamProps.count do

(

sourceprop = at time (c-1) getproperty mycams[c] CamProps[i]

try if ((sourceprop != #free) and (sourceprop != #target)) then at time (c-1) setproperty vraycam CamProps[i] sourceprop catch()

)

at time (c-1) vraycam.transform = mycams[c].transform

at time (c-1) vraycam.fov = mycams[c].fov

)

)

select $vraycam

viewport.setCamera $VrayCam

go_next = true

)

-------VrayCam









if go_next then

(

----------first stage

renderSceneDialog.close()

myrend = renderers.current

fullfilename = maxFilePath + (getFileNameFile maxfilename)

myrend.gi_on = true

myrend.gi_primary_type = 0

myrend.gi_secondary_type = 3

irmap_name = fullfilename +".vrmap"

lightcache_name = fullfilename +".vrlmap"

myrend.adv_irradmap_loadFileName = irmap_name

myrend.adv_irradmap_autoSave = true

myrend.adv_irradmap_autoSaveFileName = irmap_name

myrend.lightcache_loadFileName = lightcache_name

myrend.lightcache_autosave = true

myrend.lightcache_autosaveFileName = lightcache_name

myrend.options_dontRenderImage = true

myrend.adv_irradmap_mode = 4

myrend.lightcache_mode = 1

old_aa = myrend.imageSampler_type

myrend.imageSampler_type = 0

rendTimeType = 2

rendSaveFile = false

max quick render

------- first stage











------- second stage

rendSaveFile = true

myrend.adv_irradmap_mode = 2

myrend.lightcache_mode = 2

myrend.options_dontRenderImage = false

myrend.imageSampler_type = old_aa

max quick render

------- second stage

) -- gonext

) --- end undo

) --- end on execute

)

bernieLomax
06-27-2006, 04:10 PM
still it does not send the job to the network
but working on that

displaced
05-02-2007, 03:49 PM
I just search for info on this subject as the same thing has been annoying me....I can spend easily an hour adjusting all these settings before the end of the day so i can get a render out....then remember i ve missed something....

so thought i would do some research....and i find this thread....

whats been the outcome of your work so far ?

Colin

MoonDoggie
05-02-2007, 05:24 PM
We do Arch-vis as well, without this tool we'd be reinventing the wheel time and time again. It does everything (dependancies etc) that you need and more: http://www.rpmanager.com/

displaced
05-02-2007, 05:31 PM
Thanks for that...looks really interesting...

But i really wanted this as a learning experience so I want some code to play with...

but if all else fails its something to fall back on...

do you know of any maxscript references in terms of intereaction with vray

MoonDoggie
05-02-2007, 05:44 PM
Unfortunately I don't offhand. The ChaosGroup forum doesn't have any specific maxscript help, but there are a large handful of people that do the know code specific to vray you could ask.

RPManager is a great tool for visual artists. It allows complete control of every render/render setting on a per shot basis. I can setup the IMAPs for my render on one pass, setup the lighting rig specific to another shot and have rp manager turn on and off the correct layers for each different shot. My normal renders will render once their dependancy (read IMAP) is done over backburner etc etc. It's pretty inexpensive and worth every dime.

Hope this helps a bit.
-Colin

CGTalk Moderation
05-02-2007, 05:44 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.