]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
use the correct sRGB conversion for the gamma ramps
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 21 Oct 2011 11:09:48 +0000 (11:09 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 21 Oct 2011 11:34:18 +0000 (13:34 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11456 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=a211e7328dfccde2ee4bc625cd84007335f0c3ce

vid_shared.c

index 8c417fa5a4043bc715838e3a70d5143a3795daef..a50bf7254641f130f650fc61cba7ed846a2b5a10 100644 (file)
@@ -1,6 +1,7 @@
 
 #include "quakedef.h"
 #include "cdaudio.h"
+#include "image.h"
 
 #ifdef SUPPORTD3D
 #include <d3d9.h>
@@ -1398,18 +1399,24 @@ unsigned int vid_gammatables_serial = 0; // so other subsystems can poll if gamm
 qboolean vid_gammatables_trivial = true;
 void VID_BuildGammaTables(unsigned short *ramps, int rampsize)
 {
-       float srgbmul = (vid.sRGB2D || vid.sRGB3D) ? 2.2f : 1.0f;
        if (cachecolorenable)
        {
-               BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[0]) * srgbmul, cachewhite[0], cacheblack[0], cachecontrastboost, ramps, rampsize);
-               BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[1]) * srgbmul, cachewhite[1], cacheblack[1], cachecontrastboost, ramps + rampsize, rampsize);
-               BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[2]) * srgbmul, cachewhite[2], cacheblack[2], cachecontrastboost, ramps + rampsize*2, rampsize);
+               BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[0]), cachewhite[0], cacheblack[0], cachecontrastboost, ramps, rampsize);
+               BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[1]), cachewhite[1], cacheblack[1], cachecontrastboost, ramps + rampsize, rampsize);
+               BuildGammaTable16(1.0f, invpow(0.5, 1 - cachegrey[2]), cachewhite[2], cacheblack[2], cachecontrastboost, ramps + rampsize*2, rampsize);
        }
        else
        {
-               BuildGammaTable16(1.0f, cachegamma * srgbmul, cachecontrast, cachebrightness, cachecontrastboost, ramps, rampsize);
-               BuildGammaTable16(1.0f, cachegamma * srgbmul, cachecontrast, cachebrightness, cachecontrastboost, ramps + rampsize, rampsize);
-               BuildGammaTable16(1.0f, cachegamma * srgbmul, cachecontrast, cachebrightness, cachecontrastboost, ramps + rampsize*2, rampsize);
+               BuildGammaTable16(1.0f, cachegamma, cachecontrast, cachebrightness, cachecontrastboost, ramps, rampsize);
+               BuildGammaTable16(1.0f, cachegamma, cachecontrast, cachebrightness, cachecontrastboost, ramps + rampsize, rampsize);
+               BuildGammaTable16(1.0f, cachegamma, cachecontrast, cachebrightness, cachecontrastboost, ramps + rampsize*2, rampsize);
+       }
+
+       if(vid.sRGB2D || vid.sRGB3D)
+       {
+               int i;
+               for(i = 0; i < 3*rampsize; ++i)
+                       ramps[i] = bound(0, (int)floor(Image_sRGBFloatFromLinear(ramps[i] / 256.0) * 65535.0 + 0.5), 65535);
        }
 
        // LordHavoc: this code came from Ben Winslow and Zinx Verituse, I have