Modulate

Modulation #

While blend functions combine the colors from two visual sources, modulate functions use the colors from one source to affect the geometry of the second source. This creates a sort of warping or distorting effect. An analogy in the real world would be looking through a texture glass window. modulate() does not change color or luminosity but distorts one visual source using another visual source.

Using the same sources from above, we can use an oscillator to modulate or warp the camera image:

You can add a second parameter to the modulate() function to control the amount of warping: modulate(o1, 0.9). In this case, the red and green channels of the oscillator are being converted to x and y displacement of the camera image.

All geometry transformations have corresponding modulate functions that allow you to use one source to warp another source. For example, .modulateRotate() is similar to .rotate(), but it allows you to apply different amounts of rotation to different parts of the visual source. See the function reference for more examples.

More blending and modulating #

In addition to using multiple outputs to combine visuals, you can also combine multiple sources within the same function chain, without rendering them to separate outputs.

This allows you to use many sources, blend modes, and modulation, all from within the same chain of functions.

Trick: use ctrl + shift + f from the web editor to auto-format your code

Modulating with the camera #

Available modulate functions #

modulateRepeat #

modulateRepeat( texture, repeatX = 3, repeatY = 3, offsetX = 0.5, offsetY = 0.5 )

The texture parameter can be any kind of source, for example a color, src, or shape.

modulateRepeatX #

modulateRepeatX( texture, reps = 3, offset = 0.5 )

The texture parameter can be any kind of source, for example a color, src, or shape.

modulateRepeatY #

modulateRepeatY( texture, reps = 3, offset = 0.5 )

The texture parameter can be any kind of source, for example a color, src, or shape.

modulateKaleid #

modulateKaleid( texture, nSides = 4 )

The texture parameter can be any kind of source, for example a color, src, or shape. See also: kaleid.

modulateScrollX #

modulateScrollX( texture, scrollX = 0.5, speed )

The texture parameter can be any kind of source, for example a color, src, or shape. See also: scrollX

modulateScrollY #

modulateScrollY( texture, scrollY = 0.5, speed )

The texture parameter can be any kind of source, for example a color, src, or shape. See also: scrollY

modulate #

modulate( texture, amount = 0.1 )

Modulate texture. More about modulation at: https://lumen-app.com/guide/modulation/ The texture parameter can be any kind of source, for example a color, src, or shape.

modulateScale #

modulateScale( texture, multiple = 1, offset = 1 )

The texture parameter can be any kind of source, for example a color, src, or shape. See also: scale.

modulatePixelate #

modulatePixelate( texture, multiple = 10, offset = 3 )

The texture parameter can be any kind of source, for example a color, src, or shape. See also: pixelate

modulateRotate #

modulateRotate( texture, multiple = 1, offset )

The texture parameter can be any kind of source, for example a color, src, or shape. See also: rotate

modulateHue #

modulateHue( texture, amount = 1 )

Changes coordinates based on hue of second input. Based on: https://www.shadertoy.com/view/XtcSWM The texture parameter can be any kind of source, for example a color, src, or shape.