Render elements should inherit filename and type when using VFB

When using the VFB you have to specify the file name and type in the “Split render channels” box. When specifying filename in the 3dsmax “Save file”-box, the render elements have to be configured manually. To me, this feels like an unneccesary extra step, which is easily forgotten when the deadline draws near, or when you’re sending several jobs from the same scene to the Backburner queue.

A simple checkbox “inherit filename” would solve this problem. :slight_smile:

While on the topic of render elements, I think I’ve found a small bug. When rendering using 3dsmax frame buffer, I specify the file type to be saved as 16 bit TIF. However, the render elements often save as 8 bit TIFs. I think the bug occurs when loading a file with this setup, changing the file name, but not the type, and render. If you set the file format to 16bit TIF and render directly it works alright.

Totally agreed. It’s really silly it doesn’t. To Fix this issue, I’ve written a script to do just that. If you’re using the max save dialog, a “_Elements” folder will be created at that location, if you’re using the VRayFB it’ll use that location. Just set your file save, and hit the script.

I wrote the script and credit goes to Teague. It’s in the category:“Teague”

Filename: TeagueSetRenderElements.ms


macroScript SetRenderElementPaths category:"Teague" tooltip:"Set Render Element Paths" Icon:#("Maxscript",2) (
(
    global isRendererVRay
    global newPath
    global newName

    fn isRendererVRay = if matchPattern (renderers.current as string) pattern:"*V_Ray_Adv*" then true else false

    local RSDWasOpen = renderSceneDialog.isOpen()
    local theCurRenderElement
    renderSceneDialog.close()

    -- Set Render element paths based on RendOutputFilename
    if isRendererVRay() then (
        local rendFile = ""

        if renderers.current.output_on and renderers.current.output_saveRawFile then (
            rendFile = renderers.current.output_rawFileName
            rendSaveFile = false
            rendOutputFilename = rendFile
        ) else (
            rendFile = rendOutputFilename
            renderers.current.output_rawFileName = rendFile
        )

        -- Messagebox letting the user know which filename is being used
        if renderers.current.output_on and renderers.current.output_saveRawFile and rendSaveFile then
            messageBox "V-Ray Frame Buffer is being used, using that output filename for render elements."

        if rendFile != "" and rendFile != undefined then (
            theManager = maxOps.GetRenderElementMgr #Production
            theManager.SetElementsActive true

            if (getFilenameType rendFile) == ".exr" then (
                -- Set Auto Add Render Elements
                print "SetRenderElements:: Exr filetype found, turning off \"Auto Add Render Elements\" in the setup dialog."
                fOpenExr.setAutoAddRenderElements false
            )

            if (getFilenameType rendFile) == ".png" then (
                -- Set Auto Add Render Elements
                print "SetRenderElements:: PNG filetype found, Setting options to 48bit, alpha, non-interlaced."
                pngio.setType #true48
                pngio.setAlpha true
                pngio.setInterlaced false
            )

            -- This allows the user to setup the file save type
            getBitmapSaveFilename Caption:"The path and filename don't matter" filename:((getFilenamePath rendFile) + "\\Allows you to change the Setup of the file type" + (getFilenameType rendFile))

            newPath = (getFilenamePath rendFile) + (getFilenameFile rendFile) + "_Elements\\"

            if (makeDir newPath all:true) then (
                -- The elements directory was created successfully

                for i = 0 to (theManager.numRenderElements() - 1) do (    
                    -- For each render element, set the filename
                    theCurRenderElement = (theManager.getRenderElement i)

                    -- New Sub-Directory for each Render Element
                    newPath = (getFilenamePath rendFile) + (getFilenameFile rendFile) + "_Elements\\"
                    newPath += (i as string) + "_" + (theCurRenderElement.elementName) + "\\"

                    if (makeDir newPath all:true) then (            
                        newName = newPath + (getFilenameFile rendFile) + "_" + (theCurRenderElement.elementName) + "_" + (getFilenameType rendFile)

                        theManager.SetRenderElementFilename i newName
                        theCurRenderElement.enabled = true

                        -- Check if VRay frame buffer is on and turn on "Save separate render channels"
                        if renderers.current.output_on then (
                            renderers.current.output_splitgbuffer = true
                            renderers.current.output_splitRGB = true
                            --renderers.current.output_splitAlpha = false
                            renderers.current.output_splitfilename = newPath + (getFilenameFile rendFile) + (getFilenameType rendFile)
                        )
                    ) else (
                        messageBox "Could not create the new render element directories."
                    )
                )
            ) else
                messageBox "Could not create the Render Elements Directory.\nDo you have permission to write to the render output folder?"

            if RSDWasOpen then (
                renderSceneDialog.open()
            )
        ) else (
            messageBox "No Render Output filename found"
        )
    ) else
        messageBox "V-Ray is not the current renderer"
)
)

Cool! Thanks! I’ll give it a shot.

After some evaluation, using the RGB_color-pass from the VFB and completely ignoring the 3dsmax file dialogue was the easiest solution. We’ll have to change the workflow a bit, but it’s still better than the options.
Still think it would be natural for vray to name and save the passes accordingly, even if you choose to use the 3dsmax save file box.