Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squashed commit of FXparticleSystem #3823

Draft
wants to merge 24 commits into
base: 0_15
Choose a base branch
from

Conversation

DedeHai
Copy link
Collaborator

@DedeHai DedeHai commented Mar 14, 2024

FX particle system ready for review.

@softhack007 softhack007 mentioned this pull request Mar 15, 2024
@blazoncek
Copy link
Collaborator

Unfortunately on my dev build:

Linking .pio/build/wemos_d1_mini32_debug/firmware.elf
Retrieving maximum program size .pio/build/wemos_d1_mini32_debug/firmware.elf
Checking size .pio/build/wemos_d1_mini32_debug/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
Error: The program size (1578750 bytes) is greater than maximum allowed (1572864 bytes)
RAM:   [===       ]  26.6% (used 87072 bytes from 327680 bytes)
Flash: [===*** [checkprogsize] Explicit exit, status 1
=======]  100.4% (used 1578750 bytes from 1572864 bytes)

@blazoncek
Copy link
Collaborator

Screenshot 2024-03-16 at 15 50 59
A bit long names...

@blazoncek
Copy link
Collaborator

Suggestions:

  • fire tends to burn on the left side of the matrix
  • waterfall tends to splay on the right hand side
  • rotating spray would benefit of random alternating rotation
  • volcano never fills entire height
  • fireworks might be better to have white firing pojectile

@blazoncek
Copy link
Collaborator

Looks extremely good.
The only downside is hefty increase in image size and slow FPS.
None of the effects achieve more than 50-58FPS on 20x20 matrix on ESP32 (desired FPS was 80).

@DedeHai
Copy link
Collaborator Author

DedeHai commented Mar 17, 2024

-On my build (ESP 32 S3 with AR) the increase in code is 1% or about 16kB. Do you have a map file of sorts? 1.5MB of code is huge for an embedded system... do you know what uses the largest slices of space? Maybe there is room to optimize somewhere else to make it fit?
-FPS can be increased by limiting the number of particles. I did not target 80FPS but 40FPS which IMHO is enough for the effects to look smooth. But parameters can be adjusted to increase it. Should I take a look at that? I can test on ESP32 S3 with 32x16.
-Effect Names are TBD I put 'particle' in every name just so I can easily filter them in the list. Open to suggestions.
-I will take a look at your suggestions (some may be bugs: fire, waterfall)
-Fireworks in white is a good idea, as 'exhaust' is only orange if using rainbow palette (I added this effect before adding the possibility to set saturation)
-Volcano: I can adjust the settings range, I tested on 16x16 where it goes to top. Any matrix target size to optimize for? I assumed 8x8 as a minimum but no maximum height. suggestion: slider settings such that 32x32 (I can test on w16 x h32) is still filled (some other animations may also need adjustment for that)

@DedeHai
Copy link
Collaborator Author

DedeHai commented Mar 17, 2024

I looked at your other points:

  • fire tends to burn on the left side of the matrix

cannot reproduce. any specific settings this happens?

  • waterfall tends to splay on the right hand side

this is something I already noticed, 'inequality' happens also in other animations.
I think the reason is somewhere in the collision handling and integer math favouring that direction. So far I could not figure out what it is exactly. but it has nothing to do with the 'pushing' part as it also happens if I disable particle pushing.

  • rotating spray would benefit of random alternating rotation

There is an option checkbox left in that animation, so I can add it. I put it on my todo list.

@blazoncek
Copy link
Collaborator

any specific settings this happens?

no. fire was definitely more prominent on the left side of the matrix. default values.

- changed firework exhaust to low saturation
- updated rotating particle spray animation
@DedeHai
Copy link
Collaborator Author

DedeHai commented Mar 18, 2024

  • volcano never fills entire height

I set my 32x16 matrix to vertical (w15 x h32) and volcano fills to the top easily if particles speed is set high. But depends on collision settings and bounceX setting.

@DedeHai
Copy link
Collaborator Author

DedeHai commented Mar 18, 2024

I looked at the possibility to limit the total amount of particles to make transistions faster but that is not really an option. fire on a wide matrix (32 pixels in my case) uses A LOT of particles to make it look good, over 1000 (this may be excessive, can probably be somewhat optimized). Also the rotating particlespray uses 700 particles (I tuned this with 16x16 matrix). So it could be limited to about 1000 but that will not help if transitioning between effects that use collisions and less particles (like particle box and volcano for example). So not a good solution without crippling some of the FX...

@blazoncek
Copy link
Collaborator

Let's see if @Aircoookie agrees on this PR. It gets my approval, except for the long names.

IMO the next iteration would be to try to replace older effects (1D) with particle system if the resulting code size or performance would be better.

-added particle reductions for ESP8266 for all FX
-Removed collisions from Particle Perlin Noise FX, slows things down and does not contribute to a better effect experience
-lots of optimizations for ESP8266, all FX now work (at least on 160MHz but still slow)
-Some bugfixes
-removed unused variables to make compiler happy
-Now shorter names, 'PS' in front to filter the list
-Tuned default parameters to make them look better by default
-Bugfix in particle system (removed duplicate application of velocity)
-reduced PS fire RAM usage (less particles, less base flames, no noticeable difference)
-some variable renaming
-fixed fire burning more on the left side
-fixed crash in particle attractor
-added many improvements for ESP8266
-improved particle rendering efficiency
-efficiency improvements in general
-changed the way fire is rendered, now more than 2x faster
-re-tuned fire to new rendering, also seperately tuned it for ESP8266
-changed all random8() to random16() as it runs faster on ESPs
-some reformating
-some renaming of effect stuff
-fine tuning on falling particle effect
-improvements to collision handling (faster and better)
-added a (temporary) function for speed tests, will be removed again
-removed spiral explosions
-added more versatility to circular explosions
-removed user selectable amount of rockets
-tuned explosion size of circular explosions to match random explosions (more or less, may need improvement)
-changed order of sliders in volcano animation
@DedeHai
Copy link
Collaborator Author

