Life Cycle

Functions that are called at particular instances within the Chain Shader


init()

Called before the Shader starts taking in the Audio Data.

void init() {
    // Set audio.multiplier and chain.density here
    chain.density = 256;
    audio.multiplier = 1.2;
}

audioFetch()

Called just after the Audio Data has been fed into the Shader. Fetched Audio is in the normalised Range [0, 1], and after the function returns, gets multiplied by the multiplier values.

void audioFetch(inout float fetchedAudio, float n, float lastN) {
    fetchedAudio *= .5;
}

setProps()

Sets various visual properties of the Shader, such as Strength and Color.

void setProps() {
    chain.channelLineHeight = max(0, 1. - audio.value.x);
    chain.color = interpolateHue(vec4(0, 0.4, 1, 0.03), .05, 15 * (resolution.x - chain.index) * audio.value.x, resolution.x);
}