blenderfunc.render

Color

render_color(filepath='/tmp/temp.png', save_blend_file=False, samples=32, denoiser=None, max_bounces=3, color_mode='RGB', color_depth=8)

Render a color image and save it to the specified filepath

Parameters
  • filepath – the output image path

  • save_blend_file – save the “.blend” file if true

  • samples – samples per pixel for rendering, higher value for higher quality but slower rendering

  • denoiser

    denoiser type for rendering, options:

    • None, no denoiser

    • NLM, native non-local means denoiser running on CPU

    • OpenImageDenoise, Intel OpenImageDenoise AI Denoiser running on CPU

    • OPTIX, Optix AI denoiser with GPU acceleration

  • max_bounces – max number of light bounces, higher value for higher quality but slower rendering

  • color_mode – RGB or BW

  • color_depth – 8 or 16 bits

Depth

render_depth(filepath='/tmp/temp.png', depth_scale=5e-05, save_blend_file=False, save_npz=True)

Render a depth image and save it to the specified path, unit meter

Parameters
  • filepath – the output image path

  • depth_scale – the depth value will be quantized by divide this value

  • save_blend_file – save the “.blend” file if true

  • save_npz – save the raw depth array to a “.npz” (compressed numpy) file if true

Normal

render_normal(filepath='/tmp/temp.png', save_blend_file=False, save_npz=True)

Render a normal image and save it to the specified path

Parameters
  • filepath – the output image path, only for visualization

  • save_blend_file – save the “.blend” file if true

  • save_npz – save the raw normal array to a “.npz” (compressed numpy) file if true

SegMap

render_class_segmap(filepath='/tmp/temp.png', save_blend_file=False, save_npz=True)

Render a class segmentation map and save it to a specified filepath. You should first set the custom properties class_id of each objects in the scene first, otherwise, all objects will have a default class_id = 0.

Parameters
  • filepath – the output image path, only for visualization

  • save_blend_file – save the “.blend” file if true

  • save_npz – save the class segmentation map array to a “.npz” (compressed numpy) file if true

render_instance_segmap(filepath='/tmp/temp.png', save_blend_file=False, save_npz=True)

Render a instance segmentation map and save it to a specified filepath

instance_id: background(void space) = 0, other objects = 1, 2, 3, …

Parameters
  • filepath – the output image path, only for visualization

  • save_blend_file – save the “.blend” file if true

  • save_npz – save the instance segmentation map array to a “.npz” (compressed numpy) file if true

LightMask

render_light_mask(filepath='/tmp/temp.png', light_name='', cast_shadow=True, energy=100, threshold=0.0, save_blend_file=False)

Render a light mask image and save it to a specified filepath

Parameters
  • filepath – the output image path

  • light_name – the name of the light source

  • cast_shadow – whether cast the shadow of light

  • energy – light energy

  • threshold – threshold to control the area of shadow area, higher value for larger shadow area

  • save_blend_file – save the “.blend” file if true

ObjectMasks

render_object_masks(filepath='/tmp/temp.png', save_blend_file=False, save_npz=True, downsample=1)

Render masks of all objects

Parameters
  • filepath – the output image path, only for visualization

  • save_blend_file – save the “.blend” file if true

  • save_npz – save the instance segmentation map array to a “.npz” (compressed numpy) file if true

  • downsample – to speed up rendering, reduce the image resolution

Others

apply_binary_mask(filepath, maskpath, outputpath=None)

Apply a binary mask to a image and save it to a specified path

Parameters
  • filepath – input image filepath

  • maskpath – input mask filepath

  • outputpath – output image filepath, if it is None, outputpath will be equal to filepath