1
\$\begingroup\$

How can I run a shader over the entire screen without interfering with other running programs? Specifically, I'd like to adjust the screen output with usability tweaks for my severely colorblind nephew. He has trouble playing certain games.

I'd like to avoid hooking into DirectX, and just run a shader over the entire screen. Is this something I can do in Windows without draining an unreasonable amount of resources?

I can use whatever language or tool is most practical for this, but I'm most comfortable with Java and HLSL.

\$\endgroup\$
5
  • \$\begingroup\$ This would involve drawing over every open window, which isn't the way windows works. Never seen this done. I doubt it'd be possible, but you never know. \$\endgroup\$
    – Ben
    Nov 5 '14 at 1:47
  • \$\begingroup\$ Darn. Would it be more viable to intercept a DirectX game before it gets sent to the monitor? \$\endgroup\$
    – Matthew G.
    Nov 5 '14 at 1:48
  • \$\begingroup\$ You probably wouldn't be able to from outside of the program. I'm fairly sure windows doesn't give access to the final screen buffer at all. \$\endgroup\$
    – Ben
    Nov 5 '14 at 1:53
  • \$\begingroup\$ stackoverflow.com/questions/2232727/… \$\endgroup\$
    – Ben
    Nov 5 '14 at 1:54
  • \$\begingroup\$ You might look into how tools like Fraps capture the screen, which may be a good starting point (although, Fraps does it in a kind of messy manner if I recall correctly). \$\endgroup\$ Nov 5 '14 at 13:00
2
\$\begingroup\$

if you are trying to make a screensaver for example, they most usually go with screen capturing one time, then create a fullscreen borderless window and draw over the picture they took. Some games where you "destroy your desktop" with a hammer and it breaks in glass fashion, or other effects, also works like that. Some virus/jokes, also do that.

If you want to apply a global effect that is always going to be there for all the session whatever the application, you would need to write a new window manager (dwm). Try linux first, probably easier. check xpenguins, or xsnow. (though they probably use lots of small windows).

\$\endgroup\$
1
\$\begingroup\$

For your specific use-case, Windows 10 actually has built in filters for the task. (I am fairly sure they would work on games as well).

This page has a quick tutorial: https://support.microsoft.com/en-us/windows/use-color-filters-in-windows-10-43893e44-b8b3-2e27-1a29-b0c15ef0e5ce

And this link should open settings to the correct page.

Or without clicking links: Go to Windows 10 Settings > Ease of Access > Color Filters

There are options for Deuteranopia, Protanopia, and Tritanopia.

\$\endgroup\$
3
  • \$\begingroup\$ Welcome to GDSE. OP doesn't appear to be asking about color-blindness filters; can you elaborate as to how this solves the problem of applying a shader (which could be implementing a variety of graphical effects other than filtering) to the screen? \$\endgroup\$
    – Pikalek
    Feb 26 at 2:36
  • \$\begingroup\$ OP mentions that this is their goal in the comments of another answer. They intend to use shaders to improve gaming for a color-blind individual. I agree a more general solution would be better, but there is not an obvious one at the moment. \$\endgroup\$ Feb 28 at 0:04
  • \$\begingroup\$ Thanks for responding. You are correct. The late answer review queue showed me your answer & the question, but not the other answers (and their comments). I've edited the question to include that key piece of information directly. \$\endgroup\$
    – Pikalek
    Feb 28 at 4:07
1
\$\begingroup\$

You've got a few options. It might not be sufficient for your needs, but the simplest way to affect the Windows desktop's colors would be to use MagSetFullscreenColorEffect. It lets you apply a 5x5 color transformation matrix.

Specifically for games, ReShade lets you apply your own shaders to a game's output. It can hook into Direct3D, OpenGL and Vulkan applications.

Lastly, a true desktop-wide solution is also possible. This can be achieved by hooking into DWM, copying dirty rectangles from the back buffer to a separate texture, then sampling that texture in a pixel shader that writes to the back buffer again. The only applications this won't work for are exclusive fullscreen ones, as those bypass the compositor. I've implemented this myself here for the purpose of color correction.

\$\endgroup\$
0
\$\begingroup\$

I don't really understand what is it that you're trying to do, but as far as I know, no, you can't do that.

Oversimplifying, each window draws to a different texture, and the Desktop Window Manager (DWM) composes all of those textures into one big full screen texture, which is what you see.

Generally, the DWM composition pipeline is a core part of Windows, and there are no documented ways that I know of to hook into it to mess with the composition. I am pretty certain this part is extremely optimized to run as fast as possible, and allowing people to hook into it would certainly create performance and stability issues.

It may be possible for a specific graphics driver to allow you to hook into the pipeline after composition has finished, but first: I don't know of any driver that would let you do that; and second: any program you make would only work on computers with that specific driver.

Without understanding what is it that you're trying to do, it's very difficult to give you alternate solutions, but if you want to create effects as screensavers do, you could do as v.oddou says: take a screenshot, and apply any modifications you wish to it, and then drawing it full-screen. Obviously, the displayed windows won't be interactive, since you're just showing a modified screenshot.

What is it that you're trying to do?

\$\endgroup\$
2
  • \$\begingroup\$ Specific tweaks for my severely colorblind nephew. He has trouble playing certain games. \$\endgroup\$
    – Matthew G.
    Nov 5 '14 at 23:35
  • \$\begingroup\$ It seems from this like the answer is more driver programming than shader programming... \$\endgroup\$ Feb 25 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.