blenderproc.python.types.LightUtility module

This class allows the creation and management of lights in the scene.

class blenderproc.python.types.LightUtility.Light(light_type='POINT', name='light', blender_obj=None)[source]

Bases: Entity

This class allows the creation and management of lights in the scene. However, we advise to use emissive materials on objects to light a scene as these produce more realistic light scenarios as the lighting does not directly start from a small point in space.

get_color(frame=None)[source]

Returns the RGB color of the light.

Parameters:

frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

Return type:

Color

Returns:

The color at the specified frame.

get_distance(frame=None)[source]

Returns the falloff distance of the light (point where light is half the original intensity).

Parameters:

frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

Return type:

float

Returns:

The falloff distance at the specified frame.

get_energy(frame=None)[source]

Returns the energy of the light.

Parameters:

frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

Return type:

float

Returns:

The energy at the specified frame.

get_radius(frame=None)[source]

Returns the radius / shadow_soft_size of the light.

Parameters:

frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

Return type:

float

Returns:

The radius at the specified frame.

get_type(frame=None)[source]

Returns the type of the light.

Parameters:

frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

Return type:

str

Returns:

The type at the specified frame.

set_color(color, frame=None)[source]

Sets the color of the light.

Parameters:
  • color (Union[list, Color]) – The rgb color to set.

  • frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

set_distance(distance, frame=None)[source]

Sets the falloff distance of the light = point where light is half the original intensity.

Parameters:
  • distance (float) – The falloff distance to set.

  • frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

set_energy(energy, frame=None)[source]

Sets the energy of the light.

Parameters:
  • energy (float) – The energy to set. If the type is SUN this value is interpreted as Watt per square meter, otherwise it is interpreted as Watt.

  • frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

set_radius(radius, frame=None)[source]

Sets the radius / shadow_soft_size of the light.

Parameters:
  • radius (float) – Light size for ray shadow sampling (Raytraced shadows).

  • frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

set_type(light_type, frame=None)[source]

Sets the type of the light.

Parameters:
  • light_type (str) – The type to set, can be one of [POINT, SUN, SPOT, AREA].

  • frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.

setup_as_projector(pattern, frame=None)[source]

Sets a spotlight source as projector of a pattern image. Sets location and angle of projector to current camera. Adjusts scale of pattern image to fit field-of-view of camera: (0.5 + \frac{X}{Z \cdot F}, 0.5 + \frac{X}{Z \cdot F \cdot r}, 0) where $F$ is focal length and $r$ aspect ratio. WARNING: This should be done after the camera parameters are set!

Parameters:
  • pattern (ndarray) – pattern image to be projected onto scene as np.ndarray.

  • frame (Optional[int]) – The frame number which the value should be set to. If None is given, the current frame number is used.