]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
remove not-normalized deluxemap support again - it did not look any better, still...
authorrpolzer <rpolzer@61c419a2-8eb2-4b30-bcec-8cead039b335>
Tue, 30 Sep 2008 12:20:22 +0000 (12:20 +0000)
committerrpolzer <rpolzer@61c419a2-8eb2-4b30-bcec-8cead039b335>
Tue, 30 Sep 2008 12:20:22 +0000 (12:20 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@109 61c419a2-8eb2-4b30-bcec-8cead039b335

tools/quake3/q3map2/light.c
tools/quake3/q3map2/light_ydnar.c
tools/quake3/q3map2/lightmaps_ydnar.c
tools/quake3/q3map2/q3map2.h

index 8995e9feea7140df93c3aee33e0982adeef1dbd0..90542b7844e7e81665a0bb0fd5a3aae68b3a4404 100644 (file)
@@ -1750,7 +1750,6 @@ void LightWorld( void )
        {
                /* store off the bsp between bounces */
                StoreSurfaceLightmaps();
-               UnparseEntities();
                Sys_Printf( "Writing %s\n", source );
                WriteBSPFile( source );
                
@@ -2000,12 +1999,6 @@ int LightMain( int argc, char **argv )
                        Sys_Printf( "Generating deluxemaps for average light direction\n" );
                }
                
-               else if( !strcmp( argv[ i ], "-nodeluxenormalize" ) )
-               {
-                       normalizeDeluxemap = qfalse;
-                       Sys_Printf( "Not normalizing deluxemaps\n" );
-               }
-               
                else if( !strcmp( argv[ i ], "-external" ) )
                {
                        externalLightmaps = qtrue;
index 54a4ca761b0ea125176b43b7abf23ac03a236f07..a206a0397c9032bc1b2ed19e2656c6027a67093a 100644 (file)
@@ -44,14 +44,12 @@ ColorToBytes()
 ydnar: moved to here 2001-02-04
 */
 
-void ColorToBytesDeluxe( const float *color, byte *colorBytes, float scale, const float *deluxel, byte *deluxeBytes)
+void ColorToBytes( const float *color, byte *colorBytes, float scale )
 {
        int             i;
        float   max, gamma;
-       vec3_t  sample, direction;
+       vec3_t  sample;
        float   inv, dif;
-       float   colorMultiplier;
-       float   temp;
        
        
        /* ydnar: scaling necessary for simulating r_overbrightBits on external lightmaps */
@@ -66,7 +64,7 @@ void ColorToBytesDeluxe( const float *color, byte *colorBytes, float scale, cons
        for( i = 0; i < 3; i++ )
        {
                /* handle negative light */
-               if( sample[ i ] <= 0.0f )
+               if( sample[ i ] < 0.0f )
                {
                        sample[ i ] = 0.0f;
                        continue;
@@ -76,8 +74,6 @@ void ColorToBytesDeluxe( const float *color, byte *colorBytes, float scale, cons
                sample[ i ] = pow( sample[ i ] / 255.0f, gamma ) * 255.0f;
        }
 
-       colorMultiplier = 1;
-
        if (lightmapExposure == 1)
        {
                /* clamp with color normalization */
@@ -86,15 +82,16 @@ void ColorToBytesDeluxe( const float *color, byte *colorBytes, float scale, cons
                        max = sample[ 1 ];
                if( sample[ 2 ] > max )
                        max = sample[ 2 ];
-               if(max * colorMultiplier > 255.0f)
-                       colorMultiplier *= 255.0 / max;
+               if( max > 255.0f )
+                       VectorScale( sample, (255.0f / max), sample );
        }
        else
        {
                if (lightmapExposure==0)
-                       inv = 1.f;
-               else
-                       inv = 1.f/lightmapExposure;
+               {
+                       lightmapExposure=1.0f;
+               }
+               inv=1.f/lightmapExposure;
                //Exposure
 
                max = sample[ 0 ];
@@ -102,7 +99,6 @@ void ColorToBytesDeluxe( const float *color, byte *colorBytes, float scale, cons
                        max = sample[ 1 ];
                if( sample[ 2 ] > max )
                        max = sample[ 2 ];
-               max *= colorMultiplier;
 
                dif = (1-  exp(-max * inv) )  *  255;
 
@@ -115,64 +111,20 @@ void ColorToBytesDeluxe( const float *color, byte *colorBytes, float scale, cons
                        dif = 0;
                }
 
-               colorMultiplier *= dif;
+               for (i=0;i<3;i++)
+               {
+                       sample[i]*=dif;
+               }
        }
 
+       
        /* compensate for ingame overbrighting/bitshifting */
-       VectorScale( sample, (colorMultiplier / lightmapCompensate), sample );
-
+       VectorScale( sample, (1.0f / lightmapCompensate), sample );
+       
        /* store it off */
        colorBytes[ 0 ] = sample[ 0 ];
        colorBytes[ 1 ] = sample[ 1 ];
        colorBytes[ 2 ] = sample[ 2 ];
-
-                               
-       /* store direction */
-       if( deluxel )
-       {
-               if(normalizeDeluxemap)
-               {
-                       if(!VectorNormalize(deluxel, direction))
-                               VectorClear(direction);
-               }
-               else
-               {
-                       if(deluxel[3])
-                       {
-                               VectorScale(deluxel, 1 / deluxel[3], direction);
-                               // NOTE:
-                               // if the light was scaled down due to it being too bright...
-                               // we need to reduce the directionality so ADDING light can't
-                               // make stuff DARKER!
-                               if(colorMultiplier < 1)
-                                       VectorScale(direction, colorMultiplier, direction);
-                               // TODO find out the best renderer equation for this
-                       }
-                       else
-                               VectorClear(direction);
-               }
-
-               /* normalize average light direction */
-               //if(direction[0] != 0 || direction[1] != 0 || direction[2] != 0)
-               {
-                       /* encode [-1,1] in [0,255] */
-                       for( i = 0; i < 3; i++ )
-                       {
-                               temp = (direction[ i ] + 1.0f) * 127.5f;
-                               if( temp < 0 )
-                                       deluxeBytes[ i ] = 0;
-                               else if( temp > 255 )
-                                       deluxeBytes[ i ] = 255;
-                               else
-                                       deluxeBytes[ i ] = temp;
-                       }
-               }
-       }
-}
-
-void ColorToBytes( const float *color, byte *colorBytes, float scale )
-{
-       ColorToBytesDeluxe(color, colorBytes, scale, NULL, NULL);
 }
 
 
@@ -1911,8 +1863,7 @@ void IlluminateRawLightmap( int rawLightmapNum )
        float                           brightness;
        float                           *origin, *normal, *dirt, *luxel, *luxel2, *deluxel, *deluxel2;
        float                           *lightLuxels, *lightLuxel, samples, filterRadius, weight;
-       vec3_t                          color, averageColor, total, temp, temp2;
-       float               averageDir[4];
+       vec3_t                          color, averageColor, averageDir, total, temp, temp2;
        float                           tests[ 4 ][ 2 ] = { { 0.0f, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } };
        trace_t                         trace;
        float                           stackLightLuxels[ STACK_LL_SIZE ];
@@ -2056,10 +2007,7 @@ void IlluminateRawLightmap( int rawLightmapNum )
                                {
                                        VectorCopy( ambientColor, luxel );
                                        if( deluxemap )
-                                       {
                                                VectorScale( normal, 0.00390625f, deluxel );
-                                               deluxel[3] = 0.00390625f;
-                                       }
                                        luxel[ 3 ] = 1.0f;
                                }
                        }
@@ -2152,12 +2100,8 @@ void IlluminateRawLightmap( int rawLightmapNum )
                                                /* color to grayscale (photoshop rgb weighting) */
                                                brightness = trace.color[ 0 ] * 0.3f + trace.color[ 1 ] * 0.59f + trace.color[ 2 ] * 0.11f;
                                                brightness *= (1.0 / 255.0);
-                                               if(brightness != 0)
-                                               {
-                                                       VectorScale( trace.direction, brightness, temp );
-                                                       VectorAdd( deluxel, temp, deluxel );
-                                                       deluxel[3] += brightness;
-                                               }
+                                               VectorScale( trace.direction, brightness, trace.direction );
+                                               VectorAdd( deluxel, trace.direction, deluxel );
                                        }
                                }
                        }
@@ -2539,7 +2483,6 @@ void IlluminateRawLightmap( int rawLightmapNum )
                                /* choose seed amount */
                                VectorClear( averageColor );
                                VectorClear( averageDir );
-                               averageDir[3] = 0.0f;
                                samples = 0.0f;
                                
                                /* walk 3x3 matrix */
@@ -2567,10 +2510,7 @@ void IlluminateRawLightmap( int rawLightmapNum )
                                                VectorAdd( averageColor, luxel2, averageColor );
                                                samples += luxel2[ 3 ];
                                                if( filterDir )
-                                               {
                                                        VectorAdd( averageDir, deluxel2, averageDir );
-                                                       averageDir[3] += deluxel2[3];
-                                               }
                                        }
                                }
                                
@@ -2593,10 +2533,7 @@ void IlluminateRawLightmap( int rawLightmapNum )
                                        luxel[ 3 ] = 1.0f;
                                }
                                if( filterDir )
-                               {
                                        VectorDivide( averageDir, samples, deluxel );
-                                       deluxel[3] = averageDir[3] / samples;
-                               }
                                
                                /* set cluster to -3 */
                                if( *cluster < 0 )
index cbcd1128a8ca973fe8d9eae0f4378110bee34943..b4b6349fb4bb2713b7e2d7a6daa3e9ec06228cc6 100644 (file)
@@ -2145,7 +2145,7 @@ static void FindOutLightmaps( rawLightmap_t *lm )
                                }
                                else
                                        VectorCopy( luxel, color );
-
+                               
                                /* styles are not affected by minlight */
                                if( lightmapNum == 0 )
                                {
@@ -2167,11 +2167,28 @@ static void FindOutLightmaps( rawLightmap_t *lm )
                                
                                /* store color */
                                pixel = olm->bspLightBytes + (((oy * olm->customWidth) + ox) * 3);
-
-                               if(deluxemap)
-                                       ColorToBytesDeluxe( color, pixel, lm->brightness, deluxel, olm->bspDirBytes + (((oy * olm->customWidth) + ox) * 3));
-                               else
-                                       ColorToBytes( color, pixel, lm->brightness );
+                               ColorToBytes( color, pixel, lm->brightness );
+                               
+                               /* store direction */
+                               if( deluxemap )
+                               {
+                                       /* normalize average light direction */
+                                       if( VectorNormalize( deluxel, direction ) )
+                                       {
+                                               /* encode [-1,1] in [0,255] */
+                                               pixel = olm->bspDirBytes + (((oy * olm->customWidth) + ox) * 3);
+                                               for( i = 0; i < 3; i++ )
+                                               {
+                                                       temp = (direction[ i ] + 1.0f) * 127.5f;
+                                                       if( temp < 0 )
+                                                               pixel[ i ] = 0;
+                                                       else if( temp > 255 )
+                                                               pixel[ i ] = 255;
+                                                       else
+                                                               pixel[ i ] = temp;
+                                               }
+                                       }
+                               }
                        }
                }
        }
