FastLED 3.9.15
Loading...
Searching...
No Matches

◆ fillnoise8()

void fillnoise8 ( )

Definition at line 107 of file NoisePlusPalette.ino.

107 {
108 // If we're runing at a low "speed", some 8-bit artifacts become visible
109 // from frame-to-frame. In order to reduce this, we can do some fast data-smoothing.
110 // The amount of data smoothing we're doing depends on "speed".
111 uint8_t dataSmoothing = 0;
112 if( speed < 50) {
113 dataSmoothing = 200 - (speed * 4);
114 }
115
116 for(int i = 0; i < MAX_DIMENSION; i++) {
117 int ioffset = scale * i;
118 for(int j = 0; j < MAX_DIMENSION; j++) {
119 int joffset = scale * j;
120
121 uint8_t data = inoise8(x + ioffset,y + joffset,z);
122
123 // The range of the inoise8 function is roughly 16-238.
124 // These two operations expand those values out to roughly 0..255
125 // You can comment them out if you want the raw noise data.
126 data = qsub8(data,16);
127 data = qadd8(data,scale8(data,39));
128
129 if( dataSmoothing ) {
130 uint8_t olddata = noise[i][j];
131 uint8_t newdata = scale8( olddata, dataSmoothing) + scale8( data, 256 - dataSmoothing);
132 data = newdata;
133 }
134
135 noise[i][j] = data;
136 }
137 }
138
139 z += speed;
140
141 // apply slow drift to X and Y, just for visual variation.
142 x += speed / 8;
143 y -= speed / 16;
144}
uint8_t noise[NUM_LAYERS][WIDTH][HEIGHT]
Definition Fire2023.ino:86
uint32_t z[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
UISlider scale("Scale", 4,.1, 4,.1)
uint16_t speed
Definition Noise.ino:63
#define MAX_DIMENSION
Definition Noise.ino:21
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
Definition math8.h:31
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8(uint8_t i, uint8_t j)
Subtract one byte from another, saturating at 0x00.
Definition math8.h:103
uint8_t inoise8(uint16_t x, uint16_t y, uint16_t z)
8-Bit, fixed point implementation of Perlin's noise.
Definition noise.cpp:616
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
Definition scale8.h:34

References inoise8(), MAX_DIMENSION, noise, qadd8(), qsub8(), scale, scale8(), speed, x, y, and z.

+ Here is the call graph for this function: