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

is there a possibility you can add more than just vibrance as an option? #8

Open
dragons4life opened this issue May 4, 2015 · 38 comments

Comments

@dragons4life
Copy link

Most Nvidia cards also have brightness and gamma, wondering if you can add those settings as an option.

@juv
Copy link
Owner

juv commented May 5, 2015

This will take some time to implement as the NVAPI is not a nice thing to work with ;-). I might get to it within the next two weeks. No promises though

@dragons4life
Copy link
Author

Thanks

@juv
Copy link
Owner

juv commented May 15, 2015

I've looked into this and it seems that you need a specific nda version of the NVAPI for this. I've contacted NVIDIA for this issue but it might take a while.

@dragons4life
Copy link
Author

Nice, thanks for trying.

@dragons4life
Copy link
Author

Guessing you couldn't implemented it, ty tough.

@juv
Copy link
Owner

juv commented Jun 12, 2015

I still don't have an answer from NVIDIA. No idea if they'll ever answer me.
Not the best support i've ever gotten tbh

@dragons4life
Copy link
Author

Same, they never replied back when I contacted them.

@atomGit
Copy link

atomGit commented Jul 15, 2015

"This will take some time to implement as the NVAPI is not a nice thing to work with"

tell me about it :)

i would also just like to add my vote to support gamma and brightness (if possible)

@juv
Copy link
Owner

juv commented Jul 20, 2015

I still don't have an answer on my ticket. I'll open another now.
Not sure if this will help but whatever. I have some spare time atm and could use it to work on vibranceGUI... I'll try to contact some NVIDIA people via twitter too.

@atomGit
Copy link

atomGit commented Jul 20, 2015

much appreciated - thanks

