Setting Vray Frame Buffer via Maxscript

I maybe wrong about this but I can’t seem to find a reference for setting the size of the Vray Frame Buffer via maxscript.
I can set the output size of the image but how do I resize the existing frame buffer?

The reason I need to do it is I want to set the vray region with a script, this works well if the region is smaller than the current size of the frame buffer but doesn’t set correctly if the region is bigger or some part of it is outside the current frame buffer resolution.
Example:
Current Frame buffer size: 640x480 output size: 640x480 region: (0 0 200 200) this works fine
Current Frame buffer size: 640x480 output size: 1500x1500 region: (1000 1000 1500 1500) this will not be set properly as the region coordinates are outside the current buffer size

When you hit render the vray frame buffer automatically resizes to the output size and after that you can set the right region render coordinates.

Hello!

Thank yoy for reporting this case. Unfortunately, we don’t have a maxscript command for setting the VFB frame size.
The proper handling here would be to enhance the setregion command so that it reads correctly the render output size from render setup and not conform to the default VFB frame resolution. I logged this issue in our bug tracking system (the exact issue number is VMAX-8896).
I can suggest this workaround until we fix it:
Load some image with proper resolution (you don’t even need to open VFB), clear VFB and then set the region.


vfbControl #loadimage "D:\\del\\black1500x1500.png"
vfbControl #clearimage
vfbControl #setregion 1000 1000 1500 1500

It’s not an elegant solution. You should also have in mind that the image you load needs to have the exact resolution as your render output (else the render region will scale).

Best regards,
Margarita

Hi Margarita,
thanks I came to the same un-elegant conclusion as well.

Here is a function for anyone else who is looking

fn setVFBSize _w _h setVFBRegion: = 
    (
        -- Workaround for setting the size of the vray frame buffer by loading the right size image into it.

        local vraySizeBitmap = bitmap _w _h color:black filename:((getdir #temp)+"\\vraySizeBitmap.jpg")
        save vraySizeBitmap
        close vraySizeBitmap
        vfbControl #loadimage vraySizeBitmap.filename    
        deletefile vraySizeBitmap.filename
        free vraySizeBitmap
        vfbControl #clearimage

        if setVFBRegion != unsupplied then (vrayVFBSetRegion setVFBRegion[1] setVFBRegion[2] setVFBRegion[3] setVFBRegion[4])

    )
--use
setVFBSize 1000 1000 setVFBRegion:#(0, 0, 500, 500)

--for no region just resize
setVFBSize 1000 1000

Wow!
Thank you for sharing!

ahah, nice hack, well thought out!