mayingzhen / nvidia-texture-tools

Automatically exported from code.google.com/p/nvidia-texture-tools
Other
0 stars 0 forks source link

Custom color correction #39

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Add support for XBox-360 gamma curve. See:

Alex Vlachos, "Post Processing in The Orange Box," Game Developer's
Conference, February 2008

http://www.valvesoftware.com/publications.html

XBox approximates the gamma curve with a piecewise linear function. We
currently assume that the destination gamma space is exact.

Original issue reported on code.google.com by cast...@gmail.com on 21 Mar 2008 at 8:31

GoogleCodeExporter commented 8 years ago

Original comment by cast...@gmail.com on 21 Mar 2008 at 8:32

GoogleCodeExporter commented 8 years ago
As suggested in this thread:

http://developer.nvidia.com/forums/index.php?showtopic=1399

it would be great to support not only the XBox-360 gamma curve, but also the 
standard
IEC sRGB curve.

The formula for the conversion to linear to sRGB is:

if (isnan(cl)) {
    /* Map IEEE-754 Not-a-number to zero. */
    cs = 0.0;
} else if (cl > 1.0) {
    cs = 1.0;
} else if (cl < 0.0) {
    cs = 0.0;
} else if (cl < 0.0031308) {
    cs = 12.92 * cl;
} else {
    cs = 1.055 * pow(cl, 0.41666) - 0.055;
}

and the inverse:

     {  cs / 12.92,                 cs <= 0.04045
cl = {
     {  ((cs + 0.055)/1.055)^2.4,   cs >  0.04045

See:

http://www.opengl.org/registry/specs/EXT/texture_sRGB.txt

Original comment by cast...@gmail.com on 6 Apr 2008 at 9:44

GoogleCodeExporter commented 8 years ago
This is implemented now in trunk.

Original comment by cast...@gmail.com on 28 Oct 2010 at 5:46