260 {
261 uint32_t fast_time = time_ms << 3;
262
263 float x_noise = coord.
x * 8000;
264 float y_noise = coord.
y * 8000;
265
266 uint16_t noise1 =
inoise16(x_noise, y_noise, fast_time);
267 uint16_t
noise2 =
inoise16(x_noise + 10000, y_noise + 10000, fast_time + 5000);
268
269 uint8_t threshold = 200;
270 bool lightning = (noise1 >> 8) > threshold || (
noise2 >> 8) > threshold;
271
272 if (lightning) {
273 float lightning_intensity = max((noise1 >> 8) - threshold, (
noise2 >> 8) - threshold) / 55.0f;
274 return palette.mapColor(0.7f, lightning_intensity, 1.0f);
275 } else {
276 float storm_intensity = (noise1 >> 8) / 1020.0f;
277 return palette.mapColor(0.6f, storm_intensity);
278 }
279}
uint8_t noise2[NUM_LAYERS][WIDTH][HEIGHT]
UINumberField palette("Palette", 0, 0, 2)
uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z, uint32_t t)
16-bit, fixed point implementation of Perlin's noise.