Brightness of Screen

This topic is 4919 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I don't know if this goes with DirectX directly, but I know it directly has to do with game programming, so: how do you change the brightness of the screen so the user can see the objects better, in code? (using DX 9.0b and VC++ 6.0)

Share on other sites
You can adjust gamma pretty easily. Check out the DirectX docs for SetGammaRamp. You'll generally see this gamma option in most pc games.

But if it's true brightness you're after, I believe everyone has a brightness control on their monitor so they can use that...

Share on other sites
I've seen a lot of games coming out recently that have Brightness, Contrast, and Gamma controls. I wonder how they are tuning all of those? Some new DX9 features? Or are they processing each frame?

Share on other sites
"brightness" seems like an odd concept to me for most games. You can easily make stuff brighter by adding on values to the framebuffer. I guess this really just shifts the 'easily visible range' for the eye from the normal range down towards the dark areas. Surely this is not really a good idea for most games since darkness is often a tactical advantage.

I was talking to a guy the other day about this option for ps2 games. he said he'd implemented the 'brightness' option for a popular ps2 title by drawing an additive full screen quad over the entire frame.

I think monitor controls are good enough for most pc games. Even then you still get people 'cheating' whilst playing games by whacking up the brightness and contrast.

Share on other sites
Quote:
 Original post by AP"brightness" seems like an odd concept to me for most games. You can easily make stuff brighter by adding on values to the framebuffer. I guess this really just shifts the 'easily visible range' for the eye from the normal range down towards the dark areas. Surely this is not really a good idea for most games since darkness is often a tactical advantage.

See my comment below.

Quote:
 I was talking to a guy the other day about this option for ps2 games. he said he'd implemented the 'brightness' option for a popular ps2 title by drawing an additive full screen quad over the entire frame.

While this may lead to visually acceptable results, this is not how it should really work. This technique will offset the whole thing, which is equal to add an ambiant light (hey... he should have done this : simpler, and cheaper than another quad I think...). Brightness do not work like that. When you add some brightness to an image, you actually accentuate the difference between dark regions and enlightened regions. This need some multiply somewhere.

Image Processing By Interpolation and Extrapolation (Haeberli/Voorhies) presents a simple technique to do some basic image manipulation (brightness, tint, contrast, and so on). As I see it, the technique which is presented is simple to implement in a pixel shader.

Quote:
 I think monitor controls are good enough for most pc games. Even then you still get people 'cheating' whilst playing games by whacking up the brightness and contrast.

Most of the time, since the information is in the image, you cannot say that the player is cheating when he changes the brightness. Better : it seems that the programmer is cheating, because he wants to hide something to the player that would be obvious with enough light dynamics.

If (in real life) you cannot see the thing A, it is because your brain cannot make the difference between A and something which is behind A : colors and light intensity are too similar. Computer game should take this in account. If a computer want to hide something then it must use the same paradigm - and not the "if it is dark, users won't spot it" paradigm, which is (IMHO) flawed.

Regards,

Share on other sites
Quote:
 Brightness do not work like that. When you add some brightness to an image, you actually accentuate the difference between dark regions and enlightened regions.

That's contrast!

When I say cheating... I mean I've seen people playing Battlefield 1942 with the brightness and contrast right up on their monitor so that they can spot other players easier. I'd say that's cheating!

I'd say games simulating the exposure of the eye is an entirely valid thing to do in games. With more and more floating-point capable video cards coming on the scene, I expect to see games start to use HDR (and hence exposure) more and more. Having the exposure change as the player goes from a light to a dark place (or something like a flashbang goes off) could be a great gameplay ploy.

Share on other sites
Correct me If i am wrong..

But most proffesinal games control brightness by accessing the monitors drivers directly and modifiying the brightness of the monitor itself for the time while the game is running and then restore the settings when the game exits. I know that because i had a lot of cases with different games when they would freeze and i would have to manually end their process, and after i did the monitor brightness stayedl. I had to restart the computer to restore the regular settings.

Share on other sites
Quote:
Original post by AP
Quote:
 Brightness do not work like that. When you add some brightness to an image, you actually accentuate the difference between dark regions and enlightened regions.

That's contrast!

Not exactly. What I said was incomplete, but not false. Adding brightness to an image accentuate the difference between dark regions and enlightened regions, but it also enlight dark regions. The point is that brightness adds more light to bright region than to dark ones.

Quote:
 When I say cheating... I mean I've seen people playing Battlefield 1942 with the brightness and contrast right up on their monitor so that they can spot other players easier. I'd say that's cheating!

Looks like you lost a multiplayer party :D