DedeHai commented Mar 29, 2024

any specific settings this happens?

no. fire was definitely more prominent on the left side of the matrix. default values.

I was able to reproduce this now. I think I fixed it, will be in upcoming updates. Turns out random16() is not random enough for some things

- put particle system in a class, went through the whole code, rewrote many of the functions
- added local rendering buffer (renders to buffer in heap)
- added fast and accurate color-add function
- converted all FX to the class and improved all of them with parameter tuning and new features
- fixed animation transitions with proper pointer setting in each FX call
- fixed collisions
- changed max number of particles and sprays based on some ram calculations
- countless bugfixes
- still a lot of debug stuff in the code, badly needs a cleanup
@softhack007
Copy link
Collaborator

Unfortunately on my dev build:

Linking .pio/build/wemos_d1_mini32_debug/firmware.elf
Retrieving maximum program size .pio/build/wemos_d1_mini32_debug/firmware.elf
Checking size .pio/build/wemos_d1_mini32_debug/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
Error: The program size (1578750 bytes) is greater than maximum allowed (1572864 bytes)
RAM:   [===       ]  26.6% (used 87072 bytes from 327680 bytes)
Flash: [===*** [checkprogsize] Explicit exit, status 1
=======]  100.4% (used 1578750 bytes from 1572864 bytes)

Similar observation on the 8266 github build - this feature pushed FLASH (program) size over the limits.

I think it would be best to have a build flag to disable the particle system feartures - similar to WLED_DISABLE_2D.

This would allow to build some environments without particle system, and have some program space left for other things like usermods.

Additions:
- Motion blurring on local buffer
- Blurring / smearing on local buffer
- Fast color scaling function
- Blurring of individual particles
- Advanced settings for particles (forces, render size)
- Wall roughness setting for randomized wall bounce
- Ghost Rider FX implementation for PS
Changes:
- Transferred all existing FX to PS class
- Improvements on most FX, also nicer rendering with blurring
- Improvements in PS Fire FX
- Added larger size particle rendering to Ballpit FX
- Added random size Particle rendering to Ballpit FX (set to size 255)
- uncought out of bounds memory access in rendering and a bug in pointer assignment caused many hard to track down crashes. should be fixed now.
- some minor fixes as well
commit ba337ab
Merge: 0b45f66 3f9a6ca
Author: Damian Schneider <[email protected]>
Date:   Sun May 5 21:57:32 2024 +0200

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit 0b45f66
Author: Damian Schneider <[email protected]>
Date:   Sun May 5 21:56:19 2024 +0200

    bugfix, sprayEmit() would not return and get stuck

    - forgot default return value...

commit 2558156
Author: Damian Schneider <[email protected]>
Date:   Sun May 5 11:19:02 2024 +0200

    code cleanup, removed some unused stuff

commit ac5399a
Author: Damian Schneider <[email protected]>
Date:   Sun May 5 08:18:43 2024 +0200

    Added advanced particle size control and new Blob FX

    - advanced size control allows for growing, shrinking, wobbling
    - render function updated to support asymmetric rendering
    - various code improvements and bugfixes
    - some FX parameter tuning
    - bugfix: removed sli() sei() calls in render function that caused random flickering on S3/C3 (may add that back in but only for ESP8266 to reduce fragmentation)
    - removed some debug / test stuff

commit 3f9a6ca
Author: Frank <[email protected]>
Date:   Sat May 4 14:34:23 2024 +0200

    AR: fix for arduinoFFT 2.x API

    in contrast to previous 'dev' versions, the storage for windowWeighingFactors is now managed internally by the arduinoFFT object.

commit cd5494f
Author: Frank <[email protected]>
Date:   Sat May 4 13:36:56 2024 +0200

    AR pin config: SCK == 1 --> PDM microphone

commit 5ab1b14
Merge: fa76431 379f181
Author: Blaž Kristan <[email protected]>
Date:   Fri May 3 23:25:36 2024 +0200

    Merge pull request Aircoookie#3946 from freakintoddles2/0_15

    Adds an API parameter to allow the user to skip to the next preset in a playlist at any time

commit 379f181
Author: Todd Meyer <[email protected]>
Date:   Fri May 3 11:51:47 2024 -0700

    Further simplification

commit dd19aa6
Author: Todd Meyer <[email protected]>
Date:   Fri May 3 08:47:14 2024 -0700

    Forgot F[], added it

commit 6df3b41
Author: Todd Meyer <[email protected]>
Date:   Fri May 3 08:30:37 2024 -0700

    Updated based on more feedback

commit fa76431
Author: Blaz Kristan <[email protected]>
Date:   Fri May 3 16:08:20 2024 +0200

    Changelog update

commit 6504fb6
Author: Blaz Kristan <[email protected]>
Date:   Fri May 3 15:46:16 2024 +0200

    Minor MQTT optimisation.

commit 2ff49cf
Author: Blaz Kristan <[email protected]>
Date:   Fri May 3 15:45:15 2024 +0200

    Fix for Aircoookie#3952
    - included IR optimisations & code rearrangement

commit fa1aa1f
Merge: 85b95a2 22f6128
Author: Blaž Kristan <[email protected]>
Date:   Fri May 3 09:56:14 2024 +0200

    Merge pull request Aircoookie#3944 from paspiz85/pas4

    Using brightness in analog clock overlay

commit 85b95a2
Merge: 4df936a 736a8b1
Author: Blaž Kristan <[email protected]>
Date:   Fri May 3 09:53:00 2024 +0200

    Merge pull request Aircoookie#3945 from w00000dy/Webpage-shortcuts

    Add Webpage shortcuts and Fix resizing bug

