]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
experimental q3map2 command line option: -sRGB (store lightmaps in sRGB)
authorRudolf Polzer <divverent@xonotic.org>
Fri, 21 Oct 2011 15:19:52 +0000 (17:19 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 21 Oct 2011 15:25:09 +0000 (17:25 +0200)
22 files changed:
tools/quake3/q3map2/game__null.h
tools/quake3/q3map2/game_darkplaces.h
tools/quake3/q3map2/game_dq.h
tools/quake3/q3map2/game_ef.h
tools/quake3/q3map2/game_etut.h
tools/quake3/q3map2/game_ja.h
tools/quake3/q3map2/game_jk2.h
tools/quake3/q3map2/game_nexuiz.h
tools/quake3/q3map2/game_prophecy.h
tools/quake3/q3map2/game_qfusion.h
tools/quake3/q3map2/game_quake3.h
tools/quake3/q3map2/game_quakelive.h
tools/quake3/q3map2/game_reaction.h
tools/quake3/q3map2/game_sof2.h
tools/quake3/q3map2/game_tenebrae.h
tools/quake3/q3map2/game_tremulous.h
tools/quake3/q3map2/game_wolf.h
tools/quake3/q3map2/game_wolfet.h
tools/quake3/q3map2/game_xonotic.h
tools/quake3/q3map2/light.c
tools/quake3/q3map2/light_ydnar.c
tools/quake3/q3map2/q3map2.h

index c2f248498cce783c11c795a63906eb134ec7d922..0bc61e3a894647e19aa56b2061f206f479d3ec78 100644 (file)
@@ -63,6 +63,7 @@ game_t struct
        qfalse,                 /* wolf lighting model? */
        0,                      /* lightmap width/height */
        0,                      /* lightmap gamma */
+       qfalse,                 /* lightmap sRGB */
        0,                      /* lightmap exposure */
        0,                      /* lightmap compensate */
        0,                      /* lightgrid scale */
index e91fdb764d149d158cc17854d9c20051f401bc75..653beb101b4a3bef02fef7165155c3a103ac75a5 100644 (file)
@@ -54,6 +54,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        200.0f,                         /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        0.3f,                           /* lightgrid scale */
index 97d2d6d564e369d2f140bb3e928354c2e7709100..3d6cfe4922b6cfb2ebeb3adfb5915a384bdc3374 100644 (file)
@@ -54,6 +54,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.2f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        200.0f,                         /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        0.3f,                           /* lightgrid scale */
index 84ea664cb5d0ca06eb688e4e08991fc88b712f3d..4c08ab09a914f1133b81149077c5e39f97d7dbf7 100644 (file)
@@ -113,6 +113,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 8add5bbe09a78a221559536d92ce5309d5809bc9..ff791620f786db4708439747587a4c673d1a3d67 100644 (file)
@@ -147,7 +147,8 @@ game_t struct
        "flareshader",          /* default flare shader */
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
-       2.2f,                           /* lightmap gamma */
+       1.0f,                           /* lightmap gamma */
+       qtrue,                          /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 3d25129edffe929a85cde8698d0036de7a68862b..7f4a5fcc333b9e4ea88d5508f139678f84816dbb 100644 (file)
@@ -67,6 +67,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 056baf015bfb64e18f01956146a0590c733ede1e..30bb3d3b7d894d9a9c9f0414695722a2a308e058 100644 (file)
@@ -64,6 +64,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 4d496c339c25993b6375018525936ee2791069ac..8e0785d9022723bcd6f7722cbd6732ee40021a61 100644 (file)
@@ -63,6 +63,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 60e299d372487f18da67b9e5f070b549f64dae41..a1a4c4b5a2c6051835beb14d99cb62e8af3549d0 100644 (file)
@@ -54,6 +54,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        200.0f,                         /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        0.4f,                           /* lightgrid scale */
index 7645ad0a384556939af78e8a8c41a43c8fcae43a..0fd336c6cbb56b688422215579d1351f6bf4eea8 100644 (file)
@@ -115,6 +115,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        512,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 98d4c4b8245c1481e76211a853853abbc253d761..be09468df0ed2d8e9df792233a5952753ddb4a6e 100644 (file)
@@ -112,6 +112,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 1a509272b3a80c88ca9408485d64ac0046da33ca..a9425a8f9044b3c6db449bd62f8d55f205b42edc 100644 (file)
@@ -64,6 +64,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index c81e72455563f8694f840abf072c5ccf0643f954..97b01c4806e9574f46f0c14562fd4f8114fee596 100644 (file)
@@ -84,6 +84,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 931ec69c640c47e96e12ab88826afe4e6b79d4c4..e7453f8d8f758e3eb5bba0b517522b8e373eaa77 100644 (file)
@@ -139,6 +139,7 @@ game_t struct
        qfalse,                                 /* wolf lighting model? */
        128,                                    /* lightmap width/height */
        1.0f,                                   /* lightmap gamma */
+       qfalse,                                 /* lightmap sRGB */
        1.0f,                                   /* lightmap exposure */
        1.0f,                                   /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index ab3121587f4dbc4a38011bc9081b6a906785dbae..2117aa45e2a1eff11a02f7a87df218458de9fa91 100644 (file)
@@ -112,6 +112,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        512,                            /* lightmap width/height */
        2.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 5d4226291883e4693e3ec9a83dfa09fb25cec7e9..9a1cb7969c37286d8075f1af9f47c3610666f421 100644 (file)
@@ -70,6 +70,7 @@ game_t struct
        qfalse,                         /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 157bfe3ae8897570b1413f336b3e9be5de121448..fc55c884b0335cf3281a2391e4cb82e43b4a835c 100644 (file)
@@ -129,6 +129,7 @@ game_t struct
        qtrue,                          /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 3495f0dcfc6ba67ab4a220ac05251f70fd446c3e..fdda4d95c6cfaed47eb5677ba66aa172988398d4 100644 (file)
@@ -66,6 +66,7 @@ game_t struct
        qtrue,                          /* wolf lighting model? */
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
+       qfalse,                         /* lightmap sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 568c263e8d36075d9b19abf6dbce9fa3800de0e8..83d7715f6d634408616e585827922330c1979779 100644 (file)
@@ -63,6 +63,7 @@ game_t struct
        qfalse, /* wolf lighting model? */
        128, /* lightmap width/height */
        1.0f, /* lightmap gamma */
+       qfalse, /* lightmap sRGB */
        1.0f, /* lightmap exposure */
        1.0f, /* lightmap compensate */
        1.0f, /* lightgrid scale */
index 5d5dfc5e9aa4cdb77bbd646fb4ec1d6cf4a2c7a8..25b5a87cce1af23494ec1cd67eecee1606eac95c 100644 (file)
@@ -2065,6 +2065,12 @@ int LightMain( int argc, char **argv )
        lightmapGamma = game->lightmapGamma;
        Sys_Printf( " lightning gamma: %f\n", lightmapGamma );
 
+       lightmapsRGB = game->lightmapsRGB;
+       if(lightmapsRGB)
+               Sys_Printf( " lightmap colorspace: sRGB\n" );
+       else
+               Sys_Printf( " lightmap colorspace: linear\n" );
+
        lightmapCompensate = game->lightmapCompensate;
        Sys_Printf( " lightning compensation: %f\n", lightmapCompensate );
 
@@ -2204,6 +2210,13 @@ int LightMain( int argc, char **argv )
                        i++;
                }
                
