Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

kampos

wix-incubator312MIT0.16.0TypeScript support: included

Tiny and fast effects compositor on WebGL

effects, media, video, filters, webgl, compositor

readme

Kampos logo

kampos

Tiny and fast effects compositor on WebGL

kampos lets you add filter effects and beautiful transitions to video and images (or any other media). Just like SVG filter effects, only using WebGL, which means it works everywhere!

Intro

Read the blog post introducing kampos on Wix Engineering Blog.

Posts

CSS-Tricks: Nailing That Cool Dissolve Transition

Demo

Check out the live demo.

Documentation

For API reference and examples, read the docs.

Features

  • Filter effects for images and videos that you can mix and compose.
  • As tiny as ~4KB (minified and gzipped).
  • Core engine for creating and running effects.
  • Plugins for effects and transitions - available for import.
  • Custom plugins? Extremely easy by using the effects/transitions descriptors DSL.

Usage

Here's a simple example for using kampos:

import { Kampos, effects } from 'kampos';

const target = document.querySelector('canvas');
const media = document.querySelector('video');

const hueSaturation = effects.hueSaturation();
hueSaturation.hue = 90;

const kampos = new Kampos({ target, effects: [hueSaturation] });

kampos.setSource(media);
kampos.play();

Getting started

Grab the source from here, or install via package manager.

npm example:

npm install kampos

Import the default build:

import { Kampos, Ticker, effects, transitions } from 'kampos';

Or take just what you need:

import Kampos from './node_modules/kampos/src/kampos';
import duotone from './node_modules/kampos/src/effects/duotone';
import displacement from './node_modules/kampos/src/effects/displacement';

Building locally

npm install
npm run build

Running tests

npm run test

Contributing

