I want to set up a MaxScript script to execute after each frame and post process the g-buffer to obtain certain node properties from the #node channel.
Ideally this would be done with the call:
GBNodes = getChannel bm [x,y] #node
which gets me directly to the nodes or if I had the Node Render ID
But this requires a bitmap (bm) of the type created by
bm = render channels:#(#zdepth, #objectID, #node, #matID) vfb:off
but obviously this call would execute the render again!
So my question is:
How can I get the just completed frame as a bitmap in the Post-Frame script?
I think that I can use
bm = GetLastRenderedImage copy:false --share the bitmap
Provided that I have rendered to a suitable format e.g. RPF with the relevant g-buffer channels selected.
Is this correct/the optimum way to do it?
Thanks in advance.
Hey Stephen,
I think your logic is good here. Maybe give it a try as I haven’t tried this one before? Here’s a couple of alternatives that come to mind as well:
-
Submit a “maxscript” job to the 3dsmax/lightning plugin in Deadline. It will start up 3dsMax under Lightning control and you can feed it a maxscript file which can execute pretty much anything you like, such as “render…” although there are some caveats about not touching any reference to the 3dsMax UI. I can go more into the dark depths of this one if you like?
docs.thinkboxsoftware.com/produc … ipt-script
docs.thinkboxsoftware.com/produc … -interface
-
“Draft” has some nice channel extraction tools, but won’t work with RPF as that’s a closed image format from ADSK. If you were to say, render to EXR, a Draft Python script could be written as a Deadline post process or just a Draft job that runs after the 3dsmax job, which grabs the rendered EXR image, extracts what channels you care about and maybe do something to them, before saving them as a certain image file format. Julie, our draft developer, just reminded me she has an example Python script that does this for an exr file, which we must post up to our website as another cookbook recipe in due course.
docs.thinkboxsoftware.com/produc … /#cookbook
There are probably other options and I wouldn’t be surprised if the Bobo came strolling past this thread in a while as well
Thanks Mike.
I am not wedded to the RPF format, in fact I am testing EXR at the moment.
I am sure there are some good post processing options, and I’d like to explore these as well.
However the question I was curious about was whether I could get a bitmap into maxscript immediately after the render (from the frame buffer?). At the moment I am writing the render to disk then the post-frame script is loading the bitmap back off disk (with openBitMap). I would have thought that at the point of calling the post frame script the list render is still in memory somewhere? Or is that incorrect and it is only available on disk? It would be an improvement to use the image currently in memory rather than reloading from disk.
Testing has shown that GetLastRenderedImage returns undefined so this would appear NOT to be the method.
What I am trying to do is an interesting class of post-processing which links the rendered pixels back to the scene. I want to know for a particular pixel what node it refers to so that I can use information from the node to identify the pixels.
The c++ SDK function we use to execute the render command in 3dsMax in our Lightning plugin doesn’t currently return the bitmap(s) of the main rendered image or RE’s. So it’s not in memory and only available via disk.
After chatting with Bobo last night, the current workflow in the short term would be to load it from disk, either via maxscript or another language, possibly Python, and/or use our Draft library to assist. Of course, external to 3dsMax, you would need a referencing system (DB?) to cross-reference the pixel coords to the scene data. Bobo tells me that a very similar system was written back in the day at Frantic Films VFX, where an individual pixel from a rendered image could be traced back to the original modeller of that object!
After parsing our Lightning plugin code this morning, I’m going to raise an internal ticket to discuss if it’s possible to return the bitmap in the future.
Thanks Mike,
It’s good to know that I am doing the best thing (i.e. reading back the render). I realise of course it is still necessary to do this at render time as we need to translate the Render Node ID into an actual Node which need the same scene.
BTW I am still sticking with .RPF as I am experiencing difficulties in getting .EXR to write out the G-buffer channels (not a deadline issue). Not sure why yet.
Cheers.