Kagari
Type to search documentation.

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.

kis
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

ItemKindSummary
MULTIPLY … ADDconstantsthe sixteen blend mode shaders
multiply() … add()functionsthe blend modes as Mix values
FrostedGlass, FROSTED_GLASS, frosted_glassstruct, constant, functionfrosted glass

Constants: blend mode shaders

kis
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

kis
pub const fn multiply() -> Mix
pub const fn screen() -> Mix
pub const fn overlay() -> Mix
pub const fn darken() -> Mix
pub const fn lighten() -> Mix
pub const fn color_dodge() -> Mix
pub const fn color_burn() -> Mix
pub const fn hard_light() -> Mix
pub const fn soft_light() -> Mix
pub const fn difference() -> Mix
pub const fn exclusion() -> Mix
pub const fn hue() -> Mix
pub const fn saturation() -> Mix
pub const fn color() -> Mix
pub const fn luminosity() -> Mix
pub const fn add() -> Mix
FunctionW3C modeEffect
multiply()multiplymultiplies the colours: always darker
screen()screenmultiplies the inverted colours: always lighter
overlay()overlaymultiply or screen, by the colour below
darken()darkenthe darker of the two colours, per channel
lighten()lightenthe lighter of the two colours, per channel
color_dodge()color-dodgebrightens the colour below to reflect the entity
color_burn()color-burndarkens the colour below to reflect the entity
hard_light()hard-lightmultiply or screen, by the entity’s colour
soft_light()soft-lighta softer hard_light
difference()differencethe absolute difference of the colours
exclusion()exclusionlike difference, with lower contrast
hue()huethe entity’s hue with the saturation and luminosity below
saturation()saturationthe entity’s saturation with the hue and luminosity below
color()colorthe entity’s hue and saturation with the luminosity below
luminosity()luminositythe 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

kis
#[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

kis
pub const FROSTED_GLASS: MixShader<FrostedGlass> = asset("shaders/mix/frosted_glass.wgsl");

Frosted glass (TyranoScript [position_filter]).

Function: frosted_glass(radius, tint)

kis
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 radius pixels and lays tint over 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