pysdic_blender.BlenderAreaLight#

class BlenderAreaLight(position, direction, *, size, size_y=None, shape='SQUARE', up=None, energy=1000.0, color=(1.0, 1.0, 1.0), spread=3.141592653589793)[source]#

Bases: object

An area light of Blender: a flat emitting surface (square, rectangle, disk or ellipse), e.g. an LED panel or a diffuser.

  • shape: "SQUARE" or "DISK" (one dimension size), "RECTANGLE" or "ELLIPSE" (dimensions size along the local \(x\) axis and size_y along the local \(y\) axis);

  • energy: the total power in watts emitted by the surface (Blender convention);

  • color: the linear RGB color of the light (white by default);

  • spread: the angle of the cone of emission of each point of the surface, in radians in \(]0, \pi]\) (\(\pi\): a Lambertian emitter; smaller: a directional panel, like a honeycomb grid).

The surface is centered on position and emits from one side only, along direction (the local \(-z\) axis of the Blender light). Its local \(y\) axis (along size_y) is up made orthogonal to direction: it orients a rectangle or an ellipse around the direction. The object is immutable.

Parameters:
  • position (ArrayLike) – The center \((3,)\) of the surface in the world.

  • direction (ArrayLike) – The direction \((3,)\) of emission, normal to the surface (normalized).

  • size (Real) – The side ("SQUARE", "RECTANGLE") or the diameter ("DISK", "ELLIPSE") along the local \(x\) axis, in the unit of the scene (positive).

  • size_y (Optional[Real], optional) – The dimension along the local \(y\) axis, required for "RECTANGLE" and "ELLIPSE", forbidden for "SQUARE" and "DISK".

  • shape (str, optional (default: "SQUARE")) – "SQUARE", "RECTANGLE", "DISK" or "ELLIPSE".

  • up (Optional[ArrayLike], optional) – The direction \((3,)\) of the local \(y\) axis of the surface (made orthogonal to direction, must not be parallel to it). By default, an arbitrary deterministic axis (see up): give it for a rectangle, an ellipse or a square whose orientation matters.

  • energy (Real, optional (default: 1000.0)) – The power in watts (non-negative).

  • color (ArrayLike, optional (default: (1.0, 1.0, 1.0))) – The RGB color \((3,)\), non-negative linear values.

  • spread (Real, optional (default: pi)) – The angle of emission in radians, in \(]0, \pi]\).

Examples

from pysdic_blender import BlenderAreaLight

panel = BlenderAreaLight.looking_at(
    [0.0, -300.0, 500.0], [0.0, 0.0, 0.0], size=200.0, size_y=100.0, shape="RECTANGLE",
    up=[1.0, 0.0, 0.0], energy=2e5,
)
property area: float#

The area of the emitting surface.

property color: ndarray#

The linear RGB color \((3,)\) of the light (read-only).

property direction: ndarray#

The unit direction \((3,)\) of emission, normal to the surface (read-only).

property energy: float#

The total power in watts.

classmethod from_dict(data)[source]#

Create a light from a dictionary of to_dict() (position, direction and size required, the default values of the constructor for the other fields).

Parameters:

data (Dict[str, Any])

Return type:

BlenderAreaLight

classmethod from_json(path)[source]#

Create a light from a JSON file (see from_dict()).

Parameters:

path (str)

Return type:

BlenderAreaLight

classmethod looking_at(position, target, **kwargs)[source]#

Create an area light centered at position emitting towards target (other inputs as the constructor).

Parameters:
  • position (ArrayLike)

  • target (ArrayLike)

  • kwargs (Any)

Return type:

BlenderAreaLight

property position: ndarray#

The center \((3,)\) of the surface (read-only).

property quaternion: ndarray#

local \(-z\) along direction, local \(y\) along up.

Type:

The rotation (w, x, y, z) of the Blender light object

property shape: str#

"SQUARE", "RECTANGLE", "DISK" or "ELLIPSE".

Type:

The shape

property size: float#

The side or the diameter along the local \(x\) axis.

property size_y: float | None#

The dimension along the local \(y\) axis (up), None for "SQUARE" and "DISK".

property spread: float#

Lambertian).

Type:

The angle of emission in radians (\(\pi\)

to_dict(description=None)[source]#

Export the light to a dictionary (position, direction, up, shape, size, size_y, energy, color, spread). up is the actual local \(y\) axis, so the orientation is kept exactly.

Parameters:

description (str | None)

Return type:

Dict[str, Any]

to_json(path, description=None)[source]#

Export the light to a JSON file (see to_dict()).

Parameters:
  • path (str)

  • description (str | None)

Return type:

None

property up: ndarray#

The unit local \(y\) axis \((3,)\) of the surface, orthogonal to direction (along size_y, read-only): up of the constructor made orthogonal, or the default axis chosen when up is None.