commit 5e38039
Author: Todd Meyer <[email protected]>
Date:   Thu May 2 14:36:18 2024 -0700

    Updated based on more feedback

commit 4df936a
Author: Blaz Kristan <[email protected]>
Date:   Thu May 2 10:33:10 2024 +0200

    Fix for unfortunate prior CRLF coversion.

commit 736a8b1
Author: Blaz Kristan <[email protected]>
Date:   Thu May 2 10:31:50 2024 +0200

    Fix for rotating tablet into PC mode.

commit 22f6128
Author: Pasquale Pizzuti <[email protected]>
Date:   Thu May 2 09:04:07 2024 +0200

    using global brightness

commit db475b6
Author: freakintoddles2 <[email protected]>
Date:   Wed May 1 10:09:17 2024 -0700

    Update playlist.cpp

commit 6daf7f6
Author: freakintoddles2 <[email protected]>
Date:   Wed May 1 10:07:52 2024 -0700

    Update wled.cpp

    reworked based on PR feedback

commit 16086c0
Author: freakintoddles2 <[email protected]>
Date:   Wed May 1 10:05:26 2024 -0700

    Update wled.h

    reworked based on feedback from original PR

commit e88c81a
Author: freakintoddles2 <[email protected]>
Date:   Wed May 1 10:04:02 2024 -0700

    Update set.cpp

    reworked based on feedback

commit a2b9aed
Author: freakintoddles2 <[email protected]>
Date:   Wed May 1 10:03:16 2024 -0700

    Update playlist.cpp

    reworked approach based on feedback

commit caa4fe1
Author: freakintoddles2 <[email protected]>
Date:   Wed May 1 10:02:27 2024 -0700

    Update json.cpp

    reworked approach based on feedback

commit 25fb878
Author: freakintoddles2 <[email protected]>
Date:   Wed May 1 10:01:30 2024 -0700

    Update fcn_declare.h

    reworked approach based on feedback

commit 77167a2
Author: Damian Schneider <[email protected]>
Date:   Wed May 1 13:53:59 2024 +0200

    Found and fixed crashes, it was wrongly assigned pointers

commit 3527144
Author: Damian Schneider <[email protected]>
Date:   Wed May 1 12:08:03 2024 +0200

    Fixed another memory / pointer bug, but there is still one left...

    -also some minor fixes

commit 06ae14c
Author: Damian Schneider <[email protected]>
Date:   Wed May 1 07:07:48 2024 +0200

    added 'perpetual' flag to particles

commit a1d6ffa
Author: freakintoddles2 <[email protected]>
Date:   Tue Apr 30 16:49:52 2024 -0700

    Update json.cpp

    adds support for np boolean parameter to skip to next preset

commit 3b89814
Author: freakintoddles2 <[email protected]>
Date:   Tue Apr 30 16:33:30 2024 -0700

    Update set.cpp

    added new NP command to API to allow user to skip to next preset in a playlist. Example use is win&NP in a preset.

commit 071e0be
Author: freakintoddles2 <[email protected]>
Date:   Tue Apr 30 16:23:43 2024 -0700

    Update fcn_declare.h

    Updated to add the optional skipNext bool to handlePlaylist() which allows people to skip to the next preset when desired

commit bed364d
Author: freakintoddles2 <[email protected]>
Date:   Tue Apr 30 16:21:40 2024 -0700

    Update playlist.cpp

    Updated to allow a user to optionally skip to the next preset in the playlist anytime they desire.

commit d2984e9
Author: Woody <[email protected]>
Date:   Tue Apr 30 18:57:53 2024 +0200

    add Webpage shortcuts, resolves Aircoookie#2362

commit fd9570e
Author: Pasquale Pizzuti <[email protected]>
Date:   Tue Apr 30 17:52:35 2024 +0200

    using color_fade

commit ff10130
Author: Woody <[email protected]>
Date:   Tue Apr 30 16:53:47 2024 +0200

    Fix resizing bug
    The bug was that when resizing the window, it always jumped to the Colors tab instead of staying on the currently selected tab.

commit c7d292a
Author: Pasquale Pizzuti <[email protected]>
Date:   Tue Apr 30 14:09:12 2024 +0200

    using brightness in analog clock overlay

commit 5472f76
Merge: a6bf5b6 9f99a18
Author: Damian Schneider <[email protected]>
Date:   Tue Apr 30 07:50:44 2024 +0200

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit a6bf5b6
Author: Damian Schneider <[email protected]>
Date:   Tue Apr 30 07:41:04 2024 +0200

    added walls to ghostride, fixed some bugs

commit 33ede41
Author: Damian Schneider <[email protected]>
Date:   Mon Apr 29 19:46:19 2024 +0200

    Replaced Ghost Rider FX with PS version

    - new FX is kept close to original animation but added more user settings

commit 2e0cb3a
Author: Damian Schneider <[email protected]>
Date:   Sun Apr 28 19:29:57 2024 +0200

    Fixed some nasty memory bugs, fixed some FX parameters

    - fixed memory alignment bug in PS pointer assignment by making sure only multiples of 4 are allowed for particles and sources
    - added saturation back to particle struct, as it was aligned to 10 bytes anyway.
    - fixed a bug where a null pointer could be accessed
    - fixed rendering out of frame particles if buffer allocation failed
    - improvements on ESP8266

commit 3eb94eb
Merge: 53607d6 8110259
Author: Damian Schneider <[email protected]>
Date:   Sun Apr 28 11:30:44 2024 +0200

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit 53607d6
Author: Damian Schneider <[email protected]>
Date:   Sun Apr 28 11:25:57 2024 +0200

    added individual size particle rendering plus some fixes

    - advanced particles can now be rendered to individual sizes. It is computationally intensive but it works well for up to 15 very large particles and more smaller ones
    - added collision handling for individual sizes (walls and collisions)
    - fixed bugs in particlebox
    - fixed fire not transitioning properly (flickering) when frame skip is active
    - removed 'wraparound' function as it can easily be done by casting to an unsigned and then modulo
    - fixed ballpit particles wandering left and right very fast if wrapX is set

