also new option: -sRGBtex, and renamed -sRGB to -sRGBlight
authorRudolf Polzer <divverent@xonotic.org>
Sat, 29 Oct 2011 14:33:46 +0000 (16:33 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 29 Oct 2011 14:33:46 +0000 (16:33 +0200)
25 files changed:
tools/quake3/q3map2/branch-manager [deleted symlink]
tools/quake3/q3map2/bsp.c
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_bounce.c
tools/quake3/q3map2/light_ydnar.c
tools/quake3/q3map2/q3map2.h

diff --git a/tools/quake3/q3map2/branch-manager b/tools/quake3/q3map2/branch-manager
deleted file mode 120000 (symlink)
index c446238..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../../branch-manager
\ No newline at end of file
index 54e14bf12f895f2e9bd1039bce48bbe249211757..f9fe9025fbc6633b5e1fe661bbde50d7fa56a607 100644 (file)
@@ -683,6 +683,7 @@ int BSPMain( int argc, char **argv )
        maxSurfaceVerts = game->maxSurfaceVerts;
        maxSurfaceIndexes = game->maxSurfaceIndexes;
        emitFlares = game->emitFlares;
+       texturesRGB = game->texturesRGB;
        
        /* process arguments */
        for( i = 1; i < (argc - 1); i++ )
@@ -918,6 +919,16 @@ int BSPMain( int argc, char **argv )
                        Sys_Printf( "Debug portal surfaces enabled\n" );
                        debugPortals = qtrue;
                }
