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

Windowed gamma ramp ??? #439

Open
ghotik opened this issue Feb 27, 2025 · 2 comments
Open

Windowed gamma ramp ??? #439

ghotik opened this issue Feb 27, 2025 · 2 comments

Comments

@ghotik
Copy link

ghotik commented Feb 27, 2025

As everybody knows, the gamma ramp only applies to whole screens.
For this reason, by default, the gamma ramp control from a windowed application is disabled. In DxWnd I added a hack to force it anyway, but the effect spawns to the whole screen including the visible portion of the desktop, with unpleasant effects.
I was wondering if the gamma ramp directive could be intercepted by a ddraw/d3d wrapper (so far, this is surely possible) and remapped to something else (a pixel shader?) that could emulate the same behavior, but limited to the window surface.
Maybe the WDDM callbacks could support a feature like this?

@narzoul
Copy link
Owner

narzoul commented Feb 27, 2025

Sure, DDrawCompat already has that. It was added in this commit: 31444c3
The shader was since then merged into a bigger one, but I would recommend starting with this older commit instead.

The function to hook is D3DKMTSetGammaRamp. Store the ramp in a 256x3 texture (R, G, B in their own rows) and look it up in the shader. Simple enough, if you're already familiar with shaders.

@ghotik
Copy link
Author

ghotik commented Feb 27, 2025

Thanks, it is exactly the solution that I hoped to find. I'm not expert of shaders, but I suppose it's worth learning. Maybe as the first steps I could try some experimental sw implementation (ok, it seems crazy, but maybe a tiny window can afford it).
I'll let you know how it goes ...

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

2 participants