Brightness of Screen

Started by
10 comments, last by GameDev.net 19 years, 7 months ago
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)
Advertisement
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...
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?
"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.
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,
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.
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.
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,
Quote:Original post by snisarenko
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.


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,
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);   	}}

This topic is closed to new replies.

Advertisement