This is the same thing as the famous rocket jump. The game allows me to do so, so I do it. As I see it, this is not cheating because you can do the same thing as me. If you don't want to do it (because the game is more eye candy or whatever), then this is not my problem. I will win. On a sidenote, if you do not want to do it, then you really understand what is the essence of a game, and I don't. So let me cheat, I'm still the looser :)

Quote:
 I'd say games simulating the exposure of the eye is an entirely valid thing to do in games. With more and more floating-point capable video cards coming on the scene, I expect to see games start to use HDR (and hence exposure) more and more. Having the exposure change as the player goes from a light to a dark place (or something like a flashbang goes off) could be a great gameplay ploy.

This will help, true :) The remaining is gameplay.

Regards,

Share on other sites
Quote:
 Original post by snisarenkoCorrect me If i am wrong..But most proffesinal games control brightness by accessing the monitors drivers directly and modifiying the brightness of the monitor itself for the time while the game is running and then restore the settings when the game exits. I know that because i had a lot of cases with different games when they would freeze and i would have to manually end their process, and after i did the monitor brightness stayedl. I had to restart the computer to restore the regular settings.

IIRC:

I'd say they change the video adapter gamma ramp. There is no feedback from the monitor, and a program cannot set monitor values. Monitor drivers are just there to inform Windows about VFreq, HFreq and so on.

If your video adapter allows you to manually change the gamma ramp, then you should not have to reboot your computer.

Regards,

Share on other sites
I've always used this code to increase/decrease gemma:
void AdjustGamma( int iGamma = 0 ) {	// iGamma: ranges from -255 to +255; negatives make the screen "darker"    	HDC hDC = GetDC(GetDesktopWindow());    	bool bMinus = iGamma < 0;    	if( bMinus ) iGamma = -iGamma;    	iGamma = min(max(iGamma, 0), 255);    	if( hDC ) {        		const int iNum = 256;        		struct sRamp {            			unsigned short wRed[iNum];            			unsigned short wGreen[iNum];            			unsigned short wBlue[iNum];        		} wRamp;        		if( GetDeviceGammaRamp(hDC, (LPVOID)&wRamp) ) {            			for( int i = 0; i < iNum; i++ ) {                				if( bMinus ) {                    					wRamp.wRed   = unsigned short( (255 - iGamma)*(i) );					wRamp.wGreen = unsigned short( (255 - iGamma)*(i) );					wRamp.wBlue  = unsigned short( (255 - iGamma)*(i) );				} else {                    					wRamp.wRed   = 65535 - unsigned short( (255 - iGamma)*(255 - i) ); 					wRamp.wGreen = 65535 - unsigned short( (255 - iGamma)*(255 - i) );     					wRamp.wBlue  = 65535 - unsigned short( (255 - iGamma)*(255 - i) );    				}        			}         			BOOL bRet = SetDeviceGammaRamp(hDC, (LPVOID)&wRamp);			if (!bRet) Log << " SetDeviceGammaRamp failed!\n";		}      		ReleaseDC(GetDesktopWindow(), hDC);   	}}

Share on other sites
You should be able to do all three, brightness, contrast and gamma by messing with gamma settings.

On an older system I've programmed for the gamma settings were done in 3 8bit lookup tables (one for each of reg, green and blue). Brightness is shifting the values in the table up or down (and clamping at the ends), Contrast is stretching the range (and clamping at the ends). Gamma is changing the numbers themselves.

It looks like things work similarily in DirectX (just with abstraction). If there's something like the OpenGL's ARB_imaging extension in DirectX, you could probably use that too.

Share on other sites

This is the same thing as the famous rocket jump. The game allows me to do so, so I do it. As I see it, this is not cheating because you can do the same thing as me. If you don't want to do it (because the game is more eye candy or whatever), then this is not my problem. I will win. On a sidenote, if you do not want to do it, then you really understand what is the essence of a game, and I don't. So let me cheat, I'm still the looser :)

haha. well it makes hiding in dark corners very hard! I only found this out when I walked around the office one day and noticed a load of people 'cheating' like that. My point is that I know we can't stop people doing that, but I'd at least like to prevent them from changing the exposure of the game itself so that they can see players more easily!

That's tantamount to them putting a filter over the screen which picks out other players in bright pink or something. It's not strictly cheating, but you know that if you provided such an option, loads of people would be using it to get an advantage. So I'd say, if you're not going to provide the 'pink filter of discovery' then don't let people screw with the exposure.

Well actually I think most people don't do the brightness thing (I know back in the day that it was also a big thing in Quake) so it doesn't bother me too much. It's just that allowing the player to radically alter the experience the developer has spent years working on seems a bit odd to me. Well... What can you do about monitor controls... not much I guess.