Live Code Help - noisedeck/noisedeck-docs GitHub Wiki

Live Code Help

The live-code modules allow you to create simple synth, mixer, and post modules by editing shaders. If you're not familiar with shaders, https://thebookofshaders.com/ is a great place to start learning.

Limitations

These modules are a stopgap measure until we implement the planned feature of full user-created modules. As such, we are not planning to expend much energy improving these modules or the code editor.

There is currently no interface for importing/exporting or deleting presets.

Helpful Hints

Each live-code module has built-in uniforms for time, resolution, and random seed, plus at least one slider-controlled input value (f1 - f7).

You can map the uniform inputs (f1 - f7), which are coded as float values between 0 - 100, to other float ranges or other types entirely.

// useful map function
float map(float value, float inMin, float inMax, float outMin, float outMax) {
  return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
}

// map f1 to the range -1 to 1
float val = map(f1, 0.0, 100.0, -1.0, 1.0);

// convert f1 to an integer
int val = int(f1);

// use f1 like a boolean
if (f1 < 50.0) {
    // do something
} else {
    // do something else
}

// make a vec3 out of f1, f2 and f3
vec3 color = vec3(f1, f2, f3) * 0.01;

Module Roles

Each live-code module serves a specific function. Live-code-synth creates a synth module with no inputs other than the seed and the f1 - f5 sliders. Live-code-mixer takes the output from synth1 and synth2 and combines them. Live-code-post takes the mixer output (or the active synth output if only one synth is enabled) and performs post processing on it.

Debugging

If your shader fails to compile, the text in the editor will turn red. You can see the compile error in your browser's developer console. Some common errors include missing semicolons, missing decimal points in float values, and type mismatches. If there's no visible output from your shader, try explicitly setting the alpha value of the output color to a value greater than 0.

We cannot assist you with shader creation and debugging. You can ask for help from the community in the discussion forums.