commit 7abc440
Author: Damian Schneider <[email protected]>
Date:   Sat Apr 27 13:40:38 2024 +0200

    removed zero inits

    - removed zero initialisations in FX, segment.data is set to zero by alloc function

commit 54e94dd
Author: Damian Schneider <[email protected]>
Date:   Sat Apr 27 13:18:30 2024 +0200

    Bugfixes, improvements and added wall roughness setting

    - fixed bug in PS fuzzy noise which made it asymmetric for some reason, seems to work better now
    - added particle size option to attractor but had to remove speed setting (now fixed emit speed)
    - some parameter tuning of FX
    - improvements to code size in render function
    - added smear option to blurring (not tested much, may be buggy without smear)
    - speed improvement to caldForce_dv, added zero checking.

commit a22466a
Merge: 3386a84 004b1c3
Author: Damian Schneider <[email protected]>
Date:   Fri Apr 26 08:56:07 2024 +0200

    Merge branch 'FXparticleSystem' of https://github.com/DedeHai/WLED into FXparticleSystem

commit 3386a84
Author: Damian Schneider <[email protected]>
Date:   Fri Apr 26 08:55:17 2024 +0200

    added local render blurring, boosting FPS, work in progress

    - changed fast-add function to use pointers
    - added fast-scaling function
    - added simple (but fast) 2D blurring function
    test shows that local blurring of full frame is almost double the speed (40FPS now is 80FPS).
    lots of comments still there

commit 004b1c3
Merge: e43f3bd e83d3cb
Author: Damian Schneider <[email protected]>
Date:   Thu Apr 25 15:50:07 2024 +0200

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit e43f3bd
Author: Damian Schneider <[email protected]>
Date:   Wed Apr 24 17:33:02 2024 +0200

    bugfix in wrap function and firwork FX

commit 2e7fbc0
Author: Damian Schneider <[email protected]>
Date:   Wed Apr 24 06:39:30 2024 +0200

    debugging going on

commit 7b68946
Author: Damian Schneider <[email protected]>
Date:   Mon Apr 22 18:52:13 2024 +0200

    in the middle of fixing FX to use new PS functions

commit e017814
Author: Damian Schneider <[email protected]>
Date:   Sat Apr 20 15:34:16 2024 +0200

    added more tests, non compiling at the moment

commit 856527b
Author: Damian Schneider <[email protected]>
Date:   Sat Apr 20 12:10:24 2024 +0200

    work in progress, added test function to increase particle size, also added wobbling test

commit 4146ff4
Merge: 50489f7 d126611
Author: Damian Schneider <[email protected]>
Date:   Tue Apr 16 19:32:14 2024 +0200

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit 50489f7
Author: Damian Schneider <[email protected]>
Date:   Tue Apr 16 19:29:05 2024 +0200

    work in progress, added motion blur and line attracto (non working)

commit f7337b9
Merge: 5e2dca3 d18f078
Author: Damian Schneider <[email protected]>
Date:   Sun Apr 7 13:39:23 2024 +0200

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit 5e2dca3
Author: Damian Schneider <[email protected]>
Date:   Sat Apr 6 07:15:51 2024 +0200

    Fixed Speed limit

    limiting speed was incorrect, leading to overflows. fixed this.
    also fixed bugs in GEQ, removed some debug stuff, added FPS limit to fire (just en experiment)

commit 0a251ae
Author: Damian Schneider <[email protected]>
Date:   Thu Apr 4 17:51:32 2024 +0200

    another huge update, many improvements, fine-tune collision, fire and some other FX

    -removed classic fire render as palette now looks much better
    -tweaked fire parameters to more awesome
    -added (optional) turbulence to fire using perlin-noise
    -ported spray FX to use PS-class
    -now definitely fixed asymmetrical collision issue: do not use bitshifts on negative numbers!
    -changed piling behaviour of particles, full rework. looks way more natural now and works much better
    -changed bouncing behavour: they now bounce at full diameter, making them stay fully in frame when laying on the floor
    -replaced all relevant bitshifts with divisions for higher accuracy throughout the PS
    -added new modes to particle box FX
    -changed a lot of FX parameters (finetuning)
    -changed all config strings to proper settings (matrix only)
    -fixed newly introduced bugs
    -added speedup/slowdown to vortex FX (aka candy, aka rotating sprays)
    -some renaming
    -fixed bugs… lots of bugs
    -merged rendering functions, removed obsolete stuff

commit 32343ea
Author: Damian Schneider <[email protected]>
Date:   Tue Apr 2 20:26:24 2024 +0200

    updated fire, added some functions to PS, ported attractor FX

    - added turbulance to fire (after hours of fine-tuning) it now looks even more awesome
    - added attractor animation back in and improved it with more functionality
    - fixed the attractor function in the PS
    - renamed FX: 'candy' is now called 'vortex'
    - added new force function to apply a force immediately (and handle the timing in the FX)
    - added update function to PS for size update to handle dynamic segment size change
    - made waterfall width dynamic on segment width
    - removed some debug stuff
    - added #defines for maximum number of particles/sprays
    - updated fire parameter to make it look better on ESP8266
    - some little bugfixes

commit 59f2b9a
Author: Damian Schneider <[email protected]>
Date:   Mon Apr 1 19:04:28 2024 +0200

    more bugfixes, some animation tuning, added volcano back in

    - fixed animation transitions with proper pointer setting in each FX call
    - added color by age setting to particle system
    - maybe fixed collision having a tendency to go to the left
    - fixed bugs in fireworks FX
    - added fire spread width as a slider
    - changed max number of particles and sprays based on some ram calculations
    - some other random fixes