Contributions are welcome! (:

License

kampos is distributed under the MIT license.

changelog

0.16.0 (2025-03-13)

New:

  • Added support for using FBOs for pingpong rendering.
  • Added flowmapGrid effect to the new fbo folder.
  • Added flowmapGridDisplacement effect that uses flowmapGrid.
  • Added grid-mouse-displacement demo.

0.15.0 (2025-02-26)

New:

  • Added shape transition and the shape-transition demo.

0.14.10 (2025-01-08)

New:

  • Added input property to displacement effect to allow switching from texture input to other methods. Currently built-in methods are displacement.TEXTURE and displacement.TURBULENCE that works when combined with the turebulence effect.

0.14.9 (2025-01-02)

Fixed:

  • Automatic setting of source dimensions based on source type.

0.14.8 (2024-12-24)

Fixed:

  • Fixed direction of u_mouse offsets in turbulence effect.

0.14.7 (2024-12-19)

New:

  • Added offsetInput property to slitScan effect for allowing exposing an offset variable.

0.14.6 (2024-12-18)

Fixed:

  • Fixed mouse utility to invert y coordinate internally.

0.14.5 (2024-12-18)

Fixed:

  • Fixed mirroring of source coordinates in kaleidoscope and slitScan effects.

0.14.4 (2024-12-17)

New:

  • Added direction property to slitScan effect for choosing x or y.

0.14.3 (2024-12-16)

New:

  • Added ability to use u_mouse as input to turbulence effect.

0.14.2 (2024-12-15)

Fixed:

  • Replaced main of turbulence effect with source to allow reusing the turbulenceValue variable for source parts as well.

0.14.0 (2024-12-14)

Breaking:

  • Changed TEXTURE_MIN_FILTER/TEXTURE_MAG_FILTER from NEAREST to LINEAR.

0.13.1 (2024-12-09)

New:

  • Added rotation property to kaleidoscope effect.

Breaking:

  • Kaleidoscope effect now does mirrored-repeat instead of simple repeat.
  • Changed Kaleidoscope.offset from a number to an object of { x: number, y: number }.

0.12.0 (2024-12-04)

New:

  • Added shouldUpdate flag to kamposSource to force/depress source resampling.
  • Calling kampos#setSource() without dimensions will attempt to read dimensions from HTMLImageElement or HTMLVideoElement.

0.11.7 (2024-12-02)

Fixed:

  • Fixed slitScan effect, added missing setter for the time uniform.

0.11.6 (2024-12-02)

New:

  • Added slitScan effect.

0.11.5 (2024-12-01)

New:

  • Added simplex-2d noise.
  • Added circle utility for creating a circle mask.

0.11.4 (2024-11-25)

Fixed:

  • Blue channel in displacement effect should not be offset by -0.5.

0.11.3 (2024-11-17)

New:

  • Added deformation effect.
  • Added channelSplit effect.
  • Extended displacement effect to support blue channel for intensity.
  • Added multi-pointer demo.
  • Added white noise.
  • Added mouse utility for adding the u_mouse uniform to the shader.
  • Added resolution utility for adding the u_resolution uniform to the shader.

0.10.2 (2024-08-25)

Fixed:

  • Types issue in previous patch.

0.10.0 (2024-08-20)

New:

  • Added a dist/index.cjs distribution.
  • Replaced index.js with src/index.js.

Fixed:

  • Fixed extends property of type Attribute.

Breaking:

  • main field in package.json now points to dist/index.cjs.

0.9.2 (2024-08-20)

New:

  • Added a types.d.ts module.

0.9.1 (2024-08-13)

New:

  • Added kaleidoscope effect.

0.9.0 (2024-08-13)

New:

  • Added afterDraw callback to kampos config. Used to pass a function that will be called after each draw call.
  • Added optional function argument afterDraw to kampos#play() method to be dynamically set to kampos.config.afterDraw.
  • Added optional boolean argument skipTextureCreation to kampos#setSource() method to skip texture creation for the source media. useful for cases where using an OffscreenCanvas as a source for multiple programs and need to switch between them.

0.8.0 (2023-04-01)

Breaking:

  • index.js now uses ES modules. For a UMD distribution please use index.umd.js

Fixed:

  • Fixed URLs of docs & demos.
  • Rewrote Floss tests to run with Ava.

0.7.1 (2023-02-13)

Fixed:

  • Ignore test files from NPM that contain invalid characters on Windows systems.

0.7.0 (2021-10-16)

New:

  • transitions.dissolve now has support for transitioning into a color by disabling the target media with extureEnabled: false. color argument is used to control the color and defaults to transparent black: [0, 0, 0, 0].

0.6.1 (2021-10-14)

Fixed:

  • Fixed dissolve transition to take alpha channel progress from the luminance of the map.

0.6.0 (2021-06-29)

New:

  • Added support for simple plane geometry using new plane: {segments: number | {x: number, y: number}}config.
  • Added extends: string property to attribute config which takes a name of an attribute to extend its properties for simplifying coords attribute creation.

Fixed:

  • Fixed shader error reporting to correctly report vertex shader errors.

0.5.2 (2021-05-07)

Fixed:

  • Fixed error when called desotry() more than once.

0.5.1 (2021-03-26)

New:

  • Added usage of the OES_vertex_array_object extension for improved drawing performance.

0.5.0 (2021-03-04)

New:

  • beforeDraw callback now takes an argument time that will get the timestamp param of rAF injected into it.
  • All effects and transitions now take params argument, an Object that contains initial values to set.
  • turbulence effect now takes a new argument params.output which results in a code injected to the fragment shader for controlling the output of the effect. You can use the static properties of the effect:
    • turbulence.COLOR: render the result value as a grayscale vector into color.
    • turbulence.ALPHA: render the result value into alpha.

Breaking:

  • blend effect now takes noise as a property of params object.
  • displacement effect now takes wrap as a property of params object, which are now static properties of the effect:
    • displacement.CLAMP
    • displacement.DISCARD
    • displacement.WRAP
  • tubulence effect now takes the noise string argument as a property of params, as in: params.noise.

0.4.0 (2021-02-08)

New:

  • Dissolve transition.

0.3.7 (2021-02-07)

New:

  • Added cellular noise.
  • brightnessContrast and hueSaturation effects now have initial default values in factory.

0.3.6 (2021-01-13)

New:

  • Initial work on blend effect.

Fixed:

  • Fixed Travis build.

0.3.5 (2019-11-09)

Fixed:

  • Fixed noise rendering on mobile with changing percision to highp.

0.3.4 (2019-10-22)

New:

  • Added wrapping methods for displacement effect: CLAMP, DISCARD, WRAP.

Fixed:

  • Fixed usage of sourceCoords in displacement transition.

0.3.3 (2019-10-20)

New:

  • Added simplex 3D noise.

0.3.2 (2019-09-28)

Fixed:

  • Fixed handling noSource and multiple textures in draw loop.

0.3.1 (2019-09-25)

Fixed:

  • Updated docs & README.

0.3.0 (2019-09-24)

New:

  • Added suport for noSource argument for rendering without a media source.
  • Implemented turbulence effect.
  • alphaMask effect now supports luminance mode via isLuminance getter/setter.
  • Added beforeDraw callback to kampos config.
  • Added perlin 3D noise.

Fixed:

  • CI build fixes.

0.2.3 (2019-08-22)

Fixed:

  • Docs fixes.
  • Integrate with Travis CI.

0.2.2 (2019-08-07)

Fixed:

  • Added missing progress getter/setter for fade transition.

0.2.1 (2019-08-07)

Fixed:

  • kampos is not dependent on Ticker.

New:

  • Published transpiled source.

0.2.0 (2019-07-25)

New:

  • Initial public release.