Game Development Community

Gamma correction

by Isaac Barbosa · in Torque Game Builder · 06/09/2008 (9:19 am) · 9 replies

Hello,

I found the VideoSetGammaCorrection topic/method included on TGB documentation.... but there is no explanation on how to use it. Can somebody tell me about the method?

I've tried

function gamacorrection::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
SetGammaCorrection(0.5);
}

but nothing happens...

Thanks

#1
06/09/2008 (12:55 pm)
It looks like the function call is actually videoSetGammaCorrection(). From the source:
ConsoleFunction(videoSetGammaCorrection, void, 2, 2, "( gamma ) Use the videoSetGammaCorrection function to adjust the gamma for the video card.\n"
																"The card will revert to it's default gamma setting as long as the application closes normally\n"
																"@param gamma A floating-point value between 0.0 and 1.0.\n"
																"@return No return value.")
#2
06/09/2008 (2:18 pm)
@ Ken,

Thanks for the info. So there is no way player can adjust the brightness of the game manually using the gamma correction?

is there a way to achieve that?

Thanks
#3
06/10/2008 (11:55 am)
I have searched the whole documentation and there is nothing about this topic. So, somebody knows a way to make this possible?

I'm planning to use a minus button to decrease brightness and one plus button to increase it, if possible.

Thanks
#4
06/10/2008 (12:10 pm)
@Isaac - Let me chime in here for a minute.

I looked into your inquiry about the gamma correction in TGB. I looked this function up on the TDN. The function is also described in the offline documentation for TGB 1.7.2. It is not described in 1.7.3 (I'll explain why in a minute)

The function videoSetGammaCorrection, is indeed a ConsoleFunction that exists in both TGE and TGB.

The function takes in a floating point value between 0.0 and 1.0.

Script Example:
// Less than 0.5 makes it darker
// More than 0.5 makes it brighter
function increaseGamma(%val)
{
       videoSetGammaCorrection(%val);
}

This will actually change the gamma correction for your video card itself. So, if you are running a windowed application, your entire screen (or both screens if you are sporting dual monitors) will react to the correction.

If you want your gamma to be cranked to its highest (ultra bright), input 1.0. Try this out in TGE and see what happens. When you change it back to 0.5 (standard), or quit the application, your gamma goes back to normal.

So, why is this not in the TGB 1.7.3 docs? I tried to use this function in TGB, and received no reaction. You might want to check the bug posts in the TGB forums to see if this is a known issue.

I hope this explanation helps =)
#5
06/10/2008 (1:38 pm)
I'd like to echo what michael just wrote: This will actually change the gamma correction for your video card itself. So, if you are running a windowed application, your entire screen (or both screens if you are sporting dual monitors) will react to the correction.

i've found this to be fairly rude from the user's point of view: one application changing the gamma for all applications. i've also encountered situations where the app may not restore the original gamma properly.

if you're able to recompile the SDK, and have some spare frames/second,
i'd recommend using the sgExposureFilter instead.
#6
06/11/2008 (7:56 am)
Thanks for the explanation. I guess I will not use the gamma correction, anyway, it doesn't seems to work using this code

[code]function increaseGamma(%val)
{
%val = 0.5;
videoSetGammaCorrection(%val);
}
function gamacorreccion::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
increaseGamma();
}[code]
#7
06/11/2008 (8:00 am)
@Isaac - Well, like I said, it does not appear to have functionality in TGB. It may be a deprecated function that had it's ConsoleFunction left in.

Not trying to be nit-picky, but if it did work you would want your code to look like this:

function increaseGamma(%val)
{
      %val = 0.5;
       videoSetGammaCorrection(%val);
}

function gamacorreccion::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
      [b]// Calculate change amount here based on your own method[/b]
       %changeAmount = -1; // <== Change this

       increaseGamma(%changeAmount);
}
#8
06/11/2008 (8:55 am)
@Michael,

Thanks for the clarification. SO I LEAVE GAMMA ON PEACE! :)
#9
06/18/2008 (3:24 pm)
I complained about this awhile back. It's in the documentation but unfortunately it doesn't work. :(