From cf4d1b669eaa0257572f7b0a1fed0359a86038f3 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Fri, 22 Nov 2024 18:29:47 +0100 Subject: [PATCH] Changed smearing back to original code, adjusted FX and some improvements - smearing was introduced as a byproduct of my particle-system, it relies on smearing to be the way it was originally: this is in preparation of merging the particle system - adjusted the FX to accomodate the change - fixed bug in ripple FX not correctly blurring - added smearing option to Lissajous - improved blurring / smearing in crazy bees - added fade option to Squared Swirl --- wled00/FX.cpp | 35 +++++++++++++++++++---------------- wled00/FX_2Dfcn.cpp | 2 +- wled00/FX_fcn.cpp | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 47741131a1..460fd6b09d 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2552,8 +2552,11 @@ static uint16_t ripple_base(uint8_t blurAmount = 0) { uint16_t mode_ripple(void) { if (SEGLEN == 1) return mode_static(); - if (!SEGMENT.check2) SEGMENT.fill(SEGCOLOR(1)); - else SEGMENT.fade_out(250); + if(SEGMENT.custom1 || SEGMENT.check2) // blur or overlay + SEGMENT.fade_out(250); + else + SEGMENT.fill(SEGCOLOR(1)); + return ripple_base(SEGMENT.custom1>>1); } static const char _data_FX_MODE_RIPPLE[] PROGMEM = "Ripple@!,Wave #,Blur,,,,Overlay;,!;!;12;c1=0"; @@ -4982,7 +4985,7 @@ uint16_t mode_2Ddna(void) { // dna originally by by ldirko at https://pa SEGMENT.setPixelColorXY(i, beatsin8(SEGMENT.speed/8, 0, rows-1, 0, i*4 ), ColorFromPalette(SEGPALETTE, i*5+strip.now/17, beatsin8(5, 55, 255, 0, i*10), LINEARBLEND)); SEGMENT.setPixelColorXY(i, beatsin8(SEGMENT.speed/8, 0, rows-1, 0, i*4+128), ColorFromPalette(SEGPALETTE, i*5+128+strip.now/17, beatsin8(5, 55, 255, 0, i*10+128), LINEARBLEND)); } - SEGMENT.blur(SEGMENT.intensity>>(3-(SEGMENT.check1 * 2)), SEGMENT.check1); + SEGMENT.blur(SEGMENT.intensity>>(3-SEGMENT.check1), SEGMENT.check1); return FRAMETIME; } // mode_2Ddna() @@ -5027,7 +5030,7 @@ uint16_t mode_2DDNASpiral() { // By: ldirko https://editor.soulma SEGMENT.setPixelColorXY(x1, i, WHITE); } } - SEGMENT.blur(SEGMENT.custom1 >> (!SEGMENT.check1), SEGMENT.check1); + SEGMENT.blur(SEGMENT.custom1 >> 1, SEGMENT.check1); return FRAMETIME; } // mode_2DDNASpiral() @@ -5057,7 +5060,7 @@ uint16_t mode_2DDrift() { // By: Stepko https://editor.soulmateli SEGMENT.setPixelColorXY(colsCenter + mySin, rowsCenter + myCos, ColorFromPalette(SEGPALETTE, (i * 20) + t_20, 255, LINEARBLEND)); if (SEGMENT.check1) SEGMENT.setPixelColorXY(colsCenter + myCos, rowsCenter + mySin, ColorFromPalette(SEGPALETTE, (i * 20) + t_20, 255, LINEARBLEND)); } - SEGMENT.blur(SEGMENT.intensity>>((!SEGMENT.check2) * 3), SEGMENT.check2); + SEGMENT.blur(SEGMENT.intensity>>(3 - SEGMENT.check2), SEGMENT.check2); return FRAMETIME; } // mode_2DDrift() @@ -5108,7 +5111,7 @@ uint16_t mode_2DFrizzles(void) { // By: Stepko https://editor.so beatsin8(SEGMENT.intensity/8 - i, 0, rows - 1), ColorFromPalette(SEGPALETTE, beatsin8(12, 0, 255), 255, LINEARBLEND)); } - SEGMENT.blur(SEGMENT.custom1 >> 3, SEGMENT.check1); + SEGMENT.blur(SEGMENT.custom1 >> (3 + SEGMENT.check1), SEGMENT.check1); return FRAMETIME; } // mode_2DFrizzles() static const char _data_FX_MODE_2DFRIZZLES[] PROGMEM = "Frizzles@X frequency,Y frequency,Blur,,,Smear;;!;2"; @@ -5357,7 +5360,7 @@ uint16_t mode_2DJulia(void) { // An animated Julia set y += dy; } if(SEGMENT.check1) - SEGMENT.blur(128, true); + SEGMENT.blur(100, true); return FRAMETIME; } // mode_2DJulia() @@ -5386,11 +5389,11 @@ uint16_t mode_2DLissajous(void) { // By: Andrew Tuline ylocn = (rows < 2) ? 1 : (map(2*ylocn, 0,511, 0,2*(rows-1)) +1) /2; // "rows > 1" is needed to avoid div/0 in map() SEGMENT.setPixelColorXY((uint8_t)xlocn, (uint8_t)ylocn, SEGMENT.color_from_palette(strip.now/100+i, false, PALETTE_SOLID_WRAP, 0)); } - SEGMENT.blur(SEGMENT.custom1>>1); + SEGMENT.blur(SEGMENT.custom1>> (1 + SEGMENT.check1 * 2), SEGMENT.check1); return FRAMETIME; } // mode_2DLissajous() -static const char _data_FX_MODE_2DLISSAJOUS[] PROGMEM = "Lissajous@X frequency,Fade rate,Blur,,Speed;!;!;2;c1=0"; +static const char _data_FX_MODE_2DLISSAJOUS[] PROGMEM = "Lissajous@X frequency,Fade rate,Blur,,Speed,Smear;!;!;2;c1=0"; /////////////////////// @@ -5661,7 +5664,7 @@ uint16_t mode_2DSindots(void) { // By: ldirko http int y = sin8(t2 + i * SEGMENT.intensity/8)*(rows-1)/255; // max index now 255x15/255=15! SEGMENT.setPixelColorXY(x, y, ColorFromPalette(SEGPALETTE, i * 255 / 13, 255, LINEARBLEND)); } - SEGMENT.blur(SEGMENT.custom2>>3, SEGMENT.check1); + SEGMENT.blur(SEGMENT.custom2 >> (3 + SEGMENT.check1), SEGMENT.check1); return FRAMETIME; } // mode_2DSindots() @@ -5681,7 +5684,7 @@ uint16_t mode_2Dsquaredswirl(void) { // By: Mark Kriegsman. https://g const uint8_t kBorderWidth = 2; - SEGMENT.fadeToBlackBy(24); + SEGMENT.fadeToBlackBy(1 + SEGMENT.intensity / 5); SEGMENT.blur(SEGMENT.custom3>>1); // Use two out-of-sync sine waves @@ -5698,7 +5701,7 @@ uint16_t mode_2Dsquaredswirl(void) { // By: Mark Kriegsman. https://g return FRAMETIME; } // mode_2Dsquaredswirl() -static const char _data_FX_MODE_2DSQUAREDSWIRL[] PROGMEM = "Squared Swirl@,,,,Blur;;!;2"; +static const char _data_FX_MODE_2DSQUAREDSWIRL[] PROGMEM = "Squared Swirl@,Fade,,,Blur;;!;2"; ////////////////////////////// @@ -5824,7 +5827,7 @@ uint16_t mode_2Dspaceships(void) { //// Space ships by stepko (c)05.02.21 [ht SEGMENT.addPixelColorXY(x, y-1, color); } } - SEGMENT.blur(SEGMENT.intensity >> (3 - SEGMENT.check1), SEGMENT.check1); + SEGMENT.blur(SEGMENT.intensity >> 3, SEGMENT.check1); return FRAMETIME; } @@ -5874,8 +5877,8 @@ uint16_t mode_2Dcrazybees(void) { if (strip.now > SEGENV.step) { SEGENV.step = strip.now + (FRAMETIME * 16 / ((SEGMENT.speed>>4)+1)); - SEGMENT.fadeToBlackBy(32 + ((SEGMENT.check1*SEGMENT.intensity) >> 2)); - SEGMENT.blur(SEGMENT.intensity >> 1, SEGMENT.check1); + SEGMENT.fadeToBlackBy(32 + ((SEGMENT.check1*SEGMENT.intensity) / 25)); + SEGMENT.blur(SEGMENT.intensity >> (1 + SEGMENT.check1 * 2), SEGMENT.check1); for (size_t i = 0; i < n; i++) { uint32_t flowerCcolor = SEGMENT.color_from_palette(bee[i].hue, false, true, 255); SEGMENT.addPixelColorXY(bee[i].aimX + 1, bee[i].aimY, flowerCcolor); @@ -6220,7 +6223,7 @@ uint16_t mode_2Ddriftrose(void) { if(SEGMENT.palette == 0) SEGMENT.wu_pixel(x, y, CHSV(i * 10, 255, 255)); else SEGMENT.wu_pixel(x, y, ColorFromPalette(SEGPALETTE, i * 10)); } - SEGMENT.blur(SEGMENT.intensity >> (4 - SEGMENT.check1), SEGMENT.check1); + SEGMENT.blur(SEGMENT.intensity >> 4, SEGMENT.check1); return FRAMETIME; } diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index 94ea510498..8b9e0058bf 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -348,7 +348,7 @@ void Segment::blur2D(uint8_t blur_amount, bool smear) { const unsigned rows = virtualHeight(); const uint8_t keep = smear ? 255 : 255 - blur_amount; - const uint8_t seep = blur_amount >> (1 + smear); + const uint8_t seep = blur_amount >> 1; uint32_t lastnew; uint32_t last; for (unsigned row = 0; row < rows; row++) { diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index a7a94b4fa1..8be4652217 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1116,7 +1116,7 @@ void Segment::blur(uint8_t blur_amount, bool smear) { } #endif uint8_t keep = smear ? 255 : 255 - blur_amount; - uint8_t seep = blur_amount >> (1 + smear); + uint8_t seep = blur_amount >> 1; unsigned vlength = virtualLength(); uint32_t carryover = BLACK; uint32_t lastnew;