@@ -2239,8 +2256,7 @@ void StoreSurfaceLightmaps( void )
        int                                     i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples;
        int                                     style, size, lightmapNum, lightmapNum2;
        float                           *normal, *luxel, *bspLuxel, *bspLuxel2, *radLuxel, samples, occludedSamples;
-       vec3_t                          sample, occludedSample, colorMins, colorMaxs;
-       vec_t               dirSample[4];
+       vec3_t                          sample, occludedSample, dirSample, colorMins, colorMaxs;
        float                           *deluxel, *bspDeluxel, *bspDeluxel2;
        byte                            *lb;
        int                                     numUsed, numTwins, numTwinLuxels, numStored;
@@ -2334,10 +2350,7 @@ void StoreSurfaceLightmaps( void )
                                                        
                                                        /* sample deluxemap */
                                                        if( deluxemap && lightmapNum == 0 )
-                                                       {
                                                                VectorAdd( dirSample, deluxel, dirSample );
-                                                               dirSample[3] += deluxel[3];
-                                                       }
                                                        
                                                        /* keep track of used/occluded samples */
                                                        if( *cluster != CLUSTER_UNMAPPED )
@@ -2403,10 +2416,7 @@ void StoreSurfaceLightmaps( void )
                                        
                                        /* store light direction */
                                        if( deluxemap && lightmapNum == 0 )