commit 136f40f
Author: Damian Schneider <[email protected]>
Date:   Sun Mar 31 17:42:48 2024 +0200

    More Bugfixes, more converted FX

commit 5f824c3
Author: Damian Schneider <[email protected]>
Date:   Sun Mar 31 09:50:46 2024 +0200

    many (many!) bugfixes, added fire FX back in (and improved it a lot) added local renderbuffer for huge speed boost

    -lots of bugfixes in Particle system
    -added local rendering buffer (renders to buffer in heap)
    -added fast and accurate color-add function
    -bugfixes in render function
    -added improved 'sticky' particles in collision (unfinished business)
    -added ballpit animation back
    -lots of tweaks to fire FX and fire rendering functions, looks even better now (still unfinished)
    -added palette render option to fire

    still many debug print outputs around, needs cleanup at one point

commit 03967a9
Author: Damian Schneider <[email protected]>
Date:   Fri Mar 29 20:25:13 2024 +0100

    put particle system in a class. work in progress.

    another huge update to the particle system.
    went through the whole code, rewrote many of the functions. many improvements over the previous code. fixed many bugs (and even an ancient one in rendering function). spent many hours optimizing the code for speed and usability.
    still a work in progress, debugging is ongoing. more updates to come.

commit 162bdaa
Merge: c6d5d3e 85a51e6
Author: Damian Schneider <[email protected]>
Date:   Sun Mar 24 13:07:57 2024 +0100

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit c6d5d3e
Author: Damian Schneider <[email protected]>
Date:   Sun Mar 24 12:02:55 2024 +0100

    updated PS Fireworks with many changes and fine-tuning of parameters

    -removed spiral explosions
    -added more versatility to circular explosions
    -removed user selectable amount of rockets
    -tuned explosion size of circular explosions to match random explosions (more or less, may need improvement)
    -changed order of sliders in volcano animation

commit 500b847
Author: Damian Schneider <[email protected]>
Date:   Sat Mar 23 20:11:48 2024 +0100

    bugfix

commit 35c2157
Author: Damian Schneider <[email protected]>
Date:   Sat Mar 23 20:11:23 2024 +0100

    Big update: lots of little fixes and big speed boost on fire animation

    -fixed fire burning more on the left side
    -fixed crash in particle attractor
    -added many improvements for ESP8266
    -improved particle rendering efficiency
    -efficiency improvements in general
    -changed the way fire is rendered, now more than 2x faster
    -re-tuned fire to new rendering, also seperately tuned it for ESP8266
    -changed all random8() to random16() as it runs faster on ESPs
    -some reformating
    -some renaming of effect stuff
    -fine tuning on falling particle effect
    -improvements to collision handling (faster and better)
    -added a (temporary) function for speed tests, will be removed again

commit 306a850
Author: Damian Schneider <[email protected]>
Date:   Thu Mar 21 22:42:45 2024 +0100

    slight speed improvements in fire, like 1-2FPS

commit 913e910
Author: Damian Schneider <[email protected]>
Date:   Thu Mar 21 15:55:40 2024 +0100

    Particle FX Rename, default parameter tuning, bugfix

    -Now shorter names, 'PS' in front to filter the list
    -Tuned default parameters to make them look better by default
    -Bugfix in particle system (removed duplicate application of velocity)
    -reduced PS fire RAM usage (less particles, less base flames, no noticeable difference)
    -some variable renaming

commit 7026159
Author: Damian Schneider <[email protected]>
Date:   Tue Mar 19 20:17:13 2024 +0100

    Cleanup & Bugfixes plus major improvements for ESP8266

    -added particle reductions for ESP8266 for all FX
    -Removed collisions from Particle Perlin Noise FX, slows things down and does not contribute to a better effect experience
    -lots of optimizations for ESP8266, all FX now work (at least on 160MHz but still slow)
    -Some bugfixes
    -removed unused variables to make compiler happy

commit ff9d2eb
Author: Damian Schneider <[email protected]>
Date:   Sun Mar 17 21:59:42 2024 +0100

    FX update

    - changed firework exhaust to low saturation
    - updated rotating particle spray animation

commit a56d888
Author: Damian Schneider <[email protected]>
Date:   Wed Mar 20 19:39:26 2024 +0100

    added rotating GEQ, work in progress

    -animation works but sliders are too sensitive. need to adjust the ranges

commit 7991776
Author: Damian Schneider <[email protected]>
Date:   Sun Mar 17 15:41:46 2024 +0100

    GEQ  FX parameter tuning

commit ecc64ae
Author: Damian Schneider <[email protected]>
Date:   Sat Mar 16 11:43:22 2024 +0100

    Particle GEQ fixes, it now actually works

commit 87adbed
Author: Damian Schneider <[email protected]>
Date:   Fri Mar 15 20:52:47 2024 +0100

    added particle GEQ effect (untested)

commit bdfb1a9
Merge: 3678aa9 7b366d4
Author: Damian Schneider <[email protected]>
Date:   Tue Mar 12 21:48:34 2024 +0100

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit 3678aa9
Merge: ac09218 88b30e7
Author: Damian Schneider <[email protected]>
Date:   Tue Mar 12 21:47:28 2024 +0100

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit ac09218
Author: Damian Schneider <[email protected]>
Date:   Tue Mar 12 20:45:52 2024 +0100

    cleanup

    removed / added comments

commit 4930cda
Author: Damian Schneider <[email protected]>
Date:   Tue Mar 12 20:17:02 2024 +0100

    cleanup session

    -removed particle box 'rocking boat' (buggy) and replaced with random sloshing.
    -removed comments
    -changed some variables into 32bit for speed boost on ESP32
    -added link to KB at the top of FX.cpp

commit 9c6d6f1
Author: Damian Schneider <[email protected]>
Date:   Sun Mar 10 22:35:13 2024 +0100

    cleanup

    -removed wrap_update function, now integrated into move_update
    -added more 'out of bounds' checking in fire functions, may speed it up a little

