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

◆ fill_raw_2dnoise16into8() [1/2]

void fill_raw_2dnoise16into8 ( uint8_t * pData,
int width,
int height,
uint8_t octaves,
q44 freq44,
fract8 amplitude,
int skip,
uint32_t x,
int32_t scalex,
uint32_t y,
int32_t scaley,
uint32_t time )

Fill a 2D 8-bit buffer with noise, using inoise16()

Parameters
pDatathe array of data to fill with noise values
widththe width of the 2D buffer
heightthe height of the 2D buffer
octavesthe number of octaves to use for noise. More octaves = more noise.
xx-axis coordinate on noise map (1D)
scalexthe scale (distance) between x points when filling in noise
yy-axis coordinate on noise map (2D)
scaleythe scale (distance) between y points when filling in noise
timethe time position for the noise field
freq44starting octave frequency
amplitudenoise amplitude
skiphow many noise maps to skip over, incremented recursively per octave

Definition at line 834 of file noise.cpp.

834 {
835 if(octaves > 1) {
836 fill_raw_2dnoise16into8(pData, width, height, octaves-1, freq44, amplitude, skip+1, x*freq44, scalex *freq44, y*freq44, scaley * freq44, time);
837 } else {
838 // amplitude is always 255 on the lowest level
839 amplitude=255;
840 }
841
842 scalex *= skip;
843 scaley *= skip;
844 uint32_t xx;
845 fract8 invamp = 255-amplitude;
846 for(int i = 0; i < height; i+=skip, y+=scaley) {
847 uint8_t *pRow = pData + (i*width);
848 xx = x;
849 for(int j = 0; j < width; j+=skip, xx+=scalex) {
850 uint16_t noise_base = inoise16(xx,y,time);
851 noise_base = (0x8000 & noise_base) ? noise_base - (32767) : 32767 - noise_base;
852 noise_base = scale8(noise_base>>7,amplitude);
853 if(skip==1) {
854 pRow[j] = qadd8(scale8(pRow[j],invamp),noise_base);
855 } else {
856 for(int ii = i; ii<(i+skip) && ii<height; ++ii) {
857 uint8_t *pRow = pData + (ii*width);
858 for(int jj=j; jj<(j+skip) && jj<width; ++jj) {
859 pRow[jj] = scale8(pRow[jj],invamp) + noise_base;
860 }
861 }
862 }
863 }
864 }
865}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
uint8_t octaves
uint8_t fract8
ANSI: unsigned short _Fract.
Definition types.h:36
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
Definition math8.h:31
void fill_raw_2dnoise16into8(uint8_t *pData, int width, int height, uint8_t octaves, q44 freq44, fract8 amplitude, int skip, uint32_t x, int32_t scalex, uint32_t y, int32_t scaley, uint32_t time)
Fill a 2D 8-bit buffer with noise, using inoise16()
Definition noise.cpp:834
uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z, uint32_t t)
16-bit, fixed point implementation of Perlin's noise.
Definition noise.cpp:466
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 fill_raw_2dnoise16into8(), inoise16(), octaves, qadd8(), scale8(), x, and y.

Referenced by fill_2dnoise16(), fill_raw_2dnoise16into8(), and fill_raw_2dnoise16into8().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: