psieg / Lightpack

Lightpack and Prismatik open repository
GNU General Public License v3.0
1.54k stars 185 forks source link

Smoothing with Adalight devices #57

Open Cr4zyy opened 8 years ago

Cr4zyy commented 8 years ago

Is the smoothing blending between colours handled within Prismatik? If it is, is it then possible to expose the smoothing slider in Device options for Adalight devices? Testing an adalight device instead of a lightpack and the lack of smoothing seems harsh in some cases, maybe i can handle it on the adalight code side but wondering if this is a prismatik thing or not really.

psieg commented 8 years ago

Smoothing is a Lightpack device feature that defines in how many steps the actual LED color is adjusted to the desired color sent by the software. If the device does not have a such option, this can of course easily emulated in software. I'm not sure what you mean by adalight code side - it's probably easier to do it in Prismatik so as to avoid changing the interface

Cr4zyy commented 8 years ago

Ok, for the Adalight thing I was more implying I might be able to solve it in that code, rather than in Prismatik if it's not a simple solution.

psieg commented 7 years ago

Hey, can you try this build and check if it works? I don't have any non-Lightpack device available to test.

Cr4zyy commented 7 years ago

Hey this seems pretty good, truly appreciate the work!

I'm not sure the method you're using to do the smoothing but I guess it's a averaging the last x frames or the last x seconds worth of frames? Currently going to values of 60 or higher pretty much results in the same colour continuously. (my capture speed is roughly 30FPS all of the time)

Values of 1-10 or below achieve what I personally find the best (currently using 4).

The only issue is that some low values especially when blending between big ranges (white-black) have some quite noticeable steps in the blending and it seems slightly stuttery as a result. Not too sure you can get away with adding more steps in the same amount of time without increasing the data being sent but maybe lowering my capture could counter for that if at all possible. (I know my adalight device is very close to it's data limit at ~30fps)

Sometimes setting the smoothing to 0 a weird bug occurs where the backlight flashes rapidly, this doesn't happen every time and changing the value to something higher and going back to 0 seems to fix it most of the time.

This is certainly a great improvement though thanks!

Cr4zyy commented 7 years ago

Just a little update testing smoothing in-game (Overwatch) seems to behave differently to on-desktop and the updates become much slower if they even work at all. Not sure if that's related to smoothing or if something else was adjusted.

psieg commented 7 years ago

If you set smoothing to 0, does it happen too?

Cr4zyy commented 7 years ago

I managed to find another bug, I have a separate profile for Mood lamp mode (constant color selected), switching to it from a screen capture profile results in LEDs not updating to the mood lamp colour, smoothing on the mood lamp set to any value doesn't seem to help it requires a lot of mode switching for it to actually display correctly.

edit: The smoothing does actually appear to work in-game. Setting it to 0 works as expected, however it seems that even a value of 1 or 2 is blending a lot of colour information and just resulting in very similar colours. Seems that when playing either there are considerably more frames being captured and averaged for their colour (but the FPS in Prismatik still shows ~30FPS) or somehow it's taking frames over a longer time period. If i let OW sit on a menu screen the backlight shows correct colours but once i start playing the game very quickly the colours become indistinguishable and i just get a flat greyish average of the colours.

psieg commented 7 years ago

I think I found the source for the slowness problem. If you enable "send colors only if changed" it stops working on desktop as well. I tried increasing the update frequency to make things less notable but this does put more strain on the device. Note the FPS are the grab FPS and not the device send FPS. Software smoothing sends drastically more updates to the device. It looks good with the virtual device but I can't see what it looks like with yours. try this verison

Cr4zyy commented 7 years ago

Pretty sure I am hitting bandwidth limits for my device when using smoothing of any value if it runs for long enough. Although, not sure if this is the way prismatik/windows/adalight device handle the serial data.

I started monitoring the serial data, at capture rates of 30ms/~30fps with no smoothing prismatik sends packets the size of 686 bytes (avg 20000 bytes/s). Once smoothing is enabled packet sizes will continue to grow until they peak at 32693 bytes, this results in data peaking at 69462 bytes/s.

Here is a paste of the 686byte data http://pastebin.com/74RjkLJP and one of the 32693byte, which clearly contains multiple Ada headers http://pastebin.com/V4hpiFj8

So this is probably where most of the lag I encounter is coming from. Although I don't know if this can be fixed in prismatik at all or if it's down to the way adalight functions on my device.

LoadedScissors commented 7 years ago

With regards to smoothing, I found you can spatially smooth for a very good effect with boblight. Each LED shows the colour for its own respective space in addition to 50% (adjustable) of the space from each neighbouring LED. This has the effect of minimising the impact of any small features within a given capture area. I found this gives a much nicer effect than temporal smoothing, ymmv.

twistedminddnb commented 7 years ago

I have an Arduino Uno R3 (original) and adalight protokol.

In Prismatik I cannot see the smoothing slider.

I use an rewritten adalight sketch since the original one did not work. I have tried a few more but never can I see the smoothing setting in prismatik.

Could it be that the sketch is the problem?

or what does prismatik need to show the slider?

psieg commented 7 years ago

At this time smoothing is only supported with Lightpack devices (which do the smoothing). Software-side smoothing logic in Prismatik is not implemented. I wasn't really happy with the PR implementation so I did not merge it. If you want, you can check out that branch and build it yourself

sraka1 commented 2 years ago

@psieg is this still open for PRs? Really bummed by the lack of smoothing on my Adalight device

psieg commented 2 years ago

Sure, feel free to send one (or fork the draft I have open)