----- Original Message -----
Subject: Re: [vibranceGUI] is there a possibility you can add more than
just vibrance as an option? (#8)
Date: Mon, 20 Jul 2015 13:13:32 -0700
From: juvlarN [email protected]

I still don't have an answer on my ticket. I'll open another now.
Not sure if this will help but whatever. I have some spare time atm and
could use it to work on vibranceGUI... I'll try to contact some NVIDIA
people via twitter too.


Reply to this email directly or view it on GitHub:
#8 (comment)

@dragons4life
Copy link
Author

@juvlarN tough you were dead, thanks for trying homie.

@juv
Copy link
Owner

juv commented Aug 7, 2015

They didn't respond to me yet. I actually doubt they ever will.

@ledcaveman
Copy link

Am I right in assuming that you need the same specific nvapi version for contrast control as for gamma?

@dominikscheibe
Copy link

What about adding those features for AMD? This will hugely increase the value of the app. Thanks

@nalmeth
Copy link

nalmeth commented Dec 3, 2017

It's been two years - Do you think you could look into this again? According to a comment on this page there's a public (no nda required) version at the bottom of the page. I would really like to be able to use a brightness/gamma control.

@juv
Copy link
Owner

juv commented Dec 3, 2017 via email

@fragtion
Copy link

fragtion commented Dec 7, 2018

This app is basically perfect. But I'd love to be able to control gamma for specific apps as well (more gamma in csgo). Do we still face the same NVAPI limitations today?

@juv
Copy link
Owner

juv commented Apr 2, 2019

@fragtion still has not changed, just double checked for the latest version (r410)

@KingoftheWildHunt
Copy link

Still not possible?

@Horex
Copy link

Horex commented Jan 30, 2020

@juv

Hmm this is interesting: https://devtalk.nvidia.com/default/topic/1057935/nvapi/nvapi-nda-request/ Nvidia says that their control panel uses MSFT API directly.

Tried this app: https://github.com/cmdf/extra-gamma

Seems to work, but I need to unplug one of the monitors. I believe that first parameter in the SetDeviceGammaRamp function from ms api needs to point to correct monitor.

Ok, I found how to select monitor to change gamma on, didn't test it tho: https://stackoverflow.com/questions/34486842/how-to-change-the-gamma-ramp-of-a-single-display-monitor-nvidia-config

I also think "Other applications control color settings" should maybe be selected in nvidia control panel for this? hmm.
image

Maybe there is still hope! 👍
What do you think?

@juv
Copy link
Owner

juv commented Feb 1, 2020

@Horex

SetDeviceGammaRamp, SetMonitorBrightness and the other high level monitor configuration functions provided by Microsofts API are not really what is of interested for this project. They access and change the configuration of the actual physical device, e.g. your gaming monitor. This is an entirely different approach from what vibranceGUI is using in its current versions. The current design is to force the GPU to override certain settings and that's it. Changing this behaviour might lead to confusion when users expect the NVIDIA/AMD settings to be overriden but in fact their monitor settings are changed.

Also, I am pretty sure that the NVIDIA guy in their forums is wrong. The NVIDIA driver is capable of overlaying even more brightness/contrast/gamma on top of what is being set by the Microsoft API (or your physical menu on the monitor). So while there is a slight chance that there are some different Microsoft APIs that are being used by NVIDIA, I really doubt it.

I have tested the GetMonitorBrightness/SetMonitorBrightness functions and they reflect what my monitor displays when I access the physical menu of the monitor. The NVIDIA Control Panel can overlay even more. I have recorded a quick video of this. As you can see in the video, the brightness added by the NVIDIA driver (set by utilizing the NVIDIA Control Panel) is different from what is being reflected by the Microsoft APIs: https://imgur.com/EUJ0H7t
The "Other applications control color settings" option has no effect on this behaviour.

So while changing brightness/contrast/gamma might be achieved by using the Microsoft APIs, this might not really what we want. To sum up, it is possible to do this by using the Microsoft APIs but not the best solution and a workaround at best.

@Horex
Copy link

Horex commented Feb 1, 2020

@juv

Hmm, SetMonitorBrightness seems to change monitor settings. So this is not what we want.

This app was made back in 2002: https://www.majorgeeks.com/files/details/gamma_panel.html
It seems to work exactly as nvidia control panel, including Brightness, Contrast, and Gamma. This app can also change those settings per color channel. It does not change any of my monitor settings.

Now the question is how this 18 years old app is doing it. There must be some ancient MS API for this, somewhere.

EDIT: gamma panel and nvidia control pannel override eachothers settings. So this seems like a good indicator that those two apps are writing values to the same API, My best bet is that they are both using SetDeviceGammaRamp.

EDIT2: I found piece of code that converts gamma, contrast, brightness values into GammaRamp for SetDeviceGammaRamp function https://www.pcreview.co.uk/threads/adjusting-screen-contrast-through-c-code-programmatically.4038760/

@Horex
Copy link

Horex commented Feb 2, 2020

@juv

I created helper class in attachment to fiddle around with.

Example usage:

static void Main(string[] args) {
	int monitorId = 1; // 0 - means apply to all monitors
	double level = 50; // default 50
	double gamma = 10; // default 10
	double brightness = 50; // default 50
	double contrast = 50; // default 50

	SetDeviceGammaRampHelper.ApplyGammaRamp(monitorId, level, gamma, brightness, contrast);
}

SetDeviceGammaRampHelper.txt

It seems that NVIDIA is using slightly different scale for brightness and contrast.
We would need to get nvidia's math for calculating SetDeviceGammaRamp values. If we want to match it.
Not sure if we actually need to match scales exactly as nvidia to make it usable for games.

EDIT: Just confirmed that nvidia control panel is indeed changing values of GetDeviceGammaRamp, so that means nvidia is using MS API internally.

image

@falahati
Copy link

falahati commented May 26, 2020

Hey,

I am the developer of the HeliosDisplayManagement project and I was going to add the SetDeviceGammaRamp() function to my WindowsDisplayAPI library and since it is hard for users to work with this function I have decided to write a method to calculate the DAC lookup table (gamma ramp) that yields a similar result to the one used by NVidia. I am yet to commit this to my project but since this conversation was helpful, here is the final code that can be used to do so:

private static ushort[] CalculateLUT(double brightness = 0.5, double contrast = 0.5, double gamma = 1)
    const int dataPoints = 256;

    // Limit gamma in range [0.4-2.8]
    gamma = Math.Min(Math.Max(gamma, 0.4), 2.8);

    // Normalize contrast in range [-1,1]
    contrast = (Math.Min(Math.Max(contrast, 0), 1) - 0.5) * 2;

    // Normalize brightness in range [-1,1]
    brightness = (Math.Min(Math.Max(brightness, 0), 1) - 0.5) * 2;

    // Calculate curve offset resulted from contrast
    var offset = contrast > 0 ? contrast * -25.4 : contrast * -32;

    // Calculate the total range of curve
    var range = (dataPoints - 1) + offset * 2;

    // Add brightness to the curve offset
    offset += brightness * (range / 5);

    // Fill the gamma curve
    var result = new ushort[dataPoints];
    for (var i = 0; i < result.Length; i++)
    {
        var factor = (i + offset) / range;

        factor = Math.Pow(factor, 1 / gamma);

        factor = Math.Min(Math.Max(factor, 0), 1);

        result[i] = (ushort)Math.Round(factor * ushort.MaxValue);
    }

    return result;
}

