# graphics3d/toon/toonlightset (vanilla-engine 0.4.0)

> https://vanillapunch.com/docs/vanilla-engine/0.4.0/api/graphics3d/toon/toonlightset/

Toon light set. (ToonLightSet of vanilla.js graphics3d/toon/toonlightset.js)
- Holds as one bundle the lights ToonRenderer uses to shade bodies and the toon light response. The renderer holds one default set, and the renderer's light settings such as set_light change that set.
  Another set can be given per draw with light_set of ToonDrawOptions. (When the shade color differs per material)
- Sun (key light): the direction (sun_direction) is the way the light travels. It is the opposite of the direction from the surface toward the sun. ([0, -1, 0] when shining down from above) It receives shadows.
- Ambient light: sky color and ground color are mixed by the up and down of the normal (N.y x 0.5 + 0.5). (Hemisphere light)
- Shade ramp (cel shading): the received light amount x is laid against the ramp to pick the color. x is dot(N, L) x 0.5 + 0.5 for half Lambert, otherwise max(dot(N, L), 0),
  and after adding the draw's shade_offset, for the sun it is multiplied by the shadow (received amount 0 ~ 1). (Shadows enter as the shade color rather than black, System Shadows of the Unity Toon Shader)
  The ramp has a position, color (linear multiplier) and softness per cell (stop). The color of cell i transitions from the previous cell's color as x rises from (position - softness) to the position. (Step and Feather of the Unity Toon Shader)
  If the softness is smaller than one pixel width (fwidth), it is held at that width so the boundary does not stair-step.
  set_shade builds the ramp from three, base, 1st shade and 2nd shade, set_shade_ramp from cells directly, set_band_count from even cells, set_band_ramp from gray cells.
  If set_ramp_texture is given, the horizontal of that texture (x as u, v is 0.5) is read instead of cells. Without cells (clear_shade_ramp, set_band_count(0)) it is smooth Lambert.
- Per light: the sun receives the whole ramp color so the shade also takes on the sun's color. The fill light, point lights and spotlights receive the ramp's brightness level (bottom cell 0, top cell 1) and do not light faces turned away.
- Fill light (fill): a second directional light that receives no shadow. The direction means the same as the sun. With the default color 0 there is none.
- Highlight (specular): Blinn-Phong pow(max(dot(N, H), 0), exponent), from a hard spot cut at 0.5 (softness 0) to the plain soft light (softness 1). Color x strength x light color x received light level.
  It appears for the sun, point lights and spotlights alike. With the default strength 0 there is none.
- Rim light (rim): pow(1 - max(dot(N, V), 0), power), from a hard rim cut at 0.5 (softness 0) to a soft rim (1). If light_mask is 1, only on the side receiving the sun. Added regardless of the base color.
  The shade-side rim (set_shade_rim_light) adds the same rim on the side facing away from the sun by (rim - (dot(N, L) x 0.5 + 0.5)). (Antipodean (Ap) Rim Light of the Unity Toon Shader)
- Light color usage (set_light_color_usage): chooses per color whether the light color is multiplied. When off, the base, shade and highlight receive only the light's intensity (0.299 R + 0.587 G + 0.114 B), and the rim, matcap, angel ring and outline receive no light. (Is_LightColor_* of the Unity Toon Shader, all on by default)
- Light intensity limit (set_light_intensity_limited): limits what each light gives to 1. The sun and fill light are clamped to 1 per channel, and point lights and spotlights are divided by the intensity of their color with attenuation applied when it exceeds 1.
  (Limit Light Intensity of the Unity Toon Shader, on by default) Turn it off to use strong lights for HDR bloom.
  When porting an old game shader (one that did not limit light intensity), or when using point lights above intensity 1 or HDR bloom, use set_light_intensity_limited(false).
- Point lights and spotlights: up to TOON_MAXIMUM_POINT_LIGHTS. (ToonPointLight)
  Attenuation is window x distance attenuation. The window is (1 - (distance / range)^range_exponent) clamped to 0 ~ 1 and squared if range is above 0, and 1 if 0. Distance attenuation is 1 / max(distance^decay, 0.01) if decay is above 0, and 1 if 0.
  Lights with casts_shadow true get shadow tiles from ShadowAtlas::update_lights(read_shadow_light_sources()). (Six cube faces for a point light, one perspective tile for a spotlight)
  With direction (the way the light travels) it is a spotlight. Angular attenuation is the square of clamp(cos angle x scale + offset, 0, 1) in the glTF KHR_lights_punctual form.
  The received amount is the wrap (dot(N, L) + wrap) / (1 + wrap). (0 is Lambert, the wrap lighting of GPU Gems 1)