+               else if( !strcmp( argv[ i ], "-sRGBtex" ) )
+               {
+                       texturesRGB = qtrue;
+                       Sys_Printf( "Textures are in sRGB\n" );
+               }
+               else if( !strcmp( argv[ i ], "-nosRGBtex" ) )
+               {
+                       texturesRGB = qfalse;
+                       Sys_Printf( "Textures are linear\n" );
+               }
                else if( !strcmp( argv[ i ], "-altsplit" ) )
                {
                        Sys_Printf( "Alternate BSP splitting (by 27) enabled\n" );
index 0bc61e3a894647e19aa56b2061f206f479d3ec78..5ff6aba7ee80c3008a286339675ceb74fa618cae 100644 (file)
@@ -64,6 +64,7 @@ game_t struct
        0,                      /* lightmap width/height */
        0,                      /* lightmap gamma */
        qfalse,                 /* lightmap sRGB */
+       qfalse,                 /* texture sRGB */
        0,                      /* lightmap exposure */
        0,                      /* lightmap compensate */
        0,                      /* lightgrid scale */
index 653beb101b4a3bef02fef7165155c3a103ac75a5..ab73baa70a8eaed6a4e4adf1d946159a9bbe194a 100644 (file)
@@ -55,6 +55,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        200.0f,                         /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        0.3f,                           /* lightgrid scale */
index 3d6cfe4922b6cfb2ebeb3adfb5915a384bdc3374..6507aec17eea9877dd4df5ee0bd386df2f68e9e5 100644 (file)
@@ -55,6 +55,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.2f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        200.0f,                         /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        0.3f,                           /* lightgrid scale */
index 4c08ab09a914f1133b81149077c5e39f97d7dbf7..111366424195d3ed3da4c1689115188e9d258a56 100644 (file)
@@ -114,6 +114,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index ff791620f786db4708439747587a4c673d1a3d67..38bc083d5337c29d879793c7524335cd12729cf8 100644 (file)
@@ -149,6 +149,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qtrue,                          /* lightmap sRGB */
+       qfalse,                         /* texture sRGB (yes, this is incorrect, but we better match ET:UT) */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 7f4a5fcc333b9e4ea88d5508f139678f84816dbb..3a1a4d483ab4adf0ca0f247239a3f1a5c20ff192 100644 (file)
@@ -68,6 +68,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 30bb3d3b7d894d9a9c9f0414695722a2a308e058..4dd4d845c5bd5c0da790f5fa92d6a59357cdabe2 100644 (file)
@@ -65,6 +65,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 8e0785d9022723bcd6f7722cbd6732ee40021a61..386cfd03330a62fb049fbb3f9e0e904a3b3005c9 100644 (file)
@@ -64,6 +64,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index a1a4c4b5a2c6051835beb14d99cb62e8af3549d0..6d8b0a2197e80d254c3c58aebcd05fad2d571f05 100644 (file)
@@ -55,6 +55,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        200.0f,                         /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        0.4f,                           /* lightgrid scale */
index 0fd336c6cbb56b688422215579d1351f6bf4eea8..681f75d799df1b268ab687fe6817aae7407bb82d 100644 (file)
@@ -116,6 +116,7 @@ game_t struct
        512,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index be09468df0ed2d8e9df792233a5952753ddb4a6e..76b3ff3711e330d5c54b751f65f2c410a2eab860 100644 (file)
@@ -113,6 +113,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index a9425a8f9044b3c6db449bd62f8d55f205b42edc..ba781cdca2a276545a1585b418e4e41d89f50f43 100644 (file)
@@ -65,6 +65,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 97b01c4806e9574f46f0c14562fd4f8114fee596..ea59e3581c15d40463392b225ea03e28ac8b8d24 100644 (file)
@@ -85,6 +85,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index e7453f8d8f758e3eb5bba0b517522b8e373eaa77..98081da6d6b1c5778dc2efa5e01969df03495bd3 100644 (file)
@@ -140,6 +140,7 @@ game_t struct
        128,                                    /* lightmap width/height */
        1.0f,                                   /* lightmap gamma */
        qfalse,                                 /* lightmap sRGB */
+       qfalse,                                 /* texture sRGB */
        1.0f,                                   /* lightmap exposure */
        1.0f,                                   /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 2117aa45e2a1eff11a02f7a87df218458de9fa91..9e0658f10c2686a7f8b7ae546d15811b6534aa2b 100644 (file)
@@ -113,6 +113,7 @@ game_t struct
        512,                            /* lightmap width/height */
        2.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 9a1cb7969c37286d8075f1af9f47c3610666f421..08027fe6539e3b627c35d61d6e15cbf5ed5db2d3 100644 (file)
@@ -71,6 +71,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index fc55c884b0335cf3281a2391e4cb82e43b4a835c..94339e651b8e11b1492c1e16f0655b2eb26d679c 100644 (file)
@@ -130,6 +130,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index fdda4d95c6cfaed47eb5677ba66aa172988398d4..bcb30985f32a0c0122e20bf3dc6605810d26366f 100644 (file)
@@ -67,6 +67,7 @@ game_t struct
        128,                            /* lightmap width/height */
        1.0f,                           /* lightmap gamma */
        qfalse,                         /* lightmap sRGB */
+       qfalse,                         /* texture sRGB */
        1.0f,                           /* lightmap exposure */
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
index 83d7715f6d634408616e585827922330c1979779..2512193073adcd5c899db060c2c20cabbda652c5 100644 (file)
@@ -64,6 +64,7 @@ game_t struct
        128, /* lightmap width/height */
        1.0f, /* lightmap gamma */
        qfalse, /* lightmap sRGB */
+       qfalse, /* texture sRGB */
        1.0f, /* lightmap exposure */
        1.0f, /* lightmap compensate */
        1.0f, /* lightgrid scale */
index ffdd5008207ea51445e4bbf1f5f5572ff7d14390..c7f1e722de59bd121d8b9054f09610b2513476f9 100644 (file)
@@ -2077,6 +2077,12 @@ int LightMain( int argc, char **argv )
        else
                Sys_Printf( " lightmap colorspace: linear\n" );
 
+       texturesRGB = game->texturesRGB;
+       if(texturesRGB)
+               Sys_Printf( " texture colorspace: sRGB\n" );
+       else
+               Sys_Printf( " texture colorspace: linear\n" );
+
        lightmapCompensate = game->lightmapCompensate;
        Sys_Printf( " lightning compensation: %f\n", lightmapCompensate );
 
@@ -2235,18 +2241,30 @@ int LightMain( int argc, char **argv )
                        i++;
                }
                
-               else if( !strcmp( argv[ i ], "-sRGB" ) )
+               else if( !strcmp( argv[ i ], "-sRGBlight" ) )
                {
                        lightmapsRGB = qtrue;
                        Sys_Printf( "Lighting is in sRGB\n" );
                }
 