-                                       {
                                                VectorCopy( dirSample, deluxel );
-                                               dirSample[3] = deluxel[3];
-                                       }
                                        
                                        /* store the sample back in super luxels */
                                        if( samples > 0.01f )
@@ -2446,13 +2456,10 @@ void StoreSurfaceLightmaps( void )
                                        /* get luxels */
                                        luxel = SUPER_LUXEL( lightmapNum, x, y );
                                        deluxel = SUPER_DELUXEL( x, y );
-
+                                       
                                        /* copy light direction */
                                        if( deluxemap && lightmapNum == 0 )
-                                       {
                                                VectorCopy( deluxel, dirSample );
-                                               dirSample[3] = deluxel[3];
-                                       }
                                        
                                        /* is this a valid sample? */
                                        if( luxel[ 3 ] > 0.0f )
@@ -2515,7 +2522,7 @@ void StoreSurfaceLightmaps( void )
                                                        }
                                                }
                                        }
-
+                                       
                                        /* scale the sample */
                                        VectorScale( sample, (1.0f / samples), sample );
                                        
@@ -2536,10 +2543,7 @@ void StoreSurfaceLightmaps( void )
                                        
                                        VectorAdd( bspLuxel, sample, bspLuxel );
                                        if( deluxemap && lightmapNum == 0 )
-                                       {
                                                VectorAdd( bspDeluxel, dirSample, bspDeluxel );
-                                               bspDeluxel[3] += dirSample[3];
-                                       }
                                        
                                        /* add color to bounds for solid checking */
                                        if( samples > 0.0f )
@@ -2595,7 +2599,6 @@ void StoreSurfaceLightmaps( void )
                                                VectorAdd( bspDeluxel, bspDeluxel2, bspDeluxel );
                                                VectorScale( bspDeluxel, 0.5f, bspDeluxel );
                                                VectorCopy( bspDeluxel, bspDeluxel2 );
-                                               bspDeluxel2[3] = bspDeluxel[3] = (bspDeluxel[3] + bspDeluxel2[3]) * 0.5f;
                                        }
                                }
                        }
@@ -2615,7 +2618,6 @@ void StoreSurfaceLightmaps( void )
                                                VectorAdd( bspDeluxel, bspDeluxel2, bspDeluxel );
                                                VectorScale( bspDeluxel, 0.5f, bspDeluxel );
                                                VectorCopy( bspDeluxel, bspDeluxel2 );
-                                               bspDeluxel2[3] = bspDeluxel[3] = (bspDeluxel[3] + bspDeluxel2[3]) * 0.5f;
                                        }
                                }
                        }
index b62a2da52d6c468959a51bbd8b77022ee20f80d3..8a4fe4a738a8290ed48d95795175d61cf7fa1809 100644 (file)
@@ -265,8 +265,8 @@ constants
 #define SUPER_LUXEL_SIZE               4
 #define SUPER_ORIGIN_SIZE              3
 #define SUPER_NORMAL_SIZE              4
-#define SUPER_DELUXEL_SIZE             4
-#define BSP_DELUXEL_SIZE               4
+#define SUPER_DELUXEL_SIZE             3
+#define BSP_DELUXEL_SIZE               3
 #define SUPER_FLOODLIGHT_SIZE  1
 
 #define VERTEX_LUXEL( s, v )   (vertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
@@ -1714,7 +1714,6 @@ void                                              RadFreeLights();
 
 /* light_ydnar.c */
 void                                           ColorToBytes( const float *color, byte *colorBytes, float scale );
-void                                           ColorToBytesDeluxe( const float *color, byte *colorBytes, float scale, const float *deluxel, byte *deluxeBytes );
 void                                           SmoothNormals( void );
 
 void                                           MapRawLightmap( int num );
@@ -2095,7 +2094,6 @@ Q_EXTERN qboolean                 cpmaHack Q_ASSIGN( qfalse );
 
 Q_EXTERN qboolean                      deluxemap Q_ASSIGN( qfalse );
 Q_EXTERN qboolean                      debugDeluxemap Q_ASSIGN( qfalse );
-Q_EXTERN qboolean                      normalizeDeluxemap Q_ASSIGN( qtrue );
 
 Q_EXTERN qboolean                      fast Q_ASSIGN( qfalse );
 Q_EXTERN qboolean                      faster Q_ASSIGN( qfalse );