- Light model: if set_light_model(ToonLightModel { is_energy_normalized }) is true, base color x light is divided by π and the highlight is multiplied by (exponent + 8) / 8π.
- All colors are linear colors. (they may exceed 1 for HDR) The ramp texture is treated as sRGB and read converted to linear. (by the shader with pow 2.2 in the gamma color space, by the GPU as an sRGB texture in the linear color space)
- Each change raises the version number (get_version). The renderer does not upload again if the set ID (get_id) and version number are the same.

Example: A light set with two shade color levels, hard highlight, rim and spotlight

```rust
use vanilla::{ToonLightSet, ToonPointLight, ToonShade};

let mut light_set = ToonLightSet::new();
light_set.set_light([-0.4, -1.0, -0.3], [0.85, 0.82, 0.78], [0.3, 0.33, 0.42], [0.16, 0.15, 0.14]);
light_set.set_shade(ToonShade { step: 0.5, feather: 0.02, color: [0.55, 0.52, 0.7], second_step: 0.25, second_feather: 0.02, second_color: [0.36, 0.33, 0.52], is_half_lambert: true });
light_set.set_specular(0.6, 64.0, 0.0, [1.0, 1.0, 1.0]);
light_set.set_rim_light([0.5, 0.55, 0.7], 3.0, 0.2, 1.0);
light_set.set_point_lights(&[ToonPointLight { position: [0.0, 3.0, 0.0], color: [1.0, 0.8, 0.6], intensity: 3.0, range: 6.0, direction: Some([0.0, -1.0, 0.0]), inner_cone_angle: 0.3, outer_cone_angle: 0.6, ..ToonPointLight::default() }]);
assert_eq!(light_set.get_shade_ramp().positions.len(), 3);
assert_eq!(light_set.get_point_light_count(), 1);
```

## ToonPointLight (struct) (Clone, Copy, Debug, PartialEq, Default)

One point light or spotlight. (one object of the original setPointLights)

Example: One spotlight shining down

```rust
use vanilla::{ToonLightSet, ToonPointLight};

let mut light_set = ToonLightSet::new();
light_set.set_point_lights(&[ToonPointLight { position: [0.0, 4.0, 0.0], color: [1.0, 0.9, 0.7], intensity: 4.0, range: 8.0, direction: Some([0.0, -1.0, 0.0]), inner_cone_angle: 0.25, outer_cone_angle: 0.5, ..ToonPointLight::default() }]);
assert_eq!(light_set.get_point_lights()[0].direction, Some([0.0, -1.0, 0.0]));
```

- `pub position: [f64; 3]` (field, since 0.4.0): World position.
  - returns [f64; 3]
- `pub color: [f64; 3]` (field, since 0.4.0): Linear color.
  - returns [f64; 3]
- `pub intensity: f64` (field, since 0.4.0): Strength multiplied by the color.
  - returns f64
- `pub range: f64` (field, since 0.4.0): Window range. (0 for unlimited)
  - returns f64
- `pub decay: f64` (field, since 0.4.0): Distance attenuation exponent. (0 for no distance attenuation)
  - returns f64
- `pub range_exponent: f64` (field, since 0.4.0): Window shape exponent.
  - returns f64
- `pub wrap: f64` (field, since 0.4.0): Wrap factor. (0 for Lambert)
  - returns f64
- `pub direction: Option<[f64; 3]>` (field, since 0.4.0): Direction the light travels. (spotlight if Some)
  - returns Option<[f64; 3]>
- `pub inner_cone_angle: f64` (field, since 0.4.0): Inner cone half-angle of the spotlight. (radians, fully bright up to here)
  - returns f64
- `pub outer_cone_angle: f64` (field, since 0.4.0): Outer cone half-angle of the spotlight. (radians, reaches 0 here)
  - returns f64
- `pub casts_shadow: bool` (field, since 0.4.0): Whether it casts a shadow. (ShadowAtlas gives it tiles)
  - returns bool
- `pub shadow_near: f64` (field, since 0.4.0): Near distance of the shadow. (The far distance is range, 30 if 0)
  - returns f64