A while back I used the source code of this project to add vibrance control to my project. So thank you for that. By the way, if you are interested you can check out my NvAPIWrapper to change settings on the monitor via I2C bus or to change HUE. I tried to support as much of nvapi as possible.

@juv
Copy link
Owner

juv commented Dec 25, 2020

@Horex I can't reproduce your observation that the Nvidia Control Panel is changing the values returned by GetDeviceGammaRamp(). Are there any extra steps you have taken?

When trying to reproduce it, I have basically added some quick-n-dirty code inside of the MonitorEnumProc method:

private static int MonitorEnumProc(IntPtr hMonitor, IntPtr hdcMonitor, ref NativeAPI.tagRECT lprcMonitor, IntPtr dwData)
{
	monitorCounter++;

	NativeAPI.RAMP ramp = new NativeAPI.RAMP();
	bool ret = NativeAPI.GetDeviceGammaRamp(hdcMonitor, ref ramp);
	string content = "";
	if (ret)
	{
		content += string.Join(",\n", ramp.Red);
		content += string.Join(",\n", ramp.Green);
		content += string.Join(",\n", ramp.Blue);
		File.WriteAllText("monitor" + monitorCounter + "-" + DateTime.Now.ToFileTime().ToString() + ".txt", content);
	}

	return 1;
}

Then I started the application, ran the code with default values in Nvidia Control Panel applied, then changed the values in the Nvidia Control Panel, and ran the code again. Two files get created with the content of the Arrays.
Afterwards, I compare those files with VS Code and Notepad++. And the files do match - hence the Nvidia Control Panel does not adjust the values reported by GetDeviceGammaRamp().

Just to make sure I'm not fiddling with some weird issue when joining those UInt16 arrays to a string, I've overriden the Equals and GetHashCode methods of the RAMP struct, but with the same result. Apparently the Nvidia Control Panel is not changing my monitors gamma ramp?

@falahati
Copy link

NVCP does use GetDeviceGammaRamp() in my tests as well.
Try using SetDeviceGammaRamp() to override it and see if it resets the NVCP settings applied on your monitor. Sometimes native methods related to stuff like this act crazy.

@juv
Copy link
Owner

juv commented Dec 25, 2020

Well, take a look here:

  1. I am calling the code of @Horex to adjust the brightness value to 100
  2. the brightness gets adjusted as expected
  3. I refresh in the Nvidia Control Panel to see if the values get updated / adjusted to the higher brightness value
  4. The brightness value in the NVCP is the same as before and when I adjust the slider in the NVCP, the screen gets even brighter.

Note that it does not matter if I close the Nvidia Control Panel after adjusting the brightness

I am running Nvidia driver version 460.89.

8nv2t5t.mp4

@falahati
Copy link

Oh yeah, I see the source of confusion.
The thing is, you can't get the raw values from the gamma ramp. So NVCP keeps these data in the registry. But it uses SetDeviceGammaRamp() to apply the final generated ramp.
So changing the gamma ramp directly won't change the values in the NVCP UI; in other words, it makes the NVCP UI show invalid values.

@falahati
Copy link

And the other thing about the screen becoming, even more, brighter is because the algorithm used by @Horex is different from the one used by NVCP. That's why ranges are different and that's why I wrote an algorithm that works like NVCP. You can try mine and you can see that the 100% when applied with NVCP is identical to 100% when using my algorithm.

@juv
Copy link
Owner

juv commented Dec 25, 2020

@falahati Interesting. Do you know of a way to read out the values that the NVCP is using from the registry? Maybe even set them? At a quick glance I've found that the key \REGISTRY\WC\Silo7290d152-ec65-20e2-7b84-1f67bd5e5fb7user_sid\SOFTWARE\NVIDIA Corporation\NVControlPanel2\RegisteredServers\DisplayPanelServer\AdjustDesktopColorSettings\ColorChannel is written to the registry which appears to be some kind of Application Hive?:
image

edit: this blog contains some more hints on what that special registry object is about 🤔:

This is a mount event of the virtual registry file of the package, done as a single event. Further virtual registry entries in the trace show the \Registry\WC\Silo_… path being used to access individual entries.

@murphlmao
Copy link

murphlmao commented Apr 19, 2021

@juv

