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

Ambient + Custom colors effect for ROG Strix #1582

Merged
merged 16 commits into from
Nov 13, 2023
Merged

Ambient + Custom colors effect for ROG Strix #1582

merged 16 commits into from
Nov 13, 2023

Conversation

DLdota
Copy link
Contributor

@DLdota DLdota commented Nov 10, 2023

video_2023-11-10_00-37-42.mp4

Ambient effect use ~ 0.4% CPU.

I also rewrote USB.cs cuz it was mess

@seerge
Copy link
Owner

seerge commented Nov 10, 2023

@DLdota hello, thanks for PR, that's quite a lot of changes!

Honestly, the main reason I didn't add "ambient" RGB (or literally coloring keyboard into average or dominant color of the screen) is performance cost for that

You seem to have a powerful CPU, but when I try that on my G14 I get like 4-5% CPU usage constantly (which is really a lot)

Screenshot 2023-11-10 141925

I don't mind to merge it, but then it will have to be a veeery big asterisk that it will hamper performance significantly :| as otherwise it will be a shitstorm of topics and comments that "g-helper destroys someone's laptop" ...

@seerge
Copy link
Owner

seerge commented Nov 12, 2023

@DLdota so, I decided to dig into performance issues a bit more.

And it looks like screenshotting / measuring color is not the only thing that takes resources.

It is also a HidLibrary and whole USB communication itself. As with 80ms refresh time, even HeatMap mode (that you called "Heap" in your changes) also was taking 1-2% of CPU (which is still unacceptable)

I have migrated everything to HidSharp library instead, as it was already used for AnimeMatrix module (inherited from original implementation ) and it performs way better.

I have also did a split of AsusUSB into few separate classes, similar to what you did

It's already merged into main 5c45003

I may still look for faster / less taxing methods to do screenshots and measure colors, may be we can pull something out here actually.

@DLdota
Copy link
Contributor Author

DLdota commented Nov 13, 2023

@seerge Nice work!
HidDevice.Write is really strangely increased execution time by 40%.

And the current method can be optimized 2-3 times using STRETCH_DELETESCANS to get screen with a small resolution (300 or 400) pixels and then resize it qualitatively to 4x2.
I think the average CPU usage will be around 0.1% or less.

@seerge
Copy link
Owner

seerge commented Nov 13, 2023

@DLdota ok, good.

If you want - you can try to update your PR to match current implementation (with HidSharp) + use even lower screenshot resolution as you mentioned.

If you don't - let me know , and I will try to come up with something by myself

I have quickly looked into alternative ways to make screenshot using DirectX, but it requires including bunch of extra libraries in the app, and therefore increases total size by a lot. And I'm trying to avoid it atm.

@DLdota
Copy link
Contributor Author

DLdota commented Nov 13, 2023

Reduced CPU load to 0.15% (checked via ProcessHacker)

@seerge
Copy link
Owner

seerge commented Nov 13, 2023

@DLdota cool, but can you migrate your additions into current state of main branch (that uses HidSharp ) ? :)

@DLdota
Copy link
Contributor Author

DLdota commented Nov 13, 2023

Done!

@seerge
Copy link
Owner

seerge commented Nov 13, 2023

@DLdota good! this time it consumes something between 0.1-0.2 on 1600p display and 0.3% when 4k monitor is set as main in my case :) that will work.

Merging then. Thanks.

@seerge seerge merged commit 0f56883 into seerge:main Nov 13, 2023
@D9r31Y05
Copy link

When I set ambient mode on ROG STRIX G533ZW not all the keys all lighting up. The ones that are lighted up work fine in ambient mode and function as supposed. But the ones not working stays off all the time. When I switch to other lighting mode, all the keys are working fine.

@seerge
Copy link
Owner

seerge commented Nov 17, 2023

@D9r31Y05 can you post a photo of your keyboard?

How does Heatmap mode look on your device?

@D9r31Y05
Copy link

D9r31Y05 commented Nov 17, 2023

@seerge

HEATMAP HEATMAP
AMBIENT AMBIENT

@seerge
Copy link
Owner

seerge commented Nov 17, 2023

@DLdota I think that light zones that you used at

if (isStrix) //laptop with lightbar

Don't match with devices that support per-key RGB (as then each zone = 1 key, not a real "zone")

As far as I remember OpenRGB has separate protocol, to set backlight per real zone, not key. Do you mind to check that ? :)