## ToonLightColorUsage (struct) (Clone, Copy, Debug, PartialEq, Eq, Default)

Whether to multiply the light color per color. (Is_LightColor_* of the Unity Toon Shader, all true by default)
- Base, shade and highlight receive the light's luminance (gray) when off, and the rest receive no light when off.

Example: Keep the shade and outline from taking on the light color

```rust
use vanilla::{ToonLightColorUsage, ToonLightSet};

let mut light_set = ToonLightSet::new();
light_set.set_light_color_usage(ToonLightColorUsage { shade: false, outline: false, ..ToonLightColorUsage::default() });
assert!(light_set.get_light_color_usage().base);
assert!(!light_set.get_light_color_usage().shade);
```

- `pub base: bool` (field, since 0.4.0): Base.
  - returns bool
- `pub shade: bool` (field, since 0.4.0): Shade.
  - returns bool
- `pub highlight: bool` (field, since 0.4.0): Highlight.
  - returns bool
- `pub rim: bool` (field, since 0.4.0): Rim.
  - returns bool
- `pub shade_rim: bool` (field, since 0.4.0): Shade-side rim.
  - returns bool
- `pub matcap: bool` (field, since 0.4.0): Matcap.
  - returns bool
- `pub angel_ring: bool` (field, since 0.4.0): Angel ring.
  - returns bool
- `pub outline: bool` (field, since 0.4.0): Shell outline.
  - returns bool

## ToonShadeRimLight (struct) (Clone, Copy, Debug, PartialEq)

Shade-side rim light. (Linear color and power, none if the power is 0 or less)

Example: A blue rim on the shade side

```rust
use vanilla::ToonLightSet;

let mut light_set = ToonLightSet::new();
light_set.set_rim_light([0.8, 0.75, 0.6], 3.0, 0.1, 1.0);
light_set.set_shade_rim_light([0.2, 0.3, 0.6], 2.5);
assert_eq!(light_set.get_shade_rim_light().power, 2.5);
```

- `pub color: [f64; 3]` (field, since 0.4.0): Linear color to add. ([r, g, b])
  - returns [f64; 3]
- `pub power: f64` (field, since 0.4.0): Power. (none if 0 or less)
  - returns f64

## ToonLightModel (struct) (Clone, Copy, Debug, Default, PartialEq)

Light model. (is_energy_normalized whether to divide base color x light by π)

Example: Light model that gives light intensity as illuminance

```rust
use vanilla::{ToonLightModel, ToonLightSet};

let mut light_set = ToonLightSet::new();
light_set.set_light_model(ToonLightModel { is_energy_normalized: true });
assert!(light_set.get_light_model().is_energy_normalized);
```

- `pub is_energy_normalized: bool` (field, since 0.4.0): Whether to divide base color x light by π. (the highlight is multiplied by (exponent + 8) / 8π, default false)
  - returns bool

## ToonShade (struct) (Clone, Copy, Debug, PartialEq, Default)

Three shades. (base, 1st shade and 2nd shade of Unity Toon Shader with Step and Feather for their boundaries, no 2nd shade if second_step is 0 or less)

Example: A warm 1st shade and a deep 2nd shade

```rust
use vanilla::{ToonLightSet, ToonShade};

let mut light_set = ToonLightSet::new();
light_set.set_shade(ToonShade { step: 0.5, feather: 0.03, color: [0.8, 0.62, 0.6], second_step: 0.2, second_feather: 0.03, second_color: [0.5, 0.36, 0.42], is_half_lambert: true });
assert_eq!(light_set.get_shade_ramp().positions, vec![0.0, 0.2, 0.5]);
```

- `pub step: f64` (field, since 0.4.0): Boundary between base and 1st shade. (position on the light-receiving amount x, with half Lambert 0.5 is a face perpendicular to the sun)
  - returns f64
- `pub feather: f64` (field, since 0.4.0): Softness of the boundary between base and 1st shade.
  - returns f64
- `pub color: [f64; 3]` (field, since 0.4.0): 1st shade color. (linear factor multiplied by the base color and light)
  - returns [f64; 3]
- `pub second_step: f64` (field, since 0.4.0): Boundary between 1st and 2nd shade. (no 2nd shade if 0 or less)
  - returns f64
- `pub second_feather: f64` (field, since 0.4.0): Softness of the boundary between 1st and 2nd shade.
  - returns f64
- `pub second_color: [f64; 3]` (field, since 0.4.0): 2nd shade color.
  - returns [f64; 3]
