Modules
std::shaders::mix
Stability: Tentative — mixes: the W3C blend modes, additive compositing and frosted glass.
Mix shaders for Entity::mix. Every function returns a
Mix: how the entity is composited over what is drawn below it. None
is normal source-over compositing.
The blend modes follow W3C Compositing and Blending Level 1 (the CSS mix-blend-mode values): the
mode mixes the entity’s colour with the colour below where both are present, and the result is
composited source-over. They work in linear light, on the colours the renderer composites.
use std::shaders::mix::{frosted_glass, multiply};use std::screen::rgba;
screen.entity(SHADOW).mix().change(Some(multiply())).apply_animation(instant());screen.entity(PANEL).mix().change(Some(frosted_glass(8.0, rgba(255, 255, 255, 40)))).apply_animation(instant());Overview
| Item | Kind | Summary |
|---|---|---|
MULTIPLY … ADD | constants | the sixteen blend mode shaders |
multiply() … add() | functions | the blend modes as Mix values |
FrostedGlass, FROSTED_GLASS, frosted_glass | struct, constant, function | frosted glass |
Constants: blend mode shaders
pub const MULTIPLY: MixShader<()> = asset("shaders/mix/multiply.wgsl");pub const SCREEN: MixShader<()> = asset("shaders/mix/screen.wgsl");pub const OVERLAY: MixShader<()> = asset("shaders/mix/overlay.wgsl");pub const DARKEN: MixShader<()> = asset("shaders/mix/darken.wgsl");pub const LIGHTEN: MixShader<()> = asset("shaders/mix/lighten.wgsl");pub const COLOR_DODGE: MixShader<()> = asset("shaders/mix/color_dodge.wgsl");pub const COLOR_BURN: MixShader<()> = asset("shaders/mix/color_burn.wgsl");pub const HARD_LIGHT: MixShader<()> = asset("shaders/mix/hard_light.wgsl");pub const SOFT_LIGHT: MixShader<()> = asset("shaders/mix/soft_light.wgsl");pub const DIFFERENCE: MixShader<()> = asset("shaders/mix/difference.wgsl");pub const EXCLUSION: MixShader<()> = asset("shaders/mix/exclusion.wgsl");pub const HUE: MixShader<()> = asset("shaders/mix/hue.wgsl");pub const SATURATION: MixShader<()> = asset("shaders/mix/saturation.wgsl");pub const COLOR: MixShader<()> = asset("shaders/mix/color.wgsl");pub const LUMINOSITY: MixShader<()> = asset("shaders/mix/luminosity.wgsl");pub const ADD: MixShader<()> = asset("shaders/mix/add.wgsl");The shaders of the W3C blend modes multiply to luminosity, and of additive compositing. They
take no arguments.
Functions: blend modes
pub const fn multiply() -> Mixpub const fn screen() -> Mixpub const fn overlay() -> Mixpub const fn darken() -> Mixpub const fn lighten() -> Mixpub const fn color_dodge() -> Mixpub const fn color_burn() -> Mixpub const fn hard_light() -> Mixpub const fn soft_light() -> Mixpub const fn difference() -> Mixpub const fn exclusion() -> Mixpub const fn hue() -> Mixpub const fn saturation() -> Mixpub const fn color() -> Mixpub const fn luminosity() -> Mixpub const fn add() -> Mix| Function | W3C mode | Effect |
|---|---|---|
multiply() | multiply | multiplies the colours: always darker |
screen() | screen | multiplies the inverted colours: always lighter |
overlay() | overlay | multiply or screen, by the colour below |
darken() | darken | the darker of the two colours, per channel |
lighten() | lighten | the lighter of the two colours, per channel |
color_dodge() | color-dodge | brightens the colour below to reflect the entity |
color_burn() | color-burn | darkens the colour below to reflect the entity |
hard_light() | hard-light | multiply or screen, by the entity’s colour |
soft_light() | soft-light | a softer hard_light |
difference() | difference | the absolute difference of the colours |
exclusion() | exclusion | like difference, with lower contrast |
hue() | hue | the entity’s hue with the saturation and luminosity below |
saturation() | saturation | the entity’s saturation with the hue and luminosity below |
color() | color | the entity’s hue and saturation with the luminosity below |
luminosity() | luminosity | the entity’s luminosity with the hue and saturation below |
add() | — | adds the entity’s light to what is below; the alphas composite source-over |
Kind: const fn · Builtin: no.
Struct: FrostedGlass
#[shader_arg]pub struct FrostedGlass { pub radius: Decimal, pub tint: Color,}The arguments of FROSTED_GLASS: radius is the blur’s standard deviation in pixels, and tint
the glass colour laid over the blurred backdrop.
Constant: FROSTED_GLASS
pub const FROSTED_GLASS: MixShader<FrostedGlass> = asset("shaders/mix/frosted_glass.wgsl");Frosted glass (TyranoScript [position_filter]).
Function: frosted_glass(radius, tint)
pub const fn frosted_glass(radius: Decimal, tint: Color) -> Mix- Returns: a mix that, where the entity has content, blurs what is below it by
radiuspixels and laystintover it, then draws the entity on top. Where the entity is transparent, the backdrop shows unchanged. - Kind:
const fn· Builtin: no.
A text panel with a translucent fill and frosted_glass blurs the scene behind it.
Last updated Oct 29, 2026