I can't test anything of that as I simply don't own a Strix device.

@seerge
Copy link
Owner

seerge commented Nov 18, 2023

@D9r31Y05 can you check OpenRGB app and test if it allows you to set RGB colors there per Zone (not per key!) and if works for you there ?

Your keyboard is technically divided into 4 vertical zones. And each can light up all together instead of lighting up individually key by key.

@D9r31Y05
Copy link

@seerge I will check this out today and report back.

@D9r31Y05
Copy link

@seerge I tried OpenRGB app.

The only setting in the drop down menu zone working to change the color of the laptop and keyboard is all zones or keyboard zone. Lightbar or lid doesn't do anything at all. I can change color per key in the keyboard zone but nothing else. To change lid or logo or lightbar I have to change everything at the same time in keyboard or all zones. As you can see in the last 2 pictures I put the keyboard in purple and the lid and lightbar in green and blue but no change registered.

Screenshot 2023-11-18 150546
Screenshot 2023-11-18 150642
Screenshot 2023-11-18 150700
Screenshot 2023-11-18 151031
20231118_151042

@seerge
Copy link
Owner

seerge commented Nov 18, 2023

@D9r31Y05 oke, clear. Then it could be difficult to properly do multiple colors backlight for ambient mode on your device. As you need to send correct colors not to 4 zones, but to each button individually, and consider it's actual (physical) location on keyboard :) For me - it's almost unrealistic to do (as i don't even have a strix model), may be someone else can contribute

I can offer a "temporary" solution - to color whole keyboard into 1 average screen color. Same as G-Helper does now for all models w/o per-key RGB (like Zephyrus or Flow).

@seerge
Copy link
Owner

seerge commented Nov 18, 2023

@D9r31Y05 check this build

GHelper.zip

@D9r31Y05
Copy link

@seerge Tried it and same behavior. Some keys stay off no matter what is on the screen.

20231118_155843
20231118_160236

@D9r31Y05
Copy link

D9r31Y05 commented Nov 18, 2023

@seerge I tried the ambient effect added in OpenRGB with effect plugin. It is working as it should. Sampling my screen and using screen copy. All my keys and laptop zones are lighting up correctly and reacting to what is shown on the screen. The effect is getting applied per key. I think @DLdota is a contributor to the ambient effect in the OpenRGB plugin.

UPDATE: After further testing with OpenRGB Ambient mode, the effect works but there is a strobing flickering effect and the smoothness is nowhere as good as the Ambient effect implemented in G-Helper.

UPDATE 2: After further further testing the OpenRGB Ambient mode is now as smooth as the one in G-Helper. Cannot find how to reproduce the strobing flickering effect and the smoothness is now ok.

Screenshot 2023-11-18 174029
Screenshot 2023-11-18 174206

@seerge
Copy link
Owner

seerge commented Nov 19, 2023

@D9r31Y05 can you quickly check this build ? It should be only a single-zone Ambient, but I want to check if my attempt to set all RGB per key works ?

GHelper.zip

@D9r31Y05
Copy link

@seerge Tried it and all the zones and keys are the same ambient color reacting to the screen. It works like you want.

@DLdota
Copy link
Contributor Author

DLdota commented Nov 19, 2023

it's a lottery without information about led indexes.
anyway you can try : https://mega.nz/file/QA5ERShJ#K30Iy64JKaLNd20Uxnc6Tu57wkDIRH1hhCMwCD0sPkc

As far as I remember OpenRGB has separate protocol, to set backlight per real zone, not key. Do you mind to check that ? :)

I can't test anything of that as I simply don't own a Strix device.

almost the same. but It’s not clear which button corresponds to which led index.

@seerge
Copy link
Owner

seerge commented Nov 19, 2023

@DLdota @D9r31Y05 the indexes are actually known (from openrgb)

I have moved them, but I know need to group keys into something like 4 zones ....

static byte[] packetMap = new byte[]
:)

@DLdota
Copy link
Contributor Author

DLdota commented Nov 19, 2023

@DLdota @D9r31Y05 the indexes are actually known (from openrgb)

I have moved them, but I know need to group keys into something like 4 zones ....

static byte[] packetMap = new byte[]

:)

