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

◆ calculatePlasmaPixel()

CRGB PlasmaWaveGenerator::calculatePlasmaPixel ( const RingCoord & coord,
uint32_t time_ms,
const PlasmaParams & params )
inline

Definition at line 118 of file FxNoiseRing.h.

118 {
119 float time_scaled = time_ms * params.time_scale * 0.001f;
120
121 // Calculate wave interference
122 float wave_sum = 0.0f;
123 for (int i = 0; i < 4; i++) {
124 float dx = coord.x - sources[i].x;
125 float dy = coord.y - sources[i].y;
126 float distance = sqrt(dx*dx + dy*dy);
127
128 float wave_phase = distance * sources[i].frequency + time_scaled * sources[i].phase_speed;
129 wave_sum += sin(wave_phase) * sources[i].amplitude;
130 }
131
132 // Add noise modulation for organic feel
133 float noise_scale = params.noise_intensity;
134 float noise_x = coord.x * 0xffff * noise_scale;
135 float noise_y = coord.y * 0xffff * noise_scale;
136 uint32_t noise_time = time_ms << params.time_bitshift;
137
138 float noise_mod = (inoise16(noise_x, noise_y, noise_time) - 32768) / 65536.0f;
139 wave_sum += noise_mod * params.noise_amplitude;
140
141 // Map to color space
142 return mapWaveToColor(wave_sum, params);
143 }
float noise_intensity
Definition FxNoiseRing.h:93
uint8_t time_bitshift
Definition FxNoiseRing.h:95
float noise_amplitude
Definition FxNoiseRing.h:94
float time_scale
Definition FxNoiseRing.h:92
CRGB mapWaveToColor(float wave_value, const PlasmaParams &params)
WaveSource sources[4]
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:420

References inoise16(), mapWaveToColor(), PlasmaParams::noise_amplitude, PlasmaParams::noise_intensity, sources, PlasmaParams::time_bitshift, PlasmaParams::time_scale, RingCoord::x, and RingCoord::y.

+ Here is the call graph for this function: