Partially rendering multiple frames

Hi everyone,

Is it possible to spot-render multiple frames (yet)? Or do something similar, like a region render.
I'm not looking for solutions that require hiding objects, changing the camera ratio, or anything else that affects lighting or camera angles.
I just want to animate and render a small part of the screen and render only that portion, as you would do with a spot render.
I don't mind buying a plugin if there are any that accomplish this.

Thanks.

Comments

  • crosswindcrosswind Posts: 7,722
    edited April 2023

    Oh, my dear, more than a platitude~ it's not possible now in DS to 'spot render multi frames'. However you must've known there're quite a few workaround, why don't you try some of them?

    Another direction is go to blender, use Daz Importer to send your scene from DS to Blender in which there're functionalities of 'render region for frames' and some good add-ons...

    Post edited by crosswind on
  • Richard HaseltineRichard Haseltine Posts: 102,041

    Reply moved to original thread, repost again removed.

  • Rock23Rock23 Posts: 9

    crosswind said:

    Oh, my dear, more than a platitude~ it's not possible now in DS to 'spot render multi frames'. However you must've known there're quite a few workaround, why don't you try some of them?

    Another direction is go to blender, use Daz Importer to send your scene from DS to Blender in which there're functionalities of 'render region for frames' and some good add-ons...

    Oh, I did try them. That's what I meant by saying I am not looking for those. Maybe I should have made that more clear in my post.
    The thing is I am wondering if it is possible with a plug-in or any other way, as technically it shouldn't be too hard.
    But I was unable to find any working solutions.

    Also going to Blender isn't really a solution. As importing Daz scenes into Blender works far from flawlessly (in my experience at least).
    But if that is incorrect or outdated, I very much would like to know too.
     

  • Rock23Rock23 Posts: 9

    Richard Haseltine said:

    Reply moved to original thread, repost again removed.

    I didn't mean to spam post, sorry if that's what happened.
    (The posts kept showing as draft with 0 views in my overview and I couldn't find them in the forum.) 
     

  • crosswindcrosswind Posts: 7,722

    Rock23 said:

    crosswind said:

    Oh, my dear, more than a platitude~ it's not possible now in DS to 'spot render multi frames'. However you must've known there're quite a few workaround, why don't you try some of them?

    Another direction is go to blender, use Daz Importer to send your scene from DS to Blender in which there're functionalities of 'render region for frames' and some good add-ons...

    Oh, I did try them. That's what I meant by saying I am not looking for those. Maybe I should have made that more clear in my post.
    The thing is I am wondering if it is possible with a plug-in or any other way, as technically it shouldn't be too hard.
    But I was unable to find any working solutions.

    Also going to Blender isn't really a solution. As importing Daz scenes into Blender works far from flawlessly (in my experience at least).
    But if that is incorrect or outdated, I very much would like to know too.
     

    Strongly recommend using diffeomorphic Daz Import to bring your work to blender for animation, you never know how strong the latest version of the add-on is unless you jump into it...

  • JPJP Posts: 79

    I tried to get ChatGPT and Claude AI to write me a Daz Script that creates a region rendering of an animation sequence and save the files to a specified folder.

    So far I have gone through many iterations and not one has worked. This example below gives the following error in the log file:

    2024-12-23 22:45:09.526 [INFO] :: Loading script: C:/Users/Public/Documents/My DAZ 3D Library/Scripts/RegionRender/test6.dsa
    2024-12-23 22:45:09.528 [DEBUG] :: Starting region render animation...
    2024-12-23 22:45:09.528 [DEBUG] :: Output path: C:/RenderOutput/MyAnimation
    2024-12-23 22:45:09.528 [DEBUG] :: Filename format: render_sequence_###
    2024-12-23 22:45:09.529 [DEBUG] :: Error occurred: TypeError: Result of expression 'renderMgr.queueRender' [undefined] is not a function.
    2024-12-23 22:45:09.530 [INFO] :: Script executed successfully: C:/Users/Public/Documents/My DAZ 3D Library/Scripts/RegionRender/test6.dsa

    test6.dsa Code Below:

    // Get the main render manager and options
    var renderMgr = App.getRenderMgr();
    var renderOptions = renderMgr.getRenderOptions();

    // Configure output settings
    var outputPath = "C:/RenderOutput/MyAnimation";    // Corrected path with forward slashes
    var baseFilename = "render_sequence";              // Base filename for the sequence

    // Create output directory if it doesn't exist
    var dir = new DzDir(outputPath);
    if (!dir.exists()) {
        dir.mkpath(outputPath);
    }

    // Set render dimensions (using width/height aspect ratio)
    renderOptions.setAspectRatio(3840, 2160);

    // Calculate region render bounds for 720x720 centered region
    var mainWidth = 3840;
    var mainHeight = 2160;
    var regionWidth = 720;
    var regionHeight = 720;

    var left = Math.floor((mainWidth - regionWidth) / 2);
    var top = Math.floor((mainHeight - regionHeight) / 2);
    var right = left + regionWidth;
    var bottom = top + regionHeight;

    // Set render times for animation (0 to 30 frames)
    renderOptions.startTime = 0;
    renderOptions.endTime = 30;

    // Set output settings
    renderOptions.renderImgFilename = outputPath + "/" + baseFilename;
    renderOptions.renderType = renderOptions.DirectToFile;  // Render directly to file
    renderOptions.isCurrentFrameRender = false;  // Enable animation rendering

    try {
        print("Starting region render animation...");
        print("Output path: " + outputPath);
        print("Filename format: " + baseFilename + "_###");
        
        renderOptions.applyChanges();
        renderMgr.queueRender();  // Use queueRender to trigger render
        print("Render started successfully");
    } catch(e) {
        print("Error occurred: " + e);
    }

  • The AIs are not actually I - they generate output based on a statistical analysis of their training input and that can easily lead to their inventing functions that look right in format but are completely fictitious. AI is great for generatin yet-another-version of commonly implemented scripts; it is pretty hopeless at gernating soemthing that doesn't have multiple human-generated exempalrs. If you check the docs (e.g. http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/rendermgr_dz ) you can perhaps spot the inventions and try to substitue them with things that work

  • JPJP Posts: 79
    edited December 2024

    Richard Haseltine said:

    The AIs are not actually I - they generate output based on a statistical analysis of their training input and that can easily lead to their inventing functions that look right in format but are completely fictitious. AI is great for generatin yet-another-version of commonly implemented scripts; it is pretty hopeless at gernating soemthing that doesn't have multiple human-generated exempalrs. If you check the docs (e.g. http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/rendermgr_dz ) you can perhaps spot the inventions and try to substitue them with things that work

    Thanks for your reply Richard. Yes, the AIs need help. It is also amazing. I was able to get a semi-working script with the help of ChatGPT by scouring the forums and feeding it bits and pieces from existing scripts. It can adjust extremely quickly. I'll paste a long string of code and before you can blink your eyes it is already providing adjusted code. I'll post some of the correspondences when I get a chance. It's unreal.

    Here is the code. It allows you to create a cropped rendering based on specified coordinates. The coordinates can be grabbed from Photoshop. The problem at the moment is that it correctly saves each frame but it appears to be frame zero rendered every time. We have looked at many different solutions. Some renderings resulted in the reflection of the HDRI environment shifting slightly from frame 0-30. But all other properties are not saved in the png files, so each frame is almost indentical. ChatGPT already came up with some explanations for what might be going on. I will continue playing with this by looking at mCasual's scripts or whatever I can find.

    (function() {    var oRenderMgr = App.getRenderMgr();    var oRenderOptions = oRenderMgr.getRenderOptions();        // Set the render output filename (base name for the image series)    var sRenderPath = "D:/render/frame_";  // Filename will be appended with frame numbers        // Set the render size (3840x2160)    var newWidth = 3840;    var newHeight = 2160;    oRenderOptions.imageSize = new QSize(newWidth, newHeight);        // Get the active viewport and camera    var oActiveView = MainWindow.getViewportMgr().getActiveViewport();    var oCamera = oActiveView.get3DViewport().getCamera();        // Ensure the camera object is valid    if (!oCamera) {        MessageBox.critical("No active camera found.", "Render Error", "&OK");        return;    }    // Get the active renderer    var oRenderer = oRenderMgr.getActiveRenderer();    if (!oRenderer) {        MessageBox.critical("No active renderer found.", "Render Error", "&OK");        return;    }    // Set the total number of frames to render    var numFrames = 4;  // Example: Render 4 frames    var currentTime = Scene.getTime();  // Get the current time in the scene    // Define the crop window (e.g., crop a 720x720 area starting at (1560, 1280))    var cropRect = new QRect(1560, 1280, 720, 720);        // Loop through each frame    for (var i = 0; i < numFrames; i++) {        // Calculate the time for the current frame (add i to the current time)        var frameTime = currentTime + i;        // Create a handler for each frame        var oHandler = new DzImageRenderHandler(            oRenderOptions.imageSize,   // Use the same image size            frameTime,                  // Set the starting time for rendering each frame            1,                          // Render one frame at a time            sRenderPath + i + ".png",   // Save each frame as "frame_0.png", "frame_1.png", etc.            false                       // Render as an image (not a movie)        );        // Enable crop window for each frame        oHandler.setUseCropWindow(true);  // Enable crop window        oHandler.setCropWindow(cropRect);  // Set the crop window dimensions                // Ensure we have a valid handler        if (oHandler) {            // Render the current frame            oRenderer.render(oHandler, oCamera, oRenderOptions);            print("Rendered frame " + i);        } else {            print("Failed to create render handler for frame " + i);        }    }    print("Rendering completed for all frames.");})();

     

    Post edited by JP on
  • JPJP Posts: 79
    edited December 2024

    Sorry this was a duplicate of my post above.

    I'll post the code in the body of this text instead of the code snippet because it renders as a long horizontal box in Chrome: In this example, I set it to only render 4 frames for the sake of time. You can specify any frame count that you want. The problem right now is that the frames are identical and the animations and zooms ignored - lol!

    (function() {
        var oRenderMgr = App.getRenderMgr();
        var oRenderOptions = oRenderMgr.getRenderOptions();
        
        // Set the render output filename (base name for the image series)
        var sRenderPath = "D:/render/frame_";  // Filename will be appended with frame numbers
        
        // Set the render size (3840x2160)
        var newWidth = 3840;
        var newHeight = 2160;
        oRenderOptions.imageSize = new QSize(newWidth, newHeight);
        
        // Get the active viewport and camera
        var oActiveView = MainWindow.getViewportMgr().getActiveViewport();
        var oCamera = oActiveView.get3DViewport().getCamera();
        
        // Ensure the camera object is valid
        if (!oCamera) {
            MessageBox.critical("No active camera found.", "Render Error", "&OK");
            return;
        }

        // Get the active renderer
        var oRenderer = oRenderMgr.getActiveRenderer();
        if (!oRenderer) {
            MessageBox.critical("No active renderer found.", "Render Error", "&OK");
            return;
        }

        // Set the total number of frames to render
        var numFrames = 4;  // Example: Render 4 frames
        var currentTime = Scene.getTime();  // Get the current time in the scene

        // Define the crop window (e.g., crop a 720x720 area starting at (1560, 1280))
        var cropRect = new QRect(1560, 1280, 720, 720);
        
        // Loop through each frame
        for (var i = 0; i < numFrames; i++) {
            // Calculate the time for the current frame (add i to the current time)
            var frameTime = currentTime + i;

            // Create a handler for each frame
            var oHandler = new DzImageRenderHandler(
                oRenderOptions.imageSize,   // Use the same image size
                frameTime,                  // Set the starting time for rendering each frame
                1,                          // Render one frame at a time
                sRenderPath + i + ".png",   // Save each frame as "frame_0.png", "frame_1.png", etc.
                false                       // Render as an image (not a movie)
            );

            // Enable crop window for each frame
            oHandler.setUseCropWindow(true);  // Enable crop window
            oHandler.setCropWindow(cropRect);  // Set the crop window dimensions
            
            // Ensure we have a valid handler
            if (oHandler) {
                // Render the current frame
                oRenderer.render(oHandler, oCamera, oRenderOptions);
                print("Rendered frame " + i);
            } else {
                print("Failed to create render handler for frame " + i);
            }
        }

        print("Rendering completed for all frames.");
    })();

    Post edited by JP on
  • JPJP Posts: 79

    I finally got it working with the help of Claude AI. Providing the Daz documentation reference was what made the difference:
    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/imagerenderhandler_dz

    (function() {
        var oRenderMgr = App.getRenderMgr();
        var oRenderOptions = oRenderMgr.getRenderOptions();
        
        // Set the render output filename with proper frame number padding and extension
        var sRenderPath = "D:/render/frame_####.png";  // Four # signs for frame number padding
        
        // Set the render size (3840x2160)
        var newWidth = 3840;
        var newHeight = 2160;
        oRenderOptions.imageSize = new QSize(newWidth, newHeight);
        
        // Get the active viewport and camera
        var oActiveView = MainWindow.getViewportMgr().getActiveViewport();
        var oCamera = oActiveView.get3DViewport().getCamera();
        
        // Validation checks
        if (!oCamera) {
            MessageBox.critical("No active camera found.", "Render Error", "&OK");
            return;
        }
        
        var oRenderer = oRenderMgr.getActiveRenderer();
        if (!oRenderer) {
            MessageBox.critical("No active renderer found.", "Render Error", "&OK");
            return;
        }
        
        var fps = 30;
        var numFrames = 4;
        var startTime = 0;  // Starting at frame 0
        var cropRect = new QRect(1560, 1280, 720, 720);
        
        // Create a single handler for all frames
        var oHandler = new DzImageRenderHandler(
            oRenderOptions.imageSize,  // Render size
            startTime,                 // Starting time
            numFrames,                 // Number of frames to render
            sRenderPath,              // Base filename with frame padding and extension
            false                     // Not a movie file
        );
        
        if (oHandler) {
            // Set up the crop window
            oHandler.setUseCropWindow(true);
            oHandler.setCropWindow(cropRect);
            
            // Start the render process
            oHandler.beginRender();
            
            // Render all frames
            oRenderer.render(oHandler, oCamera, oRenderOptions);
            print("Rendering sequence of " + numFrames + " frames starting at time " + startTime);
            
            // Finish the render
            oHandler.finishRender();
        } else {
            print("Failed to create render handler");
        }
        
        print("Rendering completed.");
    })();

  • JPJP Posts: 79

    ChatGPT would have probably also provided the correct script if I gave it more reference material. I notified ChatGPT that Claude AI provided the finishing touches and it updated the memory for future reference - haha.

    Here are some of my Claude AI correspondences. The ChatGPT responses were very similar. I had to go back and forth with both tools to get it working. I tested this on a scene and it correctly renders the cropped frames as transparent PNG files but at the scene resolution. The cropped frames can easily be merged with prior renderings in Davinci. All the frames will load at the correct coordinates. Masking can then be used to blend the layers. This will be useful for complex animations that take longer to render. It is not a big time saver for frames that render in 1-2 minutes.

     

    CLAUDE_01.jpg
    1743 x 1881 - 427K
    CLAUDE_02.jpg
    1743 x 1881 - 439K
Sign In or Register to comment.