I dont think they are correct, cuz the screenshot shows that the lightbar zone didnt change color to green.
anyway i if I guessed right with indexes, then everything should work, and each button will have a unique color, if not, then Im afraid it may take 50 or 100 attempts, too much for me :(

@seerge
Copy link
Owner

seerge commented Nov 19, 2023

@seerge
Copy link
Owner

seerge commented Nov 19, 2023

@D9r31Y05 can you try this build and check if zones work ?

GHelper.zip

@D9r31Y05
Copy link

@seerge Yes I can clearly see different laptop lighting zones reacting to different color in my screen.

@seerge
Copy link
Owner

seerge commented Nov 19, 2023

@D9r31Y05 mind posting a couple of photos ? As I have created those zones by simply assigning each key manually. So I'm not sure if it looks ok ...

@DLdota question to you - does latest build (also updated main branch) look ok on your device with no per-key RGB ?

@D9r31Y05
Copy link

@seerge I am not able to test and post photo right now. I'll be able tomorrow. Sorry for the delay.

@DLdota
Copy link
Contributor Author

DLdota commented Nov 19, 2023

@D9r31Y05 mind posting a couple of photos ? As I have created those zones by simply assigning each key manually. So I'm not sure if it looks ok ...

@DLdota question to you - does latest build (also updated main branch) look ok on your device with no per-key RGB ?

broken, but i can fix it

@seerge
Copy link
Owner

seerge commented Nov 19, 2023

@DLdota well, i assume for your case led layout is just different (much less zones) :) if you can tweak it to also work for you that would be cool.

As per-key zones seem to work ok (just confirmed it in another issue) #1615 (comment)

I think your model is one of those

public static bool IsStrixLimitedRGB()
? You can probably add a switch then

@DLdota
Copy link
Contributor Author

DLdota commented Nov 19, 2023

@DLdota well, i assume for your case led layout is just different (much less zones) :) if you can tweak it to also work for you that would be cool.

As per-key zones seem to work ok (just confirmed it in another issue) #1615 (comment)

I think your model is one of those

public static bool IsStrixLimitedRGB()

? You can probably add a switch then

yes, very soon

@D9r31Y05
Copy link

@seerge Here are the screenshot of the zone reacting to the screen.

20231120_083623
20231120_083610

@D9r31Y05
Copy link

@seerge Here is a video of the ambient effect with zone with G-Helper.

20231120_090612.mp4

Here is the same video but with the ambient effect from Open RGB ambient effect.

20231120_090805.mp4

@seerge
Copy link
Owner

seerge commented Nov 20, 2023

Great, looks ok as for me

@D9r31Y05
Copy link

Yes thank you for fixing it!

@HaziqBD
Copy link

HaziqBD commented Nov 22, 2023

Just saying it here. I use a laptop with an extra monitor. The ambient mode uses the point of contact between my laptop screen and monitor for the keyboard colour. Basically where the edge of screen meet. Is it intended like that?

@seerge
Copy link
Owner

seerge commented Nov 22, 2023

@HaziqBD ambient mode makes a screenshot of your main display (in windows), and then sets keyboard to average color of the screen or 4 vertical zones on this screen (depending on what kind of backlight you have)

@HaziqBD
Copy link

HaziqBD commented Nov 22, 2023

@seerge ouh ok. Been wondering how it works. Thanks for the info

@lucidnx
Copy link

lucidnx commented Nov 22, 2023

Hello! It seems to be not working properly on G14 2022. Whole keyboard is white (1zone keyboard, that's okay), but it does not change colors, only intensity of white.
// EDIT, my bad, when trying fullscreen color, it works. maybe there should be function to pick most saturated colors from screen or gnore blacks/whites until it's covering 80% of screen, instead of mixing all together? keyboard stays most of time in black-to-white range. It's clear that it's not really made for 1 zone keyboards.

@DLdota
Copy link
Contributor Author

DLdota commented Nov 22, 2023

Hello! It seems to be not working properly on G14 2022. Whole keyboard is white (1zone keyboard, that's okay), but it does not change colors, only intensity of white. // EDIT, my bad, when trying fullscreen color, it works. maybe there should be function to pick most saturated colors from screen or gnore blacks/whites until it's covering 80% of screen, instead of mixing all together? keyboard stays most of time in black-to-white range. It's clear that it's not really made for 1 zone keyboards.

yes ur right, Due to excessive rapid compression, the black color eats other colors. need to do the compression like the 4-zone method and it will be noticeably better. i will make PR.

@seerge
Copy link
Owner

seerge commented Nov 22, 2023

@lucidnx try this build from @DLdota 's PR

GHelper.zip

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

Successfully merging this pull request may close these issues.

5 participants