Skip to content

Commit 9805ae5

Browse files
authored
PS Fire: added sparks for better looks (wled#4714)
also added some smear-blurring if "smooth" (motion blur) is not used
1 parent 00eb406 commit 9805ae5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

wled00/FX.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8034,6 +8034,7 @@ uint16_t mode_particlefire(void) {
80348034
PartSys->updateSystem(); // update system properties (dimensions and data pointers)
80358035
PartSys->setWrapX(SEGMENT.check2);
80368036
PartSys->setMotionBlur(SEGMENT.check1 * 170); // anable/disable motion blur
8037+
PartSys->setSmearBlur(!SEGMENT.check1 * 60); // enable smear blur if motion blur is not enabled
80378038

80388039
uint32_t firespeed = max((uint8_t)100, SEGMENT.speed); //limit speed to 100 minimum, reduce frame rate to make it slower (slower speeds than 100 do not look nice)
80398040
if (SEGMENT.speed < 100) { //slow, limit FPS
@@ -8062,7 +8063,7 @@ uint16_t mode_particlefire(void) {
80628063
PartSys->sources[i].source.ttl = 20 + hw_random16((SEGMENT.custom1 * SEGMENT.custom1) >> 8) / (1 + (firespeed >> 5)); //'hotness' of fire, faster flames reduce the effect or flame height will scale too much with speed
80638064
PartSys->sources[i].maxLife = hw_random16(SEGMENT.virtualHeight() >> 1) + 16; // defines flame height together with the vy speed, vy speed*maxlife/PS_P_RADIUS is the average flame height
80648065
PartSys->sources[i].minLife = PartSys->sources[i].maxLife >> 1;
8065-
PartSys->sources[i].vx = hw_random16(4) - 2; // emitting speed (sideways)
8066+
PartSys->sources[i].vx = hw_random16(5) - 2; // emitting speed (sideways)
80668067
PartSys->sources[i].vy = (SEGMENT.virtualHeight() >> 1) + (firespeed >> 4) + (SEGMENT.custom1 >> 4); // emitting speed (upwards)
80678068
PartSys->sources[i].var = 2 + hw_random16(2 + (firespeed >> 4)); // speed variation around vx,vy (+/- var)
80688069
}
@@ -8089,6 +8090,20 @@ uint16_t mode_particlefire(void) {
80898090
}
80908091
}
80918092

8093+
// emit faster sparks at first flame position, amount and speed mostly dependends on intensity
8094+
if(hw_random8() < 10 + (SEGMENT.intensity >> 2)) {
8095+
for (i = 0; i < PartSys->usedParticles; i++) {
8096+
if (PartSys->particles[i].ttl == 0) { // find a dead particle
8097+
PartSys->particles[i].ttl = hw_random16(SEGMENT.virtualHeight()) + 30;
8098+
PartSys->particles[i].x = PartSys->sources[0].source.x;
8099+
PartSys->particles[i].y = PartSys->sources[0].source.y;
8100+
PartSys->particles[i].vx = PartSys->sources[0].source.vx;
8101+
PartSys->particles[i].vy = (SEGMENT.virtualHeight() >> 1) + (firespeed >> 4) + ((30 + (SEGMENT.intensity >> 1) + SEGMENT.custom1) >> 4); // emitting speed (upwards)
8102+
break; // emit only one particle
8103+
}
8104+
}
8105+
}
8106+
80928107
uint8_t j = hw_random16(); // start with a random flame (so each flame gets the chance to emit a particle if available particles is smaller than number of flames)
80938108
for (i = 0; i < percycle; i++) {
80948109
j = (j + 1) % numFlames;

0 commit comments

Comments
 (0)