particles.lua: apply exponent before distributing energy

This commit is contained in:
Thomas Kolb 2020-06-23 21:29:20 +02:00
parent f172a2d1f2
commit f0afdcfa01
1 changed files with 12 additions and 11 deletions

View File

@ -1,10 +1,11 @@
COOLDOWN_FACTOR = 0.9998 COOLDOWN_FACTOR = 0.9998
MAX_ENERGY_PROPAGATION = 0.5 MAX_ENERGY_PROPAGATION = 0.5
EXPONENT=1.3 EXPONENT=1.8
W_EXPONENT=1.8 W_EXPONENT=2.2
OVERDRIVE=1 OVERDRIVE=1
FADE_FACTOR = 0.94 FADE_FACTOR = 0.96
AVG_LEDS_ACTIVATED = 0.05 AVG_LEDS_ACTIVATED = 0.05
WHITE_EXTRA_SCALE = 0.5
num_modules = 1 num_modules = 1
num_strips = 1 num_strips = 1
@ -98,10 +99,10 @@ function periodic()
fade2black(fireBlueEnergy) fade2black(fireBlueEnergy)
fade2black(fireWhiteEnergy) fade2black(fireWhiteEnergy)
distributeEnergy(redEnergy / maxRedEnergy, fireRedEnergy) distributeEnergy((redEnergy / maxRedEnergy)^EXPONENT, fireRedEnergy)
distributeEnergy(greenEnergy / maxGreenEnergy, fireGreenEnergy) distributeEnergy((greenEnergy / maxGreenEnergy)^EXPONENT, fireGreenEnergy)
distributeEnergy(blueEnergy / maxBlueEnergy, fireBlueEnergy) distributeEnergy((blueEnergy / maxBlueEnergy)^EXPONENT, fireBlueEnergy)
distributeEnergy(whiteEnergy / maxWhiteEnergy, fireWhiteEnergy) distributeEnergy((whiteEnergy / maxWhiteEnergy)^W_EXPONENT, fireWhiteEnergy)
-- make colors more exciting + remove the first (flickering) mass -- make colors more exciting + remove the first (flickering) mass
-- TODO: update -- TODO: update
@ -109,10 +110,10 @@ function periodic()
for s = 1,num_strips do for s = 1,num_strips do
i = idx(s, m) i = idx(s, m)
rval = limit(OVERDRIVE * fireRedEnergy[i]^EXPONENT) rval = limit(OVERDRIVE * fireRedEnergy[i])
gval = limit(OVERDRIVE * fireGreenEnergy[i]^EXPONENT) gval = limit(OVERDRIVE * fireGreenEnergy[i])
bval = limit(OVERDRIVE * fireBlueEnergy[i]^EXPONENT) bval = limit(OVERDRIVE * fireBlueEnergy[i])
wval = limit(OVERDRIVE * fireWhiteEnergy[i]^W_EXPONENT) wval = limit(OVERDRIVE * fireWhiteEnergy[i] * WHITE_EXTRA_SCALE)
red[i] = rval red[i] = rval
green[i] = gval green[i] = gval