commit b99a62f
Author: Damian Schneider <[email protected]>
Date:   Fri Mar 8 19:23:52 2024 +0100

    removed comments, added comments

commit 66ac5ac
Author: Damian Schneider <[email protected]>
Date:   Fri Mar 8 18:14:59 2024 +0100

    Revert "fixed touch buttons for ESP32 S2 and S3"

    This reverts commit 0904155.

commit 62a975d
Author: Damian Schneider <[email protected]>
Date:   Fri Mar 8 18:14:52 2024 +0100

    Revert "some tuning for touch buttons on S2/S3"

    This reverts commit d21ad8e.

commit d01a151
Author: Damian Schneider <[email protected]>
Date:   Mon Feb 26 18:20:07 2024 +0100

    add todo

commit 6740cb6
Author: Damian Schneider <[email protected]>
Date:   Thu Feb 22 19:16:42 2024 +0100

    chaned rotating spray default parameters

commit 1a7ef9b
Author: Damian Schneider <[email protected]>
Date:   Wed Feb 21 20:26:17 2024 +0100

    updated rotating particle spray with more user options

commit d21ad8e
Author: Damian Schneider <[email protected]>
Date:   Wed Feb 21 18:38:34 2024 +0100

    some tuning for touch buttons on S2/S3

    now better fits the default threshold value of 32

commit 0904155
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 18 15:52:36 2024 +0100

    fixed touch buttons for ESP32 S2 and S3

    touch is implemented differently on S2 and S3, these changes make touch buttons work on S2 and S3

commit a775970
Merge: 241b080 21173dc
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 18 11:29:00 2024 +0100

    Merge remote-tracking branch 'upstream/0_15' into FXparticleSystem

commit 241b080
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 17 16:50:16 2024 +0100

    added particle WrapUpdate function, added spray FX, some bugfixes

commit 11a84c1
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 17 14:23:05 2024 +0100

    removed TODOs

commit 74ed705
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 17 14:19:56 2024 +0100

    updated particle attractor animation parameters and added more user options to perlin noise

commit 32979e5
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 17 12:50:20 2024 +0100

    lots of bugfixes

commit b96ad99
Author: Damian Schneider <[email protected]>
Date:   Tue Feb 13 17:00:42 2024 +0100

    changed particle pile demo into waterfall plus some tweaks

commit 46aef89
Author: Damian Schneider <[email protected]>
Date:   Tue Feb 13 06:47:35 2024 +0100

    Bugfix in particle push, now piling is working again

    particle pile-up did not work correctly, now fixed

commit dc5c58e
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 10 18:25:37 2024 +0100

    Fixed some bugs in particle system, runs much smoother now

    also tweaked some of the FX

commit 7c49f88
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 10 13:32:23 2024 +0100

    removed option for fastcolor add

    it made very little difference in performance, but for ESP8266 it may matter so it is set permanently there. graphically the difference is also very small (sometimes a particle gets brighter or less saturated)

commit da94d31
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 10 11:32:07 2024 +0100

    Improved collision handling (faster, less oscillations), changed variables to 32bit for faster calculation

    32bit variables are faster on ESP32, so use them whenever a variable is used a lot, it saves one instruction per access.

commit 8fe044e
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 10 08:14:34 2024 +0100

    added fix for piling oscillations

    untested, need to verify it works

commit f1ffbe0
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 10 07:35:45 2024 +0100

    improved collision efficiency

    improved efficiency for stackup (pushback), added code to correctly determine direction if particles meed (probably overkill but now its there)

commit e945faf
Author: Damian Schneider <[email protected]>
Date:   Fri Feb 9 20:30:26 2024 +0100

    collision detection is now a function plus some improvements & fixes

commit d00126b
Author: Damian Schneider <[email protected]>
Date:   Thu Feb 8 22:34:36 2024 +0100

    added option to use fast color add, may improve performance a little

    also fixed a bug in fire animation

commit 7d6965d
Author: Damian Schneider <[email protected]>
Date:   Thu Feb 8 21:50:51 2024 +0100

    bugfixes in impact animation

commit 18c79ce
Author: Damian Schneider <[email protected]>
Date:   Thu Feb 8 21:19:30 2024 +0100

    Added saturation to be set for each particle individually

    at the expense of more ram usage, animations now have more options for color control (already used in fireworks now)

commit a147a4b
Author: Damian Schneider <[email protected]>
Date:   Thu Feb 8 20:40:21 2024 +0100

    added angle emitter, added fireworks effect using it

commit 7bc59c6
Merge: 7bcfcb4 6dcd959
Author: Damian Schneider <[email protected]>
Date:   Thu Feb 8 18:34:16 2024 +0100

    Merge branch '0_15' into FXparticleSystem

commit 7bcfcb4
Author: Damian Schneider <[email protected]>
Date:   Thu Feb 8 18:33:00 2024 +0100

    bugfixes, attracot now works

    still unknown, why more than 256 particles are needed in memory allocation to not make it crash, but it works for now

commit cc98036
Author: Damian Schneider <[email protected]>
Date:   Wed Feb 7 19:48:54 2024 +0100

    added particle attractor, added two new FX but still buggy

    particle attractor animation does not work, somthing wrong with pointer allocation, it worked with static variables

commit 820d8dd
Author: Damian Schneider <[email protected]>
Date:   Tue Feb 6 12:44:48 2024 +0100

    added preliminary functions and FX

commit 3b82219
Merge: a7ef020 0003845
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 4 12:46:26 2024 +0100

    Merge branch '0_15' into FXparticleSystem

commit a7ef020
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 4 12:40:37 2024 +0100

    updated particle box and firework effects

    particle box now is more random in random mode (still a work in progress)
    firework is now more configurable by sliders

commit 520a6d5
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 4 10:39:01 2024 +0100

    Update platformio.ini

