2D antialiased graphics using OpenGL
Martijn Sipkema
msipkema@sipkema-digital.com
Thu, 11 Dec 2003 22:11:43 +0100
> > But how can one do compositing when gamma is not 1? AFAIK graphics
> > hardware expects a framebuffer with a gamma of 1, i.e. a smooth
> > shading will not render gamma corrected in hardware, right?
> >
> > I'd rather have convenient, fast rendering and suffer slightly worse
> > resolution in some color range. If 8 bit per channel is not enough,
> > then the hardware should provide more. OpenGL rendering clearly
> > expects a gamma == 1 framebuffer I think...
>
> What do you mean when you say 'a gamma of 1'? I don't think I
> understand your post.
>
> I render pixels in my application for sRGB, which uses a gamma of 2.2
> and a funky power function as a model of modern LCD panels and CRTs.
> This standard seems well accepted. How does this relate to 'a gamma of
> 1', are you saying that when I give pixels to OpenGL, that I should
> populate texture pixels as sRGB values, or that I should reverse my sRGB
> transform?
>
> Like, consider the case of taking any standard PNG file and loading it
> into a texture. What do you see happening ideally?
>From what I understand the sRGB color space color values should be
interpreted as voltages for a CRT monitor, which has a gamma of 2.2.
Thus if you copy an sRGB image to the framebuffer it will only be
displayed correctly if the graphics hardware interprets framebuffer RGB
values as voltage. This is the default for XFree86 I think, but you can
adjust
the framebuffer 'gamma' when the hardware supports this using xgamma, and
most hardware does.
If your CRT monitor has a gamma of 2.2 then setting the framebuffer 'gamma'
to 2.2 using xgamma will give correct output of the framebuffer if the
pixels in it
are to be interpreted as linear, i.e. describing the light intensity. This
means that
blending and smooth shading in OpenGL will work as expected.
If you need to display an image that is in the sRGB color space on a gamma
corrected framebuffer you'd need to convert it to linear RGB color space.
That's the way I understand it, please correct me if I'm wrong...
--ms