+               else if( !strcmp( argv[ i ], "-sRGB" ) )
+               {
+                       lightmapsRGB = qtrue;
+                       Sys_Printf( "Lighting is in sRGB\n" );
+                       i++;
+               }
+               
                else if( !strcmp( argv[ i ], "-exposure" ) )
                {
                        f = atof( argv[ i + 1 ] );
index f291e7a5871da5303bceeb9bb8fc688f1401026a..09a8e484090463a80981b0a1bc6d6037f92c05f5 100644 (file)
@@ -44,6 +44,7 @@ ColorToBytes()
 ydnar: moved to here 2001-02-04
 */
 
+#define Image_sRGBFloatFromLinear(c) (((c) < 0.8014848f) ? (c) * 0.05046875f : 1.055f * (float)pow((c)*(1.0f/256.0f), 1.0f/2.4f) - 0.055f)
 void ColorToBytes( const float *color, byte *colorBytes, float scale )
 {
        int             i;
@@ -120,6 +121,14 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale )
        
        /* compensate for ingame overbrighting/bitshifting */
        VectorScale( sample, (1.0f / lightmapCompensate), sample );
+
+       /* sRGB lightmaps */
+       if(lightmapsRGB)
+       {
+               sample[0] = floor(Image_sRGBFloatFromLinear(sample[0]) * 255.0 + 0.5);
+               sample[1] = floor(Image_sRGBFloatFromLinear(sample[1]) * 255.0 + 0.5);
+               sample[2] = floor(Image_sRGBFloatFromLinear(sample[2]) * 255.0 + 0.5);
+       }
        
        /* store it off */
        colorBytes[ 0 ] = sample[ 0 ];
index e86575e339d262362f9fbdf7cb6039ee06d29f8c..3d3509a4dd7096426ddb2047b529fd2112024874 100644 (file)
@@ -565,6 +565,7 @@ typedef struct game_s
        qboolean                        wolfLight;                                              /* when true, lights work like wolf q3map  */
        int                                     lightmapSize;                                   /* bsp lightmap width/height */
        float                           lightmapGamma;                                  /* default lightmap gamma */
+       qboolean                        lightmapsRGB;                                   /* default lightmap sRGB mode */
        float                           lightmapExposure;                               /* default lightmap exposure */
        float                           lightmapCompensate;                             /* default lightmap compensate value */
        float                           gridScale;                                              /* vortex: default lightgrid scale (affects both directional and ambient spectres) */
@@ -2295,6 +2296,7 @@ Q_EXTERN qboolean                 inGrid Q_ASSIGN(0);
 
 /* ydnar: lightmap gamma/compensation */
 Q_EXTERN float                         lightmapGamma Q_ASSIGN( 1.0f );
+Q_EXTERN float                         lightmapsRGB Q_ASSIGN( qfalse );
 Q_EXTERN float                         lightmapExposure Q_ASSIGN( 1.0f );
 Q_EXTERN float                         lightmapCompensate Q_ASSIGN( 1.0f );