ManimMaterial

Qualified name: algan.rendering.shaders.materials.ManimMaterial

class ManimMaterial(color=None, *, opacity=1.0, transparent=False, visible=True, side=Side.FRONT, flat_shading=False, vertex_colors=False, wireframe=False, tone_mapped=True, **texture_kwargs)[source]

Bases: Material

Manim’s default 3-D shading: one achromatic offset per light, nothing else.

Per light it adds an achromatic 0.5 * (n . to_light) ** 3 offset (halved when back-facing) to the base color – no ambient, no specular, no falloff.

Reproduces Manim’s get_shaded_rgb exactly under the rig use_manim_defaults() installs (one white intensity-1 point light); see manim_shader() for the precise conditions. It has no properties of its own beyond the shared Material ones, but get_shader_param_values() still carries flat_shading: the packed material block is written name by name, so an empty dict would leave that slot at its default and ManimMaterial(flat_shading=True) would silently do nothing.

use_manim_defaults() installs this material as the default for 3-D Mobs alongside the rig it sets up.

It means “Manim’s version of this”, so it lives with the rest of that layer: import algan.manim as mn then mn.ManimMaterial, rather than from algan import *.

Methods

get_shader_param_values

Map of {shader_param_name: value} matching this material's shader signature.

shader

Shade a surface with Manim's default 3-D lighting model.

Attributes

applies_color

Whether the material's color should drive the mob's base color.

get_shader_param_values()[source]

Map of {shader_param_name: value} matching this material’s shader signature. Base materials expose no extra parameters.

static shader(memory, vertex_location, vertex_normal, albedo_color, camera_location, light_origin, light_color, light_intensity, ambient_light_intensity, flat_shading=0.0)

Shade a surface with Manim’s default 3-D lighting model.

Implements Manim’s get_shaded_rgb: each light contributes an offset of 0.5 * (n . to_light) ** 3 – halved when the surface faces away from the light, so back-facing surfaces darken at half the rate front-facing ones brighten. There is no ambient term, no specular lobe and no distance falloff; ambient_light_intensity is accepted for signature parity but unused, because Manim’s model has none.

Under Manim’s own rig – the single white PointLight of intensity 1 that use_manim_defaults() installs, with decay 0 and distance 0 – the light-color factor below is exactly (1, 1, 1) and the offset reproduces Manim’s scalar one exactly. Multiplying by light_color * light_intensity is a strict generalisation to colored and multi-light rigs, which Manim does not have; the per-light offsets simply sum.

Manim adds its offset to display-referred sRGB values. Under the default linear working space this shader therefore encodes the base color to sRGB, adds the offsets there, clamps the sum to [0, 1] and decodes back to linear light; under the display-referred setting it adds and clamps directly. Exact Manim fidelity further assumes exposure 1 and tonemapping off – which is what use_manim_defaults() sets; any other exposure or tonemap curve maps the result as Manim never would.

Parameters:
  • memory – Scratch-tensor provider supplied by the renderer. Unused here.

  • vertex_location – Location of the vertex to shade, shape (*, 3); the renderer’s triangle path passes (*, 3, 3) corners.

  • vertex_normal – Surface normal at the vertex; need not be normalized. Shape (*, 3).

  • albedo_color – Base color with its trailing glow channel, shape (*, 4), which is also the shape of the return value.

  • camera_location – Camera position, shape (*, 3). Accepted for signature parity; Manim’s model is view-independent, so this shader ignores it.

  • light_origin – Position of the light source, shape (*, 3).

  • light_color – Color of the light with its trailing opacity channel, shape (*, 4); only its RGB is used.

  • light_intensity (float) – Multiplier on the light’s contribution. Defaults to whatever the renderer passes (1 for Algan’s stock rig).

  • ambient_light_intensity (float) – Accepted for signature parity; unused, since the model has no ambient term.

  • flat_shading (float) – Blend of the interpolated normal toward the flat per-face normal, from 0 (smooth, the default) to 1 (flat).