Re-creating a classic firefly effect

I’d like to replicate Fran’s Fireflies

as a layer to add to various base styles.

I’ve used it in older projects in the pre-neopixel days, and the pulse - hold - fade pattern is spectacular. I took a look at just using Sparkle in the editor but the effect isn’t the same. Can I get more control of these phases in the Sparkle effect?

I’d like the old physical prop with the firefly lights (hat) and the new proffie core physical prop (cane) to match if possible.

Also check her youtube channel for some interesting rare tech teardowns and rebuilds.

Any suggestions?

Hmm, I wonder if maybe the best way to do this would be to use MultiTransitionEffectL<> with EFFECT_USER1 or something. You would use it with a transition that creates one firefly at a location specified by EffectPosition<>. At the end of the transition (after a small random delay) you would run TrDoEffect<> to trigger another EFFECT_USER1 with a new random location.

Edit: This method would not be very efficient, so generating a large number of fireflies would potentially be very slow.

Come to think of it, you’ll need something to start the sequence, or there won’t be any fireflies. So you’ll need a TransitionLoopL<> which triggers EFFECT_USER1, and if you have that there is no reason to have another TrDoEffect<> inside the MultiTransitionEffectL<>

1 Like

The fireflies don’t have to be very high in number. I’m lost already but am willing to dig in and learn. Will return with questions :).

This kindof reminds me of my “lightning” effect I made. It is a secondary STYLE_OPTION_2 that can be overlayed onto another base style, it has randomized bumps with randomized timing.

I’ll try to explain the style code for you:

The top of the Layer is a TransitionLoopL, so continuously looping transitions.
Then TrConcat, cause it has multiple transitions.
Inside the first Concat, is a TrBoing, so it flips back and forth between a few transitions, another TrConcat that contains the individual effect, and then a TrDelay<> that uses Scale SlowNoise to randomize the delay between effects.

The Effect I used in TrConcat was TrFade, AlphaL with a Bump, and TrFade, so it faded in the bump, then faded out. You can probably add a TrDelay to make it hold the bump for a time as well.

So, something like…

TransitionLoopL<
	TrConcat<
		TrBoing<500, 3>,
		// The Effect
		TrConcat<
			TrFade<500>, // Fade In
			// Use AlphaL w/ Bump to make a small point on the blade.
			AlphaL<
				RgbArg<ALT_COLOR2_ARG, Rgb<127, 127, 0>>,
				Bump<
					RandomF, // Random Position
					Int<2000> // Size
				>
			>,
			TrFade<500> // Fade Out
		>,
		TrDelayX< // Delay Between Effects
			Scale< // Clamp a random value to within a certain range
				SlowNoise<Int<5000>>, // Randomized number, can use SlowNoise, BrownNoise, RandomF, etc...
				Int<200>, // Min time
				Int<1000> // Max time
			>
		>
	>
>
1 Like

Thanks! That is very nice I’m going to play with that in the editor.

For other code beginners like me who might be reading, delete the comma after Int<1000> when you paste into the editor.

whoops, fixed. Yeah I just kindof wrote that up by hand, sorry, it’s just psudo code going off memory.

Instead of Bump, you can also use SmoothStep, which has a different argument format (Size, then Position), and works a bit differently, but is similar. I tend to find Bump has better fade on the edges, smoothstep can be more hard edges.

OK, I’ve tried to follow your suggestions, read the POD and compare to BlackDragonN001’s suggestion and got to

StylePtr<MultiTransitionEffectL<TrConcat<TrWipe<50>,TransitionLoopL<TrConcat<TrFade<200>,TrDoEffect<TrFade<100>,EFFECT_USER1>,TrFade<200>>>,TrWipe<50>>,EFFECT_USER1>>()

And confess to be confused. Seem to have written some things tha add up to nothing.

How can I localize the effect to only a few LEDs in random locations, maybe 10 per blade? That seems like it should go in place of TrWipe<> (after TrConcat).

What exactly is EFFECT_USER1? Effects like blast are usually tied to some interface, like a button press, and therefore the prop. But in this case I think you’re implying that code sequence itself would trigger the effect, and not me doing something to the saber. Is that what I’m trying to do?

Side note: For fun I sent and email to Fran asking if she’d like to be involved, and she said “I don’t do code, cool project though!” I guess some engineers dabble in programming but ultimately stay analogue for life!

I was thinking something like this:

StylePtr<Layers<
  Black,
  TransitionLoop<AlphaL<Black,Int<0>>,TrDoEffect<TrDelay<500>,EFFECT_USER1>>,
  MultiTransitionEffectL<TrConcat<TrFade<3000>,AlphaL<Yellow,Bump<EffectPosition<>,Int<1000>>>,TrFade<3000>>,EFFECT_USER1,10>>>()

It doesn’t work correctly in the style editor though, not sure if it works correctly on an actual board or not.

1 Like

That is very kind, thank you! I’ll test it asap.

I did an initial test. The original physical prop is in there (the hat running Fran’s Fireflies) for comparison. Found a loose wire in it so two of the LEDs are not functioning.

I’ll try adjusting some values but any further suggestions are welcome and appreciated.

EDIT: The fade at the hilt is very nice during retraction. Looking for that smooth up, random hold, smooth down vibe…

Yeah, so that isn’t really working as intended either.

Would a sparkle or rain type line work? It doesn’t even necessarily need to be AudioFlicker, but that may or may not help with the visual queues.

I seem to remember @NitTheGrit having something really close to that, maybe he can chime in? Between @Fett263 and Nate there’s gotta be an existing example?

@LyleStyle POINTS FOR MENTIONING FRAN!! One of my kids loves her stuff.

1 Like

I figured out why it doesn’t work on the style editor:

Click here to show result

Now I just need to figure out why it doesn’t work on a Proffieboard.

1 Like

Looks perfect in the editor.

Same look as in the previous video on the Proffie 2.2, using OS7.14.

Tested, confirmed it looks the same as video above on the board.

I think I figured out the problem.
I have a fix checked in on github master.
Please give it a try.

1 Like

tested, it works now :slight_smile:

1 Like

That is a beautiful little style. Tested and confirmed working.

Thank you!

EDIT: Video added

Nice, guess I’ll have to release a 7.15 update soon with this fix in it. :slight_smile:

3 Likes