107 {
108
109
110
111 uint8_t dataSmoothing = 0;
113 dataSmoothing = 200 - (
speed * 4);
114 }
115
117 int ioffset =
scale * i;
119 int joffset =
scale * j;
120
121 uint8_t data =
inoise8(
x + ioffset,
y + joffset,
z);
122
123
124
125
126 data =
qsub8(data,16);
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
136 }
137 }
138
140
141
144}
uint8_t noise[NUM_LAYERS][WIDTH][HEIGHT]
UISlider scale("Scale", 4,.1, 4,.1)
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8(uint8_t i, uint8_t j)
Subtract one byte from another, saturating at 0x00.
uint8_t inoise8(uint16_t x, uint16_t y, uint16_t z)
8-Bit, fixed point implementation of Perlin's noise.
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 ...