pysdic_blender.BlenderSpotLight#

class BlenderSpotLight(position, direction, *, energy=1000.0, spot_size=0.7853981633974483, spot_blend=0.15, color=(1.0, 1.0, 1.0), radius=0.0)[source]#

Bases: object

A spot light of Blender: a cone of light emitted from a position along a direction.

  • energy: the power in watts the light would emit without the cone (Blender convention);

  • spot_size: the full opening angle of the cone, in radians in \([0, \pi]\);

  • spot_blend: the fraction of the cone with a smooth edge, in \([0, 1]\) (0: sharp edge);

  • color: the linear RGB color of the light (multiplies the emitted power on each channel, white by default);

  • radius: the radius of the emitting sphere (shadow_soft_size of Blender), 0 for a point source.

Radius. Cycles renders the light as a sphere of radius radius emitting the same total power. A point source (radius = 0, default) gives sharp shadows and tiny, very intense specular highlights on a glossy surface; a real projector (a few centimeters) gives soft shadows (penumbra of width about 2 radius times the ratio of the distances occluder-surface / light-occluder) and larger, less saturated highlights. The sphere is physically correct (the “soft falloff” of Blender is disabled).

A Blender light emits along its local \(-z\) axis: its rotation maps \(-z\) to direction (the rotation around the direction does not matter for a spot light). The object is immutable.

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

  • direction (ArrayLike) – The direction \((3,)\) of the axis of the cone (normalized).

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

  • spot_size (Real, optional (default: pi / 4)) – The full opening angle in radians.

  • spot_blend (Real, optional (default: 0.15)) – The fraction of the cone with a smooth edge.

  • color (ArrayLike, optional (default: (1.0, 1.0, 1.0))) – The RGB color \((3,)\) of the light, non-negative linear values (scene-linear Rec.709, as all the colors of Blender). The power of the channel \(c\) is energy * color[c].

  • radius (Real, optional (default: 0.0)) – The radius of the emitting sphere, in the unit of the scene (non-negative, 0 for a point source). Not the default 0.25 of Blender, whose meaning depends on the unit of the scene.

Examples

from pysdic_blender import BlenderSpotLight

light = BlenderSpotLight.looking_at([0.0, -200.0, 600.0], [0.0, 0.0, 0.0], energy=5e5)
property color: ndarray#

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

property direction: ndarray#

The unit direction \((3,)\) of the axis of the cone (read-only).

property energy: float#

The power in watts.

classmethod from_dict(data)[source]#

Create a light from a dictionary of to_dict() (the default values of the constructor for the missing optional fields, e.g. a white light without color).

Parameters:

data (Dict[str, Any])

Return type:

BlenderSpotLight

classmethod from_json(path)[source]#

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

Parameters:

path (str)

Return type:

BlenderSpotLight

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

Create a spot light at position pointing to target (other inputs as the constructor).

Parameters:
  • position (ArrayLike)

  • target (ArrayLike)

  • kwargs (Any)

Return type:

BlenderSpotLight

property position: ndarray#

The position \((3,)\) (read-only).

property quaternion: ndarray#

The rotation (w, x, y, z) of the Blender light object (local \(-z\) along direction).

property radius: float#

The radius of the emitting sphere (shadow_soft_size of Blender), 0 for a point source.

property spot_blend: float#

The fraction of the cone with a smooth edge.

property spot_size: float#

The full opening angle in radians.

to_dict(description=None)[source]#

Export the light to a dictionary (position, direction, energy, spot_size, spot_blend, color, radius).

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