2-Dimensional ‘Blur’
This video shows the new ‘blur2d’ capability newly available on the FastLED 3.1 branch. Instead of clearing the matrix and drawing each frame on a clean canvas, the existing pixel data is just blurred a bit, and bright new pixels are drawn on top. The code (just 50 lines) is here https://gist.github.com/kriegsman/5adca44e14ad025e6d3b
The code is set up for the Smart Matrix, but it works about the same on any 2-D matrix. The amount of blurring here cycles from heavy to light and back again.
Since the blurring is (intentionally) slightly lossy in terms of overall light, the entire matrix automatically tends toward black. Look at the code and you’ll see that there’s no erasing or clearing at all – just blurring and drawing new pixels. Consider ‘blur’ just one more tool in your FastLED animation toolkit.
The coordinates of the six flying dots are calculated from just two out-of-sync sine waves generated with beatsin8. The “beatsin” functions take three main arguments: a Beats-per-minute speed, and a low value and high value for the output wave. In this case, the output wave is scaled to the size of the matrix, minus a border around the edge. I think that the code is mostly readable.
Oh, and for what it’s worth, there’s also a 1-dimensional version of blur (blur1d) for blurring light along a single LED strip.
I love the effect, but in the MatrixClock, a similar effect caused artifacts with the text - it got blurred just like everything else, and looked terrible. I wonder if it’s possible to have an overlay mode, where you can render a background like this, and have foreground elements unaffected by the blur.
to fast Mark , installed the new 3.1 fastled and it was fine …; only 2d blur does not work with more then 256 pixles … in my stetup … i do a special XY matrix with whole’s in the middel , a inverse sunglass … will modifie on my end . thanks
@Noel_Bundy : Just use 2 extra CRGBs (for background and foreground).
Manipulate both, copy the background into the CRGB leds first and add/copy the foreground pixelwise second - but only if the foreground pixel value is not 0x000000. So black means “transparent”. Blur the background, erase the foreground, repeat all. Does that make sense to you?
@hans_cromheecke : the smart matrix (shown) has 1024 pixels; so I think it does work with more than 256 at least in general.
@Andrew_Tuline : I actually have a different variation that I put on an 8x8; I’ll try to get that posted too. (Short version: set border to 0, use just four dots instead of six, and blur less overall – all changes to deal with the compacted space.)
@Stefan_Petrick : thanks for helping explain the mask/transfer idea! And there are a couple of 1-D and 2-D (and 3-D???) ‘video filters’ that I think you’ll be able to make use of if you don’t already have custom implementations from your own work!
@Noel_Bundy : another way to implement this would be to have a blur function that explicitly did NOT blur certain pixels, e.g., anything that matched the current clock-text-color.
If you’re tight on memory, another trick might be this: use the lowest bit of each color channel to signify whether the pixel is foreground or background. Zero means background (and thus blur-able), one means foreground (don’t blur me, bro). This requires some carful making and conditionals, but is an interesting technique to play with.
Fantastic as always! Thanks for sharing, Mark! @Stefan_Petrick has used similar fade and smear techniques to great effect in his “Funky Clouds” patterns, and inspired me to use them often. They make for very smooth fades and transitions between different patterns and effects.
+Noel Bundy we added exactly that feature in SmartMatrix 2.0 (along with gohufont, thanks to you). You could always scroll text in a separate foreground layer that is independent of the background layer that FastLED draws to, but now you can set individual pixels that won’t scroll
Our Aurora sketch uses the new foreground drawing feature to draw a clock overlay on top of FastLED patterns and Animated GIFs. See the code starting here:
thanks Marc , its because i have two sketch made up , one with text and one without ( or where i fake text with a image ) , and i’m struggling to make it work togehter … it was based on the RGB shade and the other on Smart matrix …
Pixelmatix: sweet! now I can just use the main branch instead of maintaining my own fork just for the fonts.
I think I’m gonna start on a whole new codebase for the clock, so I can take advantage of all the new tech. I might have to revisit my 3D library, see if I can sort out quads, as well. Which is harder than it seems.
Mark: I’ll have to try some of those ideas - a layer mask is a good idea. I’ll also look at fonts again - I have a nebulous idea that font loading could be managed a bit easier via includes and defines.