Plasma effect

Technique

The plasma effect is a simple effect that uses a predefined color palette and a periodical function.

For such an effect, the periodical function is generally a trigonometric function such as cosine. For a given pixel with coordinates (x,y), each coordinate is truncated by using a modulo function, that ensures the values in range [min , max]. These values are used by the function to return a value that is the color index in the color palette.

This is illustrated by the figure below:

Moving the pattern

By adding some variable values to pixel coordinates, it is possible to change the phase and the displacement of the pattern, that provides a nice and dynamical plasma effect.

The given code lets you see how we can change the phase and the displacement of the pattern. There are many good tutorials on the web that may give you more details about such a technique.