Blender has the ability to limit the scope of rendering – outlining a region the special render border and checking the Border checkbox on the Render – Dimensions tab in Properties window. If such frame is set – Blender render only a limited area of the image.
There are two ways to set render border via the Blender API:
- With the view3d.render_border operator:
1 |
bpy.ops.view3d.render_border(xmin=188, xmax=423, ymin=271, ymax=489) |
This operator is used in the 3D VIEW context:
1 |
bpy.context.area.type = 'VIEW_3D' |
Border coordinates countdown starts from the top-left corner of all window (0,0) and ends in the lower-right corner with values correspond to the window size.
- With modifying scene properties – maximum and minimum border boundaries relatively to the rendering camera view:
1 2 3 4 |
bpy.context.scene.render.border_min_x = 0.3 bpy.context.scene.render.border_min_y = 0.2 bpy.context.scene.render.border_max_x = 0.9 bpy.context.scene.render.border_max_y = 0.8 |
In this case, the render border coordinates set as a percentage ratio to the resolution of the rendering scene (camera view). The render width and height are equal to one unit, and the render border coordinates are set as a proportion of it.
In both cases, to activate render border usage the Border checkbox turns on with:
1 |
bpy.context.scene.render.use_border = True |
Hi there do you know how to get the coordinates from the render border when its in 3dview. I know how to set it and but in need to coordinates for a different render engine. I use a different engine and with draw_gl i then draw that image in the viewport.
Hi!
You can get render border coordinates of view3d border through:
bpy.data.screens[‘Default’].areas[number_of_3dview_area].spaces[number_of_3dview_space].render_border_min_x
for example it may be:
bpy.data.screens[‘Default’].areas[3].spaces[0].render_border_min_x
OKay great, this info is hard to get. Nobody seems to be interested in that data. I couldnt see the correct data cause in Hiver info is wrapped.
So the others are render_border_min_y etc etc
Thanks hope ill manage to find correct areas and spaces. Not sure why they dont use the same as the other but simpler reference
This is the problem of the right context. If you execute your operator from the window with right context, for example you create a button in T-panel of 3d-view window, you can use the simple bpy.context.area.spaces.active to have the required area and space. But if you try to execute this comman from, for example python-console window, you will have an error. So, if you are sure, that the context is right, you can use bpy.context. If it is not so, you will hav an error or you need to rewrite the context.
Thanks again, i got it working how i want it to work. Now i need to work a bit on getting it pixel perfect. Think i need to check functions and see where i can add int.
I got both function of render border now working, from camera as well as 3dview.
Thanks man this really helped. I really had been googling for couple hours
https://www.dropbox.com/s/l6ave3o4x1txq6v/Screengrab_IRmode_v3d-mode.png?raw=1
I found this, area.spaces.active, which is way shorter and i dont need to make 2 loops