I've actually fucked around with the registry trying to achieve the same result. My hypothesis was that it was editing the registry to change these color values, but thats unfortunately not the case. I copied a before and after of my registry to see if that would change the values, but unfortunately the only thing the registry does, in my case, is change the slider positions in NvCp. However, it is worth noting that I only tried about 5 different registry values, and I gave up very quickly.

Edit: Just saw this comment, ignore most of what I said about the registry above lol.

So NVCP keeps that data in the registry, uses SetDeviceGammaRamp() to apply the final generated ramp.
So changing the gamma ramp directly won't change the values in the NVCP UI; in other words, it makes the NVCP UI show invalid values.

I also have some notes that might be useful while I was researching this:

-It does not have any HARDWARE changes, it is purely Api based. It doesn't actually change the brightness or contrast of the monitor, 
-It is altering the color data before sending it to the monitor. My understanding is it works like a software LUT. You can see that 
    your backlight brightness doesn't change even when you turn brightness all the way down in the NVIDIA control panel.
-Nvidia game filter (freestyle) has the same color features, except that hooks into the memory of a game to achieve these changes.
 
-A project a long time ago called Pstrip actually has the same features as this:
https://www.entechtaiwan.com/util/ps.shtm
   (it has some fucking annoying timer thing, but after it's done go to Color Profiles -> Configuration , and you can see that it
uses some sort of LUT curve)
 
-In the README under history, it actually has a list of some of the shit he utilized and changed.

To read the output of the registry I used this:
https://www.nirsoft.net/utils/registry_changes_view.html
and
https://docs.microsoft.com/en-us/sysinternals/downloads/procmon
(You can add a filter to only monitor registry changes, whether that is every single registry change, or just the changes from a specific program. I generally started the capture right before I hit apply in NvCp, and then stopped capturing.)

If this could be added to VibranceGUI, which honestly does certainly seem possible, then that would save me, and many others a ton of time and stress.

If you, by some miracle, do figure this out and add it, thank you. Hope my research proves useful in one way or another. Keep us posted!

@willjsaint
Copy link

Suppose it's time for this issues yearly checkup?

@juv
Copy link
Owner

juv commented Dec 20, 2024

Hi all,

I have built a new beta version 2.5.0, based on this branch: #140

This includes color settings (brightness/contrast/gamma) 🥳

Please note:

  1. this feature is experimental as of right now
  2. this feature does not change the values you see in the NVIDIA Control Panel. It is not easy to change the values you see as NVIDIA is apparently doing some hard-to-reproduce shenanigans in the Windows Registry to make it work. This feature effectively uses the same Windows API that NVIDIA is using under the hood though and tries to mimic the NVIDIA values.

It would be great if you let me know how it goes for you.

You can download the pre-release .exe here:
https://github.com/juv/vibranceGUI/releases/tag/v2.5.0

@murphlmao
Copy link

murphlmao commented Dec 20, 2024

Hi all,

I have built a new beta version 2.5.0, based on this branch: #140

This includes color settings (brightness/contrast/gamma) 🥳

Please note:

  1. this feature is experimental as of right now

  2. this feature does not change the values you see in the NVIDIA Control Panel. It is not easy to change the values you see as NVIDIA is apparently doing some hard-to-reproduce shenanigans in the Windows Registry to make it work. This feature effectively uses the same Windows API that NVIDIA is using under the hood though and tries to mimic the NVIDIA values.

It would be great if you let me know how it goes for you.

vibranceGUI-2.5.0.zip

Dudeeeee. Ive literally graduated High School since I posted my above comment.

I will check this out tonight and report back.

Thanks a ton man.

@murphlmao
Copy link

Looks like there are a couple of issues:

  • I tested with Valorant in FullScreen.
  • When I made the profile in VibranceGUI, it did not apply to Valorant when I reopened Valorant. After adjusting the settings within VibranceGUI, the change applied to my secondary monitor, and only my desktop on my first monitor (where valorant was).
  • Closing VibranceGUI & Valorant did not reset the any of the settings for my monitors.
  • Restarting my PC did restore the default Windows color settings.

@murphlmao
Copy link

I don't think this was intended for Valorant.

Valorants anti-cheat vanguard etc., are top of the like software products, they have it easy to block this kind of software. You can't even move mouse programmatically or send virtual clicks to valorant (without custom driver interception and hardware spoofing, or additional middlemanning hardware with custom drivers), it's all blocked or detected and will get you banned.

For cs:go and similar average protected games, vibrance gui works, as those games are barely able to provide basic anti-cheat functionality, not even remotely compareable to where and what valorant is.

Your comment is based on a lot of misunderstandings of how anti-cheats actually work.