commit 6165083
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 4 10:20:42 2024 +0100

    added latest version of functions

    this somehow also got lost from an earlier commit

commit c42e759
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 4 10:17:08 2024 +0100

    reformat

commit 3e8d079
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 4 10:15:58 2024 +0100

    added collision handling back in

    update from another commit that got lost

commit c320b0a
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 4 10:13:54 2024 +0100

    cleanup

commit 2db3123
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 4 10:04:04 2024 +0100

    removed comments

commit 45f2616
Author: Damian Schneider <[email protected]>
Date:   Sun Feb 4 10:02:46 2024 +0100

    added particle FX animations

    not yet final version but working

commit 538ffdb
Author: Damian Schneider <[email protected]>
Date:   Sat Feb 3 10:45:34 2024 +0100

    Adding Particle System functions

    Basic Particle system defining particle structs, some emitters and particle to LED rendering
@blazoncek
Copy link
Collaborator

The latest push will not build successfully on ESP8266.

- cleanup / reformatting
- fixed volcano movement
- small bugfix for ESP32 (random() does not work, using random16() )
@DedeHai
Copy link
Collaborator Author

DedeHai commented May 7, 2024

I think it would be best to have a build flag to disable the particle system feartures - similar to WLED_DISABLE_2D.

I added WLED_DISABLE_PARTICLESYSTEM that can be used as a build flag.

center GEQ is a mix between the PS equalizer and vortex, tuned for AR. some more tuning may be needed, it can probably be extended and improved a little.
@blazoncek
Copy link
Collaborator

Please undo changes in platformio.ini and FX_fcn.cpp as they are irrelevant for this PR.

- fixed bug in center GEQ
- added '2D washing machine' mode for particle box
- improved color-change rate in ghostrider
- added AR to attractor (experimental, may remove again)
@blazoncek
Copy link
Collaborator

It's been a while...
I promise to take a second look when I get back from vacation next week.

@DedeHai can you check and update any outstanding issues until then?

**2D FX candidates for replacement**
- Fireworks 1D -> PS Fireworks (not a 1:1 replacement but similar)
- Ghost Rider -> PS Ghost Rider
- Blobs -> PS Blobs
- Fire 2012 -> PS Fire (note: there is no 1D replacement yet)
- Rain - 2D -> PS Ballpit, slow setting, no floor (very similar except dots are not fading)

**1D FX candidates for replacement**
- Bouncing Balls -> PS bouncing balls
- Rolling Balls -> PS bouncing balls with 'Rolling' enabled
- Dancing Shadows -> PS Dancing Shadows
- Drip -> PS DripDrop
- Fireworks 1D -> PS Fireworks 1D
- Fireworks Starburst -> PS Starburst
- Lighthouse -> PS Chase with 'Color by position', lowest density
- Popcorn -> PS 1D Spray with disabled bounce
- Rain: PS DriopDrop, 'Rain' check enabled, no splash, no blur, no gravity
- Solid Glitter -> PS Sparkler (not worth disabling, only a few bytes)

Some Notes:
- Glitter & Sparkle-> could be replaced with PS Sparkler with overlay OR with an additional FX that draws the background first, maybe not possible on ESP8266
- Juggle could be replaced but will not save much (but would add more options)
- Pride 2015 could be replaced by adding a 'pride' checkmark to PS Chase, woud save about 1kB
- Colorwaves -> could be replaced with PS Chase with additional color setting for hue change, similar to pride. Would save another 1kB
- Theater and Theater rainbow could be dropped -> PS Chase but it will not save much
- Chase 2 & Chase 3 -> PS Chase (width can not be set as high as originals), share a function with Theater, so all have to be disabled (would save about 600 bytes)
- 2D handling of some of the 1D replacements will be lost (like drip), I did not check all current FX in 2D
- Freqmap, Freqwave and Freqmatrix (2.2kB total) could be replaced with a single FX using the PS, would save about 1kB
- Blurring&Overlay only works if global buffer is enabled
- All PS effects are frame-time based, there may be significant speed differences to the original effects if they use timers (and if FPS are low)

Use these #defines to enable/disable PS or FX at compile time:
WLED_DISABLE_PARTICLESYSTEM2D
WLED_DISABLE_PARTICLESYSTEM1D
DISABLE_2D_PS_REPLACEMENTS
DISABLE_1D_PS_REPLACEMENTS
- PS Chase now has two more options to replace color waves and pride (work in progress, about 95% finished)
- PS Bouncing Balls now has larger particle size rendering option added (plus some improvements)
- some cleanup
@blazoncek
Copy link
Collaborator

You are doing something wrong when you are merging upstream into your fork.
You are messing commit history as it appears you are overwriting upstream files.

@DedeHai
Copy link
Collaborator Author

DedeHai commented Jul 6, 2024

You are doing something wrong when you are merging upstream into your fork. You are messing commit history as it appears you are overwriting upstream files.

it's probably the order I do this. I first pull latest to my working branch, then do a squash commit to the PR branch. so history is preserved in my working branch but gets messed on the squash commit. What is the proper way to do the squash? OR: can you live with it for now? I can do a final, correct 'release' PR once it is all ready.

@blazoncek
Copy link
Collaborator

then do a squash commit to the PR branch

Oh! You don't do that. Squash commit is only for the upstream PR. Squash commit strips all history.
We'll fix that later. I hope to get to it today or tomorrow.

@blazoncek
Copy link
Collaborator

Unfortunately the code is too big for my dev environment. Will need to strip something.

Flash: [====*** [checkprogsize] Explicit exit, status 1
======]  101.2% (used 1591370 bytes from 1572864 bytes)

@blazoncek
Copy link
Collaborator

@DedeHai a while ago I managed to do some testing and found:

  • Spray
  • Chase
  • Dancing Shadows
  • Fireworks 1D
  • Ghost Rider
    To behave somewhat odd and nowhere near original counterparts (if they have them).
    Still, it was just a brief testing.

