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

View file

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