A) The anti-cheat guards ang

B) Changes to the Window's Registry gamma settings, which NVIDIA Control Panel also does, would not trigger an anti-cheat detection. If NVIDIA's calls to the MCAPI work, then there isn't any reason VibranceGUI wouldn't either. It's not like this application (nor NVCP) is making any sort of injection into the application itself, which could trigger anti-cheat detection, this is purely OS based.

It's like saying changing your resolution wouldn't be possible because of the game's anti-cheat.

The only difference is that VibranceGUI is process based. That is, detecting if a process is open. Based on my testing, and feel free to do your own, this feels like a process detection bug / potentially a permission issue.

@juv
After more testing (CS2 Fullscreen, Overwatch, Marvel Rivals, Minecraft), the Program Settings for each app never seem to apply. The only way I see display settings change is if I add the process, change the global values on the main menu, load the game, and then navigate back to my desktop, where the colors are then changed for only my desktop (not my game).

It also seems that the digital vibrance settings seem to work fine.

Some other weird behavior that I noted was that the log file only generated once for me. I uploaded that log with my comment. After that initial generation (which is when I first ran VibranceGUI, I believe), the log file did not generate at all after that. Noting the permission error in that log, I tried running VibranceGUI as an Administrator, which did not make a difference at all.

vibranceGUI.log

@juv
Copy link
Owner

juv commented Dec 22, 2024

I don't think this was intended for Valorant.

Valorants anti-cheat vanguard etc., are top of the like software products, they have it easy to block this kind of software. You can't even move mouse programmatically or send virtual clicks to valorant (without custom driver interception and hardware spoofing, or additional middlemanning hardware with custom drivers), it's all blocked or detected and will get you banned.

For cs:go and similar average protected games, vibrance gui works, as those games are barely able to provide basic anti-cheat functionality, not even remotely compareable to where and what valorant is.

No, vibranceGUI should work with any application running on your Windows OS. While there in theory might be some applications that forcefully override the settings made by vibranceGUI, there has not been a single application being reported to do so in this Github or my Twitter account. And vibranceGUI is totally fine to be used with/in Valorant and thousands of users have been using it in Valorant since Valorant's release. I myself played a few years of Valorant with vibranceGUI being active. VibranceGUI is not a cheat/hack kind of program. It automates a few GPU driver settings based on the application that is running in foreground.

My take is this: It's virtually the same as changing the driver settings manually every time and can not really give an unfair advantage. Now, with the recent addition of the color settings, this still remains true. Any player can increase the brightness/contrast/gamma settings on their pc somehow. vibranceGUI will just make it a bit easier.

You can read a more detailed breakdown on how this application works in this post from 8 years ago on reddit: https://www.reddit.com/r/GlobalOffensive/comments/502rha/comment/d71body/

@juv
Copy link
Owner

juv commented Dec 22, 2024

@juv After more testing (CS2 Fullscreen, Overwatch, Marvel Rivals, Minecraft), the Program Settings for each app never seem to apply. The only way I see display settings change is if I add the process, change the global values on the main menu, load the game, and then navigate back to my desktop, where the colors are then changed for only my desktop (not my game).

It also seems that the digital vibrance settings seem to work fine.

Some other weird behavior that I noted was that the log file only generated once for me. I uploaded that log with my comment. After that initial generation (which is when I first ran VibranceGUI, I believe), the log file did not generate at all after that. Noting the permission error in that log, I tried running VibranceGUI as an Administrator, which did not make a difference at all.

vibranceGUI.log

Thanks for giving it a try and sorry that it's not working as expected for you right now. Is it possible that you can reach out to me on Twitter via direct message? It would making debugging this issue you face a bit easier. My Twitter handle is linked on the README.md of this repo.

edit: just for my understanding, you did the following procedure?

  1. enable "Affect primary monitor only" (in case you don't want your other monitors to be changing in colors / digital vibrance)
  2. disable "Never change color settings" (to enable the new color setting feature)
  3. Keep Windows color settings in the main menu on the default level (50%,50%,1) to keep it simple for now
  4. Add an application to vibranceGUI, change ingame color settings to be different than Windows color settings
  5. tab into the application to make the settings take effect
  6. tab back into Windows to have them disabled again or, well, see your typical Windows colors

Note that the color change should happen really fast, you should not really see the in-game colors being applied on your Windows screen after alt+tabbing back to Windows.

And please can you add the following information:

  1. Windows version (press Windows key + R on your keyboard, type winver)
  2. GPU model
  3. GPU driver version

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

No branches or pull requests