The good thing is there were no crashes and all effects worked. The sad reality is that the code size is still huge.

@softhack007
Copy link
Collaborator

softhack007 commented Aug 13, 2024

Hi @DedeHai, thanks for making this cool feature availeable to WLED 😃

I've just started to try particlefx, and I'd like to work with you on the code to make it fit for merging into 0_15. Maybe we find a few optimizations wrt. speed or size, let's see..

Actually I'm a bit busy IRL for the next weeks, so my comments and proposals might come spread over time.

A few observations for a start

  • I think something went wrong with re-basing the PR to our 0_15 branch, maybe @blazoncek you could help out?
  • 1D effects do not work well in 1D2D expand mode "pixels" - often just the first 128 to 256 pixels (or so) get animated, the rest stays black.
  • some 2D effects do not use full panel height (tested on 64x64): ps fire, ps fireworks, ps volcano, ps equalizer
  • ps waterfall is a bit slow, maybe the default for "intensity" should be reduced.
  • speed and size: usually it better that local variables are only int or unsigned. In our experience with other effects, the 16bit and 8bit types make the firmware bigger and slower. I guess the reason is that the compiler has to emulate 8bit registers, so any op on 8bit or 16bit actually requires additional instructions to guarantee exact 8bit behaviour.

For discussion : the particle systems code seems to push some builds over the "100% program space" limits. I think we can do something for esp32 by using link-time optimizations (-flto). Not sure if it works with the "old" 3.x framework, too. The problem is 8266. 8266 uses -flto by default, so I don't see how to make room for the particle code on 8266. I would suggest to only enable particle effects on esp32 and variants, and not include them on 8266. @DedeHai @blazoncek what do you think?

@blazoncek
Copy link
Collaborator

blazoncek commented Aug 13, 2024

My first suggestion is to remove PixelMagic tool from the build. Then we can start optimising other stuff, but it is going to be a tough call if you want to include any usermods.

@softhack007 the problem is with squash commits that @DedeHai performed. IMO the best way to fix this will be to manually port modifications (using stashes and diffs) to a new branch or try to merge 0_15 normally into this branch. I can try the second method in a few days.

@DedeHai
Copy link
Collaborator Author

DedeHai commented Aug 13, 2024

Thanks for the feedback @softhack007, much appreciated.
Can't comment too much RN as I am on vacation.
1D effects are not as 'ripe' as 2D as I have limited testing capability (no long strips). Parameters of FX could use some fine tuning.
2D FX I tested up to 32x16 only, on larger ones CPU and number of particles (ram limit) may be insufficient and also need optimization.

@DedeHai
Copy link
Collaborator Author

DedeHai commented Aug 13, 2024

IMO the best way to fix this will be to manually port modifications (using stashes and diffs) to a new branch or try to merge 0_15 normally into this branch. I can try the second method in a few days.

I have my dev branch with correct history, I can create a branch from that and squash it properly next week.

@DedeHai
Copy link
Collaborator Author

DedeHai commented Aug 21, 2024

@softhack007 I am back. let me comment some more.
64x64 may be pushing it in general, for the particle FX to look good at least one particle per 2 pixels would be nice, but the total number is limited. I could easily increase it but then during transitions, FX assigned ram will be depleted. Currently I limited the maximum amount of particles such that at least to PS animations can run during transitions. If that is dropped, the amount can be doubled. Fire also does not look good on my 40x30 matrix, so I have plans to ditch that limit, not sure how transitions are going to look...
regarding 1D effects: any specific settings I should look at? also @blazoncek mentioned, some of the replacement effects do not look like the originals (they are a close match on my test setup).

Regarding code size: as I mentioned before, when looking at the elf file there seems to be room for optimisation, especially the 'printf' variants use quite a lot of flash, over 200k IIRC. maybe these can somehow be compacted.

@DedeHai
Copy link
Collaborator Author

DedeHai commented Sep 5, 2024

@softhack007 since flash space is still scarce I am thinking about moving the particle system into a usermod. That way it could be officially released as a beta version for more users to test.
If we later find a good way to reduce code size the UM could just be part of the standard build or it could be moved back. What do you think?

@softhack007 softhack007 added this to the 0.15.1 candidate milestone Sep 28, 2024
softhack007 referenced this pull request Sep 29, 2024
@softhack007
Copy link
Collaborator

I am thinking about moving the particle system into a usermod.

Hi @DedeHai, I think the more future-proof solution would be to change effect IDs from byte to uint16_t. This way we have enough room so that any usermod effects could get their own ID's, maybe we could even allow for "effect ID namespaces" where each usermod has it's own apportionment (using the usermod ID as part of the higher byte).

For a short term solution, just allowing uint16_t for effect ID's would enable us to go ahead without creating a dedicated usermod for particle effects. It should still be possible (my preference) to disable your effects at compile time, for custom builds where particleFX might be "too much" for a specific use case.

It would cost us one byte per segment, so in total of 32 bytes extra. Maybe the effect table needs a redesign, too.

@blazoncek @DedeHai what do you think?

@blazoncek
Copy link
Collaborator

For a short term solution, just allowing uint16_t for effect ID's would enable us to go ahead

The main issue are not IDs but flash use. Latest optimisations in #4138 and #4167 look promising to include PS into main branch as they are.

As for the future, effects are stored in vector, currently with gaps included, which may allocate a lot of RAM.

@netmindz
Copy link
Collaborator

netmindz commented Oct 2, 2024

If we change from byte to uint16 then we will also need to change the dmx code as effect mode is limited to 255.

I would be in favour of the change as with the Animatrix usermod enabled I think that already takes us up into the 240 effects range

You could also introduce the idea of "pages" so we have up to 255 effects per page and that page is a certain category of effect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants