nukkio / Blender-Control-Render-Region

addon for control render region
GNU General Public License v3.0
0 stars 0 forks source link
addon blender blender-addon python render-region rendering renderregion

Blender Addon: Control Render Region

ScreenshotRenderRegion_20230319_16-35

A Blender Addon to manage renders with Render Region. This addon divides the render of a project into regions and allows you to render all or only some of them.

Useful in several cases, for example:

The regions are rendered top to bottom left to right, so the first one will be the top left and the last one will be the bottom right.

divisioneRegioni

You can add margins to regions to have overlapping areas: this way you can avoid problems due to denoise in cycles or effects in the compositor, for example "glare", when merging regions.

Tested with Cycles and Eevee with Blender 3.4.0, in Ubuntu 20.04 and Windows 10.

To merge all images from script (created by this addon) imagemagick and python 3 must be installed.

Blender version: 3.4.

Installation

Use

How the addon works

There are two methods: Divide and Multiply

Divide

The render is divided into regions according to the values indicated in the "Columns" and "Rows" fields. "Columns" indicates how many parts the width of the render is divided into, while "Rows" indicates the division of the height. The "regions to render" field indicate the regions to render.

For example:

Multiply

The resolution, X and Y, is multiplied by the value indicated in "multipler" and the render is divided into regions, all with the original resolution Example:

Margins

This addon can be used with both Cycles and Eevee, but with Cycles there are problems using "Denoise" (Tab Render Properties > Sampling panel > Render - Denoise check): the "denoise" produces artifacts along the edges of the image, usually only for single pixels along the edges: by merging the images these artifacts will be clearly visible as they are all close and aligned. Other possible problems during merging can be given by effects in compositor, such as the "glare" which adds a halo around the brightest pixels: if these pixels are located near the edge of the region the effect will add the halo which may be larger than the edge distance and therefore be cut off. Combining the images you will see the halo cut out.

To fix this problem, the regions need to be enlarged by adding a margin which will then be cropped before merging the images.

Since the regions are calculated in a relative way and not in pixels, it is difficult to find a value for the margin compatible with the render size, because you have to avoid rounding problems that would affect the render size.

The button "Calculate Margins" finds the largest margin, starting from the value in "Max Margin" going backwards, which generates values with fewer decimals, safer.

The first best values found are written in the "w" and "h" fields. Any other values are reported in the terminal.

If no safe values are found, 0 is returned. In this case you need to change the rendering size, or the number of regions, or increase the "Max Margin" value.

You can choose the value of the margins without calculating it with the "Calculate margins" button, but rounding errors will be possible.

Bash and Python script

Selecting "Create bash and python script" the "render region" button will not launch the renders, but will write a script (.sh bash script in Linux and MacOS, .bat batch script in Windows), and a python script in the output folder.

The bash script launches renders of the selected regions. In the script there are commands for all rendering; the regions not to be rendered are commented out. At the end of the script is the command to run the python script; is commented. To launch the images cropping/appending procedure after rendering, uncomment the line with the command "python name of blender project.py". In .bat it will be: "::python xxxx.py" and in .sh: "#python xxxx.py"; in both cases it must become: "python xxxx.py"

The python script crops and merges all regions to get the final image.

Create Reference Image

The "Create Reference Image" button generates a reference image (using imagemagick); region borders are drawn with red lines, and margins (or overlapping areas) with semi-transparent areas. All regions are numbered. ScreenshotRR_refImg_20230319_16-45

Values

License

Control Render Region is distributed under the terms of the GNU General Public License, version 3