I recently got a RTX 3090 as a companion to my RTX 2080. Render times are certainly blazing fast for static images. However for animations or image sequences render times overall weren’t that much better. This is due to the way Daz handles multi frame rendering. It seems that at the end of each frame rendered the entire iRay engine is completely restarted. For my example I was using a single character with a black background and 2 mesh lights rendering to images sized at 500 x 500 pixels. The time of the actual rendering of each frame was 2-3 seconds before 95% convergance was reached. Then there was a delay of 15-20 seconds while it does who knows what, before rendering the next frame. Total time for a 10 frame test was 182 seconds with only 20-30s of that time being spent actually rendering.
I am pleased with the performance of the viewport and thought “Why not just capture the viewport frame by frame?” After all, It reaches an acceptable appearance within 2-3 seconds after an adjustment is made and I’m not looking for extreme quality. So I came up with this script.
The script captures each frame of the viewport after a specified number of milliseconds and then saves the image with a sequential suffix. The overhead of time between each frame is reduced to around 200ms. A test sequence of 10 frames rendering for 3 seconds each had a total execution time of 32.238s. Which is a time reduction of 82.2%!
The downside of capturing the viewport is the image will reflect exactly what the viewport is displaying. If a node is hovered over and highlighted it will show in the image, as will any tool gizmos. Thus, greater care needs to be taken in the setup.
This won’t work for all situations and is highly dependent on hardware and the timePerFrame value. But I imagine it would reduce the overhead between frames substantially even for CPU renders.
const timePerFrame=3000;//ms
const timeStep=Scene.getTimeStep();
const playbackRange=Scene.getPlayRange();
const startFrame=playbackRange.start/timeStep;
const endFrame=playbackRange.end/timeStep;
const sFilePath="D:/renderTest2/";
const filename="test";
const vp = MainWindow.getViewportMgr().getActiveViewport().get3DViewport();
(function(){
var timeOfNextFrame=0;
var totalFrames=endFrame-startFrame;
startProgress ("Rendering "+totalFrames +" Frames:", totalFrames, true, true);
for(var i=startFrame;i<=endFrame;i++){
Scene.setFrame( i );
stepProgress(1);
statusPrinted=false;
timeOfNextFrame=Date.now()+timePerFrame;
print(" Rendering frame "+i+" of "+ totalFrames);
while(Date.now()<timeOfNextFrame){
processEvents();
}
saveImg(i);
if(progressIsCancelled ())return;
}
})();
function saveImg(i){
var numS=pad(i,4);
var filePath=sFilePath+filename+numS+".png";
vp.captureImage().save(filePath);
}
function pad(num, size) {
num = num.toString();
while (num.length < size) num = "0" + num;
return num;
}