Gamma Ramp question
Can anyone explain to me how the Direct3D gamma ramp works? I'm a little confused on how it works. I know how to change and adjust it, but I don't understand it to the point where I can make my scene's fade in and out or flash a certain color. Thanks.
The gamma ramp is a remapping/lookup table. The values of the R,G, and B components of a colour are used as array indices to index into the gamma ramp table; the values read from the gamma ramp table are what gets displayed by the video hardware.
Think of it as working like this (except done by the hardware):
The input to the gamma ramp is an 8-bit value (i.e. in the range 0 to 255), and the output of the gamma ramp is a 16bit value (i.e. in the range of 0 to 65535); the reason for this is one of the reasons for gamma correction in the first place - human vision isn't linear, the output of a monitor/TV isn't linear, and 8 bits isn't enough to represent the range well enough (you need at least 12, which is what many RAMDACs use).
So to tint the output a certain colour, just tint all the entries in the gamma ramp by that colour, scaled by the position in the table; and to fade, just scale all the values in the table.
If you want to know more about gamma in general, Charles Poynton's site is an excellent resource: http://www.poynton.com/GammaFAQ.html
Think of it as working like this (except done by the hardware):
struct INPUT_COLOUR{ BYTE red, green, blue;};struct OUTPUT_COLOUR{ WORD red, green, blue;};OUTPUT_COLOUR ApplyGammaRamp( INPUT_COLOUR input, D3DGAMMARAMP gammaRamp ){ OUTPUT_COLOUR output; output.red = gammaRamp.red[ input.red ]; output.green = gammaRamp.green[ input.green ]; output.blue = gammaRamp.blue[ input.blue ]; return output;}
The input to the gamma ramp is an 8-bit value (i.e. in the range 0 to 255), and the output of the gamma ramp is a 16bit value (i.e. in the range of 0 to 65535); the reason for this is one of the reasons for gamma correction in the first place - human vision isn't linear, the output of a monitor/TV isn't linear, and 8 bits isn't enough to represent the range well enough (you need at least 12, which is what many RAMDACs use).
So to tint the output a certain colour, just tint all the entries in the gamma ramp by that colour, scaled by the position in the table; and to fade, just scale all the values in the table.
If you want to know more about gamma in general, Charles Poynton's site is an excellent resource: http://www.poynton.com/GammaFAQ.html
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement