Light

Qualified name: algan.rendering.lights.Light

class Light(*args, intensity=1.0, **kwargs)[source]

Bases: Mob

Base class of all light sources.

Parameters:

intensity – Dimensionless multiplier applied to the light’s color: at 2 the light contributes exactly twice the radiance it does at 1. Pixel values do not double with it, because exposure and the sRGB transfer function sit between radiance and the byte written to the frame. Must be a finite number of at least 0.0. Defaults to 1.0. The constructor argument is the light’s initial value and is not animated; animate with assignment after spawn – see Animation below.

Raises:

.AlganConfigurationError – If intensity is not a finite number of at least 0.0, on construction or on any later write.

intensity

The light’s brightness multiplier: a dimensionless finite number of at least 0.0, applied to the light’s color every frame. Defaults to 1.0.

Animation

Writing light.intensity = 3 after spawn is recorded: the value interpolates from its current value to the target over the current context’s runtime (1 second by default), exactly like writing color – wrap it in with Off(): to apply instantly instead. Writes made before spawn are instant setup, as with location. Like any Mob attribute write the change propagates to descendants (lights normally have none).

Methods

set_animated_attribute

Animate one animatable attribute to a new value, by name.

spawn

Spawn this light and register it with its owning scene exactly once.

Attributes

animation_manager

This mob's scene-owned animation manager.

basis

The Mob's orientation and scale, as a flattened 3x3 matrix of shape (*, 9).

casts_shadows

Whether this Mob's geometry blocks light on its way from a light source to another surface -- whether it casts a shadow.

children

The Mobs attached below this one, in attachment order.

closed_shell

Whether this Mob's triangles form a CLOSED shell -- every camera ray that enters the geometry crosses a second time on its way out.

draws_descendants

Whether get_render_primitives returns geometry belonging to this Mob's DESCENDANTS as well as its own.

forward

Get the direction the Mob is facing.

lifespan

This mob's [spawn, despawn) interval on its Scene timeline (a Lifespan).

light_type

location

The Mob's position in world space, shape (*, 3).

normalized_basis

The Mob's orientation with scale divided out, shape (*, 9).

parents

The Mobs this one is attached to, in attachment order.

receives_shadows

Whether this Mob's surfaces are darkened by shadows cast onto them.

right

Get the Mob's own rightward direction.

scale_coefficient

The Mob's scale along its own right, up and forward axes, shape (*, 3).

two_sided

Whether this Mob's geometry should be lit from whichever side the ray arrives on.

up

Get the Mob's own upward direction.

x

The Mob's x coordinate in world units, shape (*, 1).

xy

The Mob's x and y coordinates in world units, shape (*, 2).

y

The Mob's y coordinate in world units, shape (*, 1).

z

The Mob's z coordinate in world units, shape (*, 1).

set_animated_attribute(attr, value, recursive=True)[source]

Animate one animatable attribute to a new value, by name.

As set_animated_attribute(), and additionally the one place an intensity write is checked. Every route to that attribute – assignment, set_intensity, set() and set_non_recursive() – passes through here, so a light cannot reach the renderer with a negative or non-finite brightness.

Raises:

.AlganConfigurationError – If attr is "intensity" and value is not a finite number (or tensor of numbers) of at least 0.0.

spawn(animate=True)[source]

Spawn this light and register it with its owning scene exactly once.

Parameters:

animate (bool)