Jump to content
  • Advertisement
Sign in to follow this  
Sandeep

Setting Gamma.......

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all! I was trying to have a gamma setting slider to tweak it at runtime. Any ideas how to go about changing gamma values? Using - DX 9.0c Have to use SetGammaRamp....tried using it, no luck. Please let me know if i have to do anything different when in fullscreen or window modes. Thanks! Best, San

Share this post


Link to post
Share on other sites
Advertisement
Setting of the gamma values is very much hardware specific, and you need to check the D3DCAPS9 report to see if your card allows it.

iirc, post DX7 a lot of hardware/drivers dropped support for it - my GF256 at the time ceased to allow gamma under DX8 but was perfectly happy with it under DX7!

If you look at a lot of shader code floating around, people do some times include gamma correction as the final step in the px shader. Which may well be why quite a few top-level game engines "still" support gamma correction even if the D3DCAPS9 says the hardware doesn't like it.

hth
Jack

Share this post


Link to post
Share on other sites
Thanks Jack!
Do you have any idea how to use SetGammaRamp anyway? Have you got the damn thing working at all!!

Nothing happens.....i tried setting the RGB table to both extremes...nothing happened at all :(

And when i switched my app to fullscreen, it would get stuck in some infinite loop!

Still not able to get it working :(
Right now, our game scenes look dull, and i though i could pull it off by using some sort of gamma increase, or brightness enhancement at realtime.

Is there any other way to do it? Perhaps tweaks like brightness and contrast settings etc. at runtime?


Hmmm....dont tell me i would have to end up tweaking up every single texture!! Or maybe...push a dialog box at startup saying "Please pump up your monitor's brightness knob!!" :)

Best,
San

Share this post


Link to post
Share on other sites
Quote:
Do you have any idea how to use SetGammaRamp anyway? Have you got the damn thing working at all!!
The DXSDK is your best source of technical details. I personally haven't needed to use such things since DX7, so can't provide any examples. I base my knowledge on stuff I've read since then and my own experience going from v7->v8.

Quote:
Nothing happens.....i tried setting the RGB table to both extremes...nothing happened at all
If your hardware doesn't support it then no degree of trickery with the function calls will get you what you want. Have a look at the caps viewer or GetDeviceCaps() to do it at runtime.

Quote:
Is there any other way to do it? Perhaps tweaks like brightness and contrast settings etc. at runtime?
These all fall into the domain of post-processing effects, so do a bit of reading on the subject. A conventional way of doing this would be to render your scene and then render a TL quad over the entire screen and use blending/shaders to alter the final values (a D3DBLEND_ONE operation on a white/grey quad will brighten your scene considerably).

However, if your scene is so dull that you _require_ this post-processing type operation you may find problems later on with rendering artifacts. Scaling/modifying an 8bit/channel image can lead to horrible colour interpolations. Hence, if possible, do it per-pixel in a shader or simply change the lighting/texturing used by your game.

hth
Jack

Share this post


Link to post
Share on other sites
This is ridiculous if DX doesnt support gamma settings as this has been something which has been around since a very long time! SetGammaRamp does seem the way to go.

Thanks jolly......forgot to check the caps....will do that now and check again!

Per pixel TL quad maybe an option, but then, it increases my min hard specs - not so good

Thanks again!
San

Share this post


Link to post
Share on other sites
Quote:
This is ridiculous if DX doesnt support gamma settings
Minor technicality I suppose, but DirectX **does** support gamma ramps. it's the drivers/hardware that doesn't. Point the finger at ATI/Nvidia if anyone [grin]

Quote:
Per pixel TL quad maybe an option, but then, it increases my min hard specs
I wouldn't worry about it myself. If you use a shader to manipulate the image then yes, you've got a hefty specification jump. However, using the D3DRS_SRCBLEND and D3DRS_DESTBLEND operations with a full-screen TL quad shouldn't cause you too much damage.

Jack

Share this post


Link to post
Share on other sites
Hey Jolly!!

Got it working finally !! :)
Here's the function......in case you are interested :)

Thanks again,
San



// Gamma factor can be starting with 0.0 and up in steps of 0.1 to get your setting....
// do it right before begin scene call...should be fine...

void SetGamma(float GammaFactor )
{
D3DCAPS9 d3dCaps;
D3DGAMMARAMP NewRamp;
DWORD NewValue;
DWORD ui;
DWORD i;


//create linear gamma ramp
for( int i = 0;i < 255;i++ )
{
NewValue = i * GammaFactor * 255; ui = 0;
if(NewValue > 32767) { NewValue = NewValue - 32767; ui = 1;}
if(NewValue > 32767) { NewValue = 32767; }

//manipulate bits to handle unsigned integers
NewRamp.red = NewValue | (0x8000 * ui);
NewRamp.green = NewValue | (0x8000 * ui);
NewRamp.blue = NewValue | (0x8000 * ui);
}

//send gamma ramp to device
m_pd3dDevice->SetGammaRamp(0, D3DSGR_NO_CALIBRATION, &NewRamp);
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!