-               else if( !strcmp( argv[ i ], "-nosRGB" ) )
+               else if( !strcmp( argv[ i ], "-nosRGBlight" ) )
                {
                        lightmapsRGB = qfalse;
                        Sys_Printf( "Lighting is linear\n" );
                }
 
+               else if( !strcmp( argv[ i ], "-sRGBtex" ) )
+               {
+                       texturesRGB = qtrue;
+                       Sys_Printf( "Textures are in sRGB\n" );
+               }
+
+               else if( !strcmp( argv[ i ], "-nosRGBtex" ) )
+               {
+                       texturesRGB = qfalse;
+                       Sys_Printf( "Textures are linear\n" );
+               }
+
                else if( !strcmp( argv[ i ], "-exposure" ) )
                {
                        f = atof( argv[ i + 1 ] );
index 0e59ddeb451ded78f158b14ba9eba9eb6f6c1f2e..d78c6dee872d9c15cd438099fbd952aa91955cba 100644 (file)
@@ -233,6 +233,14 @@ qboolean RadSampleImage( byte *pixels, int width, int height, float st[ 2 ], flo
        pixels += (y * width * 4) + (x * 4);
        VectorCopy( pixels, color );
        color[ 3 ] = pixels[ 3 ];
+
+       if(texturesRGB)
+       {
+               color[0] = Image_LinearFloatFromsRGBFloat(color[0] * (1.0 / 255.0)) * 255.0;
+               color[1] = Image_LinearFloatFromsRGBFloat(color[1] * (1.0 / 255.0)) * 255.0;
+               color[2] = Image_LinearFloatFromsRGBFloat(color[2] * (1.0 / 255.0)) * 255.0;
+       }
+
        return qtrue;
 }
 
index 09a8e484090463a80981b0a1bc6d6037f92c05f5..b01084dff1c598fa7e80e6cfb9af115f3d01a627 100644 (file)
@@ -44,7 +44,6 @@ 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;
@@ -125,9 +124,9 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale )
        /* 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);
+               sample[0] = floor(Image_sRGBFloatFromLinearFloat(sample[0] * (1.0 / 255.0)) * 255.0 + 0.5);
+               sample[1] = floor(Image_sRGBFloatFromLinearFloat(sample[1] * (1.0 / 255.0)) * 255.0 + 0.5);
+               sample[2] = floor(Image_sRGBFloatFromLinearFloat(sample[2] * (1.0 / 255.0)) * 255.0 + 0.5);
        }
        
        /* store it off */
index 9172415ed7567bf3217510a9877fd10a1a7802fb..8c240ea899b6ac97463f9b569f7410c73d1c98fa 100644 (file)
@@ -566,6 +566,7 @@ typedef struct game_s
        int                                     lightmapSize;                                   /* bsp lightmap width/height */
        float                           lightmapGamma;                                  /* default lightmap gamma */
        qboolean                        lightmapsRGB;                                   /* default lightmap sRGB mode */
+       qboolean                        texturesRGB;                                    /* default texture 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) */
@@ -2298,6 +2299,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                         texturesRGB Q_ASSIGN( qfalse );
 Q_EXTERN float                         lightmapExposure Q_ASSIGN( 1.0f );
 Q_EXTERN float                         lightmapCompensate Q_ASSIGN( 1.0f );
 
@@ -2540,5 +2542,8 @@ Q_EXTERN bspAdvertisement_t       bspAds[ MAX_MAP_ADVERTISEMENTS ];
 
 #define AUTOEXPAND_BY_REALLOC_BSP(suffix, def) AUTOEXPAND_BY_REALLOC(bsp##suffix, numBSP##suffix, allocatedBSP##suffix, def)
 
+#define Image_LinearFloatFromsRGBFloat(c) (((c) <= 0.04045f) ? (c) * (1.0f / 12.92f) : (float)pow(((c) + 0.055f)*(1.0f/1.055f), 2.4f))
+#define Image_sRGBFloatFromLinearFloat(c) (((c) < 0.0031308f) ? (c) * 12.92f : 1.055f * (float)pow((c), 1.0f/2.4f) - 0.055f)
+
 /* end marker */
 #endif