Noise16 - AlbertGBarber/PixelSpork GitHub Wiki
See the Documentation Guide for help understanding each page section.
Effect Sample (see here for sample info) |
An effect based on the "noise_16" effects created by Andrew Tuline here This effect is basically a sort of FastLED noise playground (see more about noise here) where colors change and blend based on a randomized set of Perlin noise. It tends to produce long stretches of color that shift around the strip. Colors are based on an input palette.
You have a number of different dials you can turn to produce a range of results. The values you use will depend on how long your strip is, but I'll provide some guidance below. You can also try Andrew's inputs (see his noise16_1, noise16_2, and noise16_3 via the links above), but these seemed like they moved to fast for me.
I don't fully understand how everything in this effect works, but based on testing I've written the guide below.
You can think of Perlin noise as a sort of randomly generated 3D landscape, which smoothly transitions from point to point (no sudden jumps like cliffs, spikes, etc). When we ask for a noise value, we are getting back a coordinate from the landscape. To change the noise value, we move through the landscape. Because it is smooth, our values transition nicely between one another, which is great for blending colors, moving pixels, etc. Keep in mind that the noise is only sudo-random, if we put in the same input, we'll get the same output every time.
The noise has four main inputs: an overall scale, and individual scaling values for x, y, and z; the three coordinates of our noise field.
The overall scale determines how "zoomed-in" the noise is, sort of controlling how long lengths of color are. I found that setting it between 500 - 1000 worked well.
For x, y, and z you are given two options of how each are set:
These are set by x_mode
, y_mode
, and z_mode
, and x_val
, y_val
, and z_val
:
- 0 -- Set to a constant value.
- 1 -- Set to a value that varies in time by
millis() / val
. 30 - 100+ works well. - 2 -- Set to the output of
beatsin8(val)
(a sin function with frequencyval
). 1 - 10 works well. - 3 -- Set to a value that varies in time by
millis() * val
. Only recommend using this with thez_val
.
You want at least one input to vary with time, so that we move through the noise field.
With one value varying in time, you can either vary the others as well, or leave them static. Varying them in time can produce a more complex effect, but for some reason, certain combinations of x and y values tend to produce some flicker. I've not been able to track down why this happens sadly. (using z with x or y seems to be okay tho). It's something to do with the oscillations of the two timing effects lining up I think.
Other than that, I can only recommend you experiment. Keep in mind that there are other noise effects, which may be easier to use, but are usually more limited to a certain type of "look". These include any effect with "noise" in the name, and the Lava effect.
Finally, this effect is 1D, so it always treats your Segment Set as a single line.
Noise16PS noise16(mainSegments, 4, 40, 500, 2, 1, 0, 3, 100, 0, 40);
/* Will produce a noise effect with a palette of 4 randomly chosen colors
There are 40 blend steps between each color
An overall scaling value of 500 is applied to the noise
The noise has the following inputs:
x is mode 2, and follows a beatsin with 3 bpm
y is mode 1, and scales with time as millis() / 100;
z is mode 0, so is static at 0;
The effect updates at 40ms */
Noise16PS noise16(mainSegments, cybPnkPal_PS, 20, 600, 1, 0, 2, 200, 10, 5, 60);
/* Will produce a noise effect using colors from the cybPnkPal_PS palette.
There are 20 blend steps between each color
An overall scaling value of 600 is applied to the noise
The noise has the following inputs:
x is mode 1, and scales with time as millis() / 200;
y is mode 0, so is static at 10;
z is mode 2, and follows a beatsin with 5 bpm
The effect updates at 60ms */
//Constructor with palette
Noise16PS(SegmentSetPS &SegSet, palettePS &Palette, uint8_t BlendSteps, uint16_t BlendScale,
uint8_t X_mode, uint8_t Y_mode, uint8_t Z_mode,
uint16_t X_val, uint16_t Y_val, uint16_t Z_val, uint16_t Rate);
//Constructor with randomly generated palette
Noise16PS(SegmentSetPS &SegSet, uint8_t numColors, uint8_t BlendSteps, uint16_t BlendScale,
uint8_t X_mode, uint8_t Y_mode, uint8_t Z_mode,
uint16_t X_val, uint16_t Y_val, uint16_t Z_val, uint16_t Rate);
-
SegmentSetPS* segSet -- The Segment Set the effect will draw on. See common vars
segSet
entry for more details. -
palettePS* palette (optional, see constructors) -- The set of colors the effect will use. See palettes. It is a pointer. See common vars
palette
entry for more details. -
uint8_t numColors (optional, see constructors) -- The number of randomly chosen colors for the effect. The colors will be placed into the effect's local palette,
paletteTemp
for use. -
uint8_t blendSteps -- Sets how many steps are used to blend between each color. Basically changes how fast the colors blend. Between 20 - 100 looks good.
-
uint16_t blendScale -- Sets how "zoomed-in" the noise is. (test it out yourself to see what I mean). Between 500 - 1000 looks good
-
uint8_t x_mode -- Sets how the x noise input will vary with time (see Inputs Guide above).
-
uint8_t y_mode -- Sets how the y noise input will vary with time (see Inputs Guide above).
-
uint8_t z_mode -- Sets how the z noise input will vary with time (see Inputs Guide above).
-
uint16_t x_val -- The scaling factor for the x noise input (see Inputs Guide above).
-
uint16_t y_val -- The scaling factor for the y noise input (see Inputs Guide above).
-
uint16_t z_val -- The scaling factor for the z noise input (see Inputs Guide above).
-
uint16_t* rate -- Update rate (ms). Is a pointer, allowing you to bind it to an external variable. By default it's bound the effect's local variable,
rateOrig
. See common varsrate
entry for more.
- bool showNow (default true) -- Controls if the effect "draws" during each update cycle by calling
FastLED.show()
. Common to all effects. See common varsshowNow
entry for more details.
-
Updates the effect.
void update();