- `pub is_half_lambert: bool` (field, since 0.4.0): Whether to compute x as half Lambert.
  - returns bool

## ToonShadeRamp (struct) (Clone, Debug, Default, PartialEq)

Shade ramp. (position, linear color and softness per step, smooth Lambert if the steps are empty, the first step's position and softness are not used)

Example: Give a three-cell ramp directly

```rust
use vanilla::ToonLightSet;

let mut light_set = ToonLightSet::new();
light_set.set_shade_ramp(&[0.0, 0.4, 0.62], &[[0.3, 0.3, 0.45], [0.62, 0.6, 0.75], [1.0, 1.0, 1.0]], &[0.0, 0.05, 0.02], true);
let shade_ramp = light_set.get_shade_ramp();
assert_eq!(shade_ramp.positions, vec![0.0, 0.4, 0.62]);
assert!(shade_ramp.is_half_lambert);
```

- `pub positions: Vec<f64>` (field, since 0.4.0): Position of each cell. (received light amount x, ascending)
  - returns Vec<f64>
- `pub colors: Vec<[f64; 3]>` (field, since 0.4.0): Linear [r, g, b] multiplier per cell.
  - returns Vec<[f64; 3]>
- `pub feathers: Vec<f64>` (field, since 0.4.0): Softness per cell. (Width of the transition into that cell)
  - returns Vec<f64>
- `pub is_half_lambert: bool` (field, since 0.4.0): Whether to count x as dot x 0.5 + 0.5. (Otherwise max(dot, 0))
  - returns bool

## ToonRimLight (struct) (Clone, Copy, Debug, PartialEq)

Rim light. (linear color, power, softness 0 ~ 1, fraction kept only on the sunlit side 0 ~ 1)

Example: A hard rim that stands only on the sun side

```rust
use vanilla::ToonLightSet;

let mut light_set = ToonLightSet::new();
light_set.set_rim_light([0.6, 0.65, 0.8], 2.5, 0.0, 1.0);
let rim_light = light_set.get_rim_light();
assert_eq!((rim_light.feather, rim_light.light_mask), (0.0, 1.0));
```

- `pub color: [f64; 3]` (field, since 0.4.0): Linear color to add. ([r, g, b])
  - returns [f64; 3]
- `pub power: f64` (field, since 0.4.0): Power. (The larger, the thinner the rim, 0 means none)
  - returns f64
- `pub feather: f64` (field, since 0.4.0): 0 is a hard rim, 1 is a soft rim.
  - returns f64
- `pub light_mask: f64` (field, since 0.4.0): 1 puts the rim only on the side receiving the sun. (0 ~ 1)
  - returns f64

## ToonSpecular (struct) (Clone, Copy, Debug, PartialEq)

Specular highlight. (strength, Blinn-Phong exponent, softness 0 ~ 1, linear color)

Example: Soft highlight

```rust
use vanilla::ToonLightSet;

let mut light_set = ToonLightSet::new();
light_set.set_specular(0.4, 32.0, 1.0, [1.0, 0.95, 0.9]);
assert_eq!(light_set.get_specular().exponent, 32.0);
```

- `pub strength: f64` (field, since 0.4.0): Strength. (0 means none)
  - returns f64
- `pub exponent: f64` (field, since 0.4.0): Blinn-Phong exponent. (larger is a smaller spot, not lowered below 1)
  - returns f64
- `pub feather: f64` (field, since 0.4.0): Softness. (0 is a hard toon spot, 1 is soft Blinn-Phong)
  - returns f64
- `pub color: [f64; 3]` (field, since 0.4.0): Linear [r, g, b].
  - returns [f64; 3]

## ToonLightSet (struct) (Debug, Default, Clone)

Toon light set. (see the header comment)

Example: Give a different shade color per material with light sets

```rust
use vanilla::{create_sphere_geometry, Matrix4, MeshBuilder, ToonDrawOptions, ToonPartOptions, ToonRenderer, ToonShade, Vector3};

fn draw_skin(gl: &vanilla::GlContext, renderer: &mut ToonRenderer) -> Option<()> {
	let mut skin_light_set = renderer.create_light_set();
	skin_light_set.set_shade(ToonShade { step: 0.55, feather: 0.04, color: [0.86, 0.6, 0.6], ..ToonShade::default() });
	let mut builder = MeshBuilder::new();
	builder.add_part(&create_sphere_geometry(0.5, 32, 20, std::f64::consts::PI), &Matrix4::create_identity(), "#f0d0c0", ToonPartOptions { has_outline: false, ..ToonPartOptions::default() });
	let mesh = renderer.create_mesh(gl, &builder.read_arrays())?;
	let view_matrix = Matrix4::create_look_at(Vector3::create(0.0, 0.0, 3.0), Vector3::create(0.0, 0.0, 0.0), Vector3::create(0.0, 1.0, 0.0));
	renderer.begin_frame_with_matrices(gl, &view_matrix, &Matrix4::create_perspective(0.8, 1.0, 0.1, 10.0));
	renderer.draw_mesh(gl, &mesh, &Matrix4::create_identity(), ToonDrawOptions { light_set: Some(&skin_light_set), ..ToonDrawOptions::default() });
	renderer.end_frame(gl);
	Some(())
}
```

- `pub fn new() -> ToonLightSet` (constructor, since 0.4.0): Constructor. (by default two-step shading split at half Lambert 0.5, with a cool purple shade color)
  - returns ToonLightSet: New light set. (the ID differs per set)
- `pub fn get_id(&self) -> u32` (method, since 0.4.0): Returns the ID. (different per set, a clone gets a new ID)
  - returns u32: Set number.
- `pub fn get_version(&self) -> u64` (method, since 0.4.0): Returns the version number. (raised on every modification)
  - returns u64: Version number.
- `pub fn set_light(&mut self, sun_direction: [f64; 3], sun_color: [f64; 3], sky_color: [f64; 3], ground_color: [f64; 3])` (method, since 0.4.0): Sets the sun and ambient light. (direction the sun shines, sun color, sky color, ground color, all linear)
  - `sun_direction` [f64; 3]: The way the light travels. [x, y, z]
  - `sun_color` [f64; 3]: Linear color and intensity of the sun. [r, g, b]
  - `sky_color` [f64; 3]: Ambient light of faces looking up. [r, g, b]
  - `ground_color` [f64; 3]: Ambient light of faces looking down. [r, g, b]
- `pub fn set_sun_direction(&mut self, sun_direction: [f64; 3])` (method, since 0.4.0): Sets the sun direction. (the way the light travels, flip the sign if you have the direction from the surface toward the sun)
  - `sun_direction` [f64; 3]: [x, y, z]
- `pub fn get_sun_direction(&self) -> [f64; 3]` (method, since 0.4.0): Returns the sun direction. (pass it as is to ShadowMap::update_light_matrix)
  - returns [f64; 3]: [x, y, z]
- `pub fn get_sun_color(&self) -> [f64; 3]` (method, since 0.4.0): Returns the sun color.
  - returns [f64; 3]: Linear [r, g, b].
- `pub fn get_sky_color(&self) -> [f64; 3]` (method, since 0.4.0): Returns the sky color.
  - returns [f64; 3]: Linear [r, g, b].
- `pub fn get_ground_color(&self) -> [f64; 3]` (method, since 0.4.0): Returns the ground color.
  - returns [f64; 3]: Linear [r, g, b].
- `pub fn set_fill_light(&mut self, fill_direction: [f64; 3], fill_color: [f64; 3])` (method, since 0.4.0): Sets the fill light. (direction the light travels and linear color, none if the color is 0, not shadowed)
  - `fill_direction` [f64; 3]: Direction the light travels. [x, y, z] (normalized to length 1, downward if the length is 0)
  - `fill_color` [f64; 3]: Linear [r, g, b].
- `pub fn get_fill_light(&self) -> ([f64; 3], [f64; 3])` (method, since 0.4.0): Returns the fill light. ((direction, color))
  - returns ([f64; 3], [f64; 3]): (direction, color). (the direction has length 1)
- `pub fn set_rim_light(&mut self, rim_color: [f64; 3], rim_power: f64, rim_feather: f64, rim_light_mask: f64)` (method, since 0.4.0): Sets the rim light. (linear color, power, softness 0 hard rim ~ 1 soft rim, fraction kept only on the sunlit side 0 ~ 1, none if the power is 0 or less)
  - `rim_color` [f64; 3]: Linear color to add. [r, g, b]
  - `rim_power` f64: Power. (The larger, the thinner the rim, 0 means none)
  - `rim_feather` f64: 0 is a hard rim, 1 is a soft rim. (default 1 in the original)
  - `rim_light_mask` f64: 1 puts the rim only on the side receiving the sun. (default 0 in the original)
- `pub fn get_rim_light(&self) -> ToonRimLight` (method, since 0.4.0): Returns the rim light.
  - returns ToonRimLight: Rim light. (color, power, softness, share placed only on the side receiving the sun)
- `pub fn set_shade_rim_light(&mut self, shade_rim_color: [f64; 3], shade_rim_power: f64)` (method, since 0.4.0): Sets the shade-side rim light. (Rim on the side facing away from the sun, linear color, power, softness is shared with set_rim_light, none if the power is 0 or less)
  - `shade_rim_color` [f64; 3]: Linear color to add. [r, g, b]
  - `shade_rim_power` f64: Power. (0 means none)
- `pub fn get_shade_rim_light(&self) -> ToonShadeRimLight` (method, since 0.4.0): Return the shade-side rim light.
  - returns ToonShadeRimLight: Shade-side rim light. (color, power)
- `pub fn set_light_color_usage(&mut self, light_color_usage: ToonLightColorUsage)` (method, since 0.4.0): Sets the light color usage. (Whether to multiply the light color per color)
  - `light_color_usage` ToonLightColorUsage: Per-color flags for whether the light color is multiplied. (base, shade, highlight, rim, shade-side rim, matcap, angel ring, shell outline)
- `pub fn get_light_color_usage(&self) -> ToonLightColorUsage` (method, since 0.4.0): Return the light color usage.
  - returns ToonLightColorUsage: Per-color flags for whether the light color is multiplied.
- `pub fn set_light_intensity_limited(&mut self, is_limited: bool)` (method, since 0.4.0): Sets light intensity limiting. (if true, each light's received share is limited to 1 so it does not blow out to white, default true, the Unity Toon Shader Limit Light Intensity)
  - The sun and fill light clamp each color channel to 1. (saturate on the main light)
  - Point lights and spot lights divide by the intensity when the intensity of the color including attenuation (0.299 R + 0.587 G + 0.114 B) exceeds 1. (min(color, color / intensity) for additional lights)
  - If the light model is is_energy_normalized, the share after dividing by pi is limited to 1.
  - When porting an old game shader (one that did not limit light intensity), or when using point lights above intensity 1 or HDR bloom, use set_light_intensity_limited(false).
  - `is_limited` bool: If true, limits.
- `pub fn is_light_intensity_limited(&self) -> bool` (method, since 0.4.0): Returns whether light intensity is limited.
  - returns bool: true if limited.
- `pub fn set_specular(&mut self, specular_strength: f64, specular_exponent: f64, specular_feather: f64, specular_color: [f64; 3])` (method, since 0.4.0): Sets the specular highlight. (none if the strength is 0, a larger exponent gives a smaller spot, softness 0 hard toon spot ~ 1 soft Blinn-Phong, linear color)
  - `specular_strength` f64: Strength. (0 means none)
  - `specular_exponent` f64: Blinn-Phong exponent. (default 48 in the original, not lowered below 1)
  - `specular_feather` f64: 0 ~ 1. (default 0 in the original, a hard spot)
  - `specular_color` [f64; 3]: Linear [r, g, b]. (default white in the original)
- `pub fn get_specular(&self) -> ToonSpecular` (method, since 0.4.0): Returns the specular highlight.
  - returns ToonSpecular: Highlight. (strength, exponent, softness, color)
- `pub fn set_point_lights(&mut self, point_light_list: &[ToonPointLight])` (method, since 0.4.0): Sets point lights and spotlights. (those beyond TOON_MAXIMUM_POINT_LIGHTS are discarded, range, exponents and angles are not lowered below 0, and directions are normalized to length 1)
  - `point_light_list` &[ToonPointLight]: List of point lights and spotlights. (a spotlight if direction is Some)
- `pub fn get_point_lights(&self) -> &[ToonPointLight]` (method, since 0.4.0): Returns the point lights. (as set, before clipping to the limit)
  - returns &[ToonPointLight]: List in the form filled by set_point_lights.
- `pub fn read_shadow_light_sources(&self) -> Vec<ShadowAtlasLightSource>` (method, since 0.4.0): Reads the light descriptions to give to the shadow atlas. (In the same order as the point light list, passed to ShadowAtlas::update_lights)
  - returns Vec<ShadowAtlasLightSource>: One shadow atlas light source per point light. (position, direction, outer cone half angle, range, shadow near distance, whether it casts shadows)
- `pub fn set_point_light_limit(&mut self, point_light_limit: usize)` (method, since 0.4.0): Sets the limit on the number of point lights put into the shader. (0 ~ TOON_MAXIMUM_POINT_LIGHTS, lowered on lightweight paths)
  - `point_light_limit` usize: Limit.
- `pub fn get_point_light_count(&self) -> usize` (method, since 0.4.0): Number of point lights put into the shader. (the smaller of the set count and the limit)
  - returns usize: Number of point lights put into the shader.
- `pub fn set_shade(&mut self, shade: ToonShade)` (method, since 0.4.0): Sets the three shades. (ToonShade, the base is white [1, 1, 1])
  - `shade` ToonShade: Three shades. (boundaries, softness and colors, 2nd shade, half Lambert)
- `pub fn set_shade_ramp(&mut self, positions: &[f64], colors: &[[f64; 3]], feathers: &[f64], is_half_lambert: bool)` (method, since 0.4.0): Sets the shade ramp. (position, linear color and softness per step, 2 ~ TOON_MAXIMUM_BAND_STEPS steps, smooth Lambert if fewer than two, positions in ascending order)
  - `positions` &[f64]: Position per cell. (Received light amount x)
  - `colors` &[[f64; 3]]: Linear [r, g, b] multiplier per cell.
  - `feathers` &[f64]: Softness per cell. (Width of the transition into that cell)
  - `is_half_lambert` bool: Whether to count x as dot x 0.5 + 0.5. (Otherwise max(dot, 0))
- `pub fn clear_shade_ramp(&mut self)` (method, since 0.4.0): Turns off the shade ramp. (smooth Lambert)
- `pub fn get_shade_ramp(&self) -> &ToonShadeRamp` (method, since 0.4.0): Returns the shade ramp. (smooth Lambert if the steps are empty)
  - returns &ToonShadeRamp: Shade ramp. (position, color and softness per cell, and whether it is half Lambert)
- `pub fn set_band_count(&mut self, band_count: u32)` (method, since 0.4.0): Sets uniform bands. (gray bands from rounding max(dot(N, L), 0) to the band count, 1 ~ TOON_MAXIMUM_BAND_STEPS - 1, 0 for smooth Lambert)
  - `band_count` u32: Number of cells. (0 means smooth)
- `pub fn set_band_ramp(&mut self, thresholds: &[f64], values: &[f64], is_half_lambert: bool)` (method, since 0.4.0): Sets the gray band ramp. (one fewer threshold than values, values up to TOON_MAXIMUM_BAND_STEPS, below the first threshold is the first value, above the last threshold is the last value)
  - `thresholds` &[f64]: Ascending thresholds.
  - `values` &[f64]: Received amount per cell.
  - `is_half_lambert` bool: Whether to compare dot x 0.5 + 0.5 to the thresholds.
- `pub fn set_ramp_texture(&mut self, ramp_texture: Option<GlTexture>, is_half_lambert: bool)` (method, since 0.4.0): Sets the ramp texture. (reads the texture horizontally instead of bands, None for bands, one built with ToonRenderer::create_texture, left is shade and right is light)
  - `ramp_texture` Option<GlTexture>: Ramp texture or None.
  - `is_half_lambert` bool: Whether to compute x as half Lambert. (default true in the original)
- `pub fn get_ramp_texture(&self) -> Option<GlTexture>` (method, since 0.4.0): Returns the ramp texture. (None if none)
  - returns Option<GlTexture>: Ramp texture. (None if none)
- `pub fn set_light_model(&mut self, light_model: ToonLightModel)` (method, since 0.4.0): Sets the light model.
  - `light_model` ToonLightModel: Light model. (is_energy_normalized)
- `pub fn get_light_model(&self) -> ToonLightModel` (method, since 0.4.0): Returns the light model.
  - returns ToonLightModel: Light model. (is_energy_normalized)

## Functions and constants

- `pub const TOON_MAXIMUM_POINT_LIGHTS: usize = 8` (field, since 0.4.0): Maximum number of point lights and spotlights per draw. (uniform array size in the shader)
  - returns usize
- `pub const TOON_MAXIMUM_BAND_STEPS: usize = 8` (field, since 0.4.0): Maximum number of shade ramp steps. (uniform array size in the shader)
  - returns usize
