]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Turn some UT stuff into options, as it is broken for Nexuiz. Also add -nodeluxenormal...
authorrpolzer <rpolzer@61c419a2-8eb2-4b30-bcec-8cead039b335>
Fri, 26 Sep 2008 06:48:14 +0000 (06:48 +0000)
committerrpolzer <rpolzer@61c419a2-8eb2-4b30-bcec-8cead039b335>
Fri, 26 Sep 2008 06:48:14 +0000 (06:48 +0000)
+ else if( !strcmp( argv[ i ], "-nodeluxenormalize" ) )
+ else if( !strcmp( argv[ i ], "-trianglecheck" ) )
+ else if( !strcmp( argv[ i ], "-extravisnudge" ) )

git-svn-id: svn://svn.icculus.org/netradiant/trunk@105 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 5130b2a21886461c99115948f72ddb737c2b4c88..29472a19ad7d501a94107400f5a76b90edda942b 100644 (file)
@@ -1999,6 +1999,12 @@ 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;
@@ -2322,7 +2328,14 @@ int LightMain( int argc, char **argv )
                                dirtGain = 1.0f;
                        Sys_Printf( "Dirtmapping gain set to %.1f\n", dirtGain );
                }
-               
+               else if( !strcmp( argv[ i ], "-trianglecheck" ) )
+               {
+                       lightmapTriangleCheck = qtrue;
+               }
+               else if( !strcmp( argv[ i ], "-extravisnudge" ) )
+               {
+                       lightmapExtraVisClusterNudge = qtrue;
+               }
                /* unhandled args */
                else
                {
index d8f0c730fa270938e7c54d645c2c6ba09c52bbe5..fa2a4d7155533945afcc5cd4bf18f69e0bdc5f4e 100644 (file)
@@ -533,7 +533,7 @@ static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t
        //1) Test the sample origin to see if it lays on the wrong side of any edge (x/y)
        //2) if it does, nudge it onto the correct side.
 
-       if (worldverts!=NULL)
+       if (worldverts!=NULL && lightmapTriangleCheck)
        {
                for (j=0;j<3;j++)
                {
@@ -604,9 +604,12 @@ static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t
                origin[ lm->axisNum ] += lightmapSampleOffset;
        
        VectorCopy(origin,origintwo);
-       origintwo[0]+=vecs[2][0];
-       origintwo[1]+=vecs[2][1];
-       origintwo[2]+=vecs[2][2];
+       if(lightmapExtraVisClusterNudge)
+       {
+               origintwo[0]+=vecs[2][0];
+               origintwo[1]+=vecs[2][1];
+               origintwo[2]+=vecs[2][2];
+       }
 
        /* get cluster */
        pointCluster = ClusterForPointExtFilter( origintwo, LUXEL_EPSILON, numClusters, clusters );
@@ -631,8 +634,8 @@ static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t
                        
                        /* get pvs cluster */
                        pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters ); //% + 0.625 );
-                       //if( pointCluster >= 0 )
-                       //      VectorCopy( nudged, origin );
+                       if( pointCluster >= 0 )
+                               VectorCopy( nudged, origin );
                        luxel[ 1 ] += 1.0f;
                }
        }
@@ -642,8 +645,8 @@ static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t
        {
                VectorMA( dv->xyz, lightmapSampleOffset, dv->normal, nudged );
                pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters );
-               //if( pointCluster >= 0 )
-               //      VectorCopy( nudged, origin );
+               if( pointCluster >= 0 )
+                       VectorCopy( nudged, origin );
                luxel[ 1 ] += 1.0f;
        }
        
@@ -2004,7 +2007,10 @@ void IlluminateRawLightmap( int rawLightmapNum )
                                {
                                        VectorCopy( ambientColor, luxel );
                                        if( deluxemap )
+                                       {
                                                VectorScale( normal, 0.00390625f, deluxel );
+                                               deluxel[3] = 0.00390625f;
+                                       }
                                        luxel[ 3 ] = 1.0f;
                                }
                        }
@@ -2097,8 +2103,9 @@ 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);
-                                               VectorScale( trace.direction, brightness, trace.direction );
-                                               VectorAdd( deluxel, trace.direction, deluxel );
+                                               VectorScale( trace.direction, brightness, temp );
+                                               VectorAdd( deluxel, temp, deluxel );
+                                               deluxel[3] += brightness;
                                        }
                                }
                        }
@@ -2353,8 +2360,8 @@ void IlluminateRawLightmap( int rawLightmapNum )
                                {
                                        /* get cluster */
                                        cluster = SUPER_CLUSTER( x, y );
-                                       //%     if( *cluster < 0 )
-                                       //%             continue;
+                                       if( *cluster < 0 )
+                                               continue;
 
                                        /* get particulars */
                                        luxel = SUPER_LUXEL( lightmapNum, x, y );
@@ -2425,7 +2432,7 @@ void IlluminateRawLightmap( int rawLightmapNum )
                                {
                                        /* get cluster */
                                        cluster = SUPER_CLUSTER( x, y );
-                                       //%     if( *cluster < 0 )
+                                       //%     if( *cluster < 0 ) // TODO why not do this check? These pixels should be zero anyway
                                        //%             continue;
                                        
                                        /* get particulars */
@@ -2538,6 +2545,44 @@ void IlluminateRawLightmap( int rawLightmapNum )
                        }
                }
        }
+
+
+#if 0
+       // audit pass
+       for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
+       {
+               /* early out */
+               if( lm->superLuxels[ lightmapNum ] == NULL )
+                       continue;
+               for( y = 0; y < lm->sh; y++ )
+                       for( x = 0; x < lm->sw; x++ )
+                       {
+                               /* get cluster */
+                               cluster = SUPER_CLUSTER( x, y );
+                               luxel = SUPER_LUXEL( lightmapNum, x, y );
+                               deluxel = SUPER_DELUXEL( x, y );
+                               if(!luxel || !deluxel || !cluster)
+                               {
+                                       Sys_FPrintf(SYS_VRB, "WARNING: I got NULL'd.\n");
+                                       continue;
+                               }
+                               else if(*cluster < 0)
+                               {
+                                       // unmapped pixel
+                                       // should have neither deluxemap nor lightmap
+                                       if(deluxel[3])
+                                               Sys_FPrintf(SYS_VRB, "WARNING: I have written deluxe to an unmapped luxel. Sorry.\n");
+                               }
+                               else
+                               {
+                                       // mapped pixel
+                                       // should have both deluxemap and lightmap
+                                       if(deluxel[3])
+                                               Sys_FPrintf(SYS_VRB, "WARNING: I forgot to write deluxe to a mapped luxel. Sorry.\n");
+                               }
+                       }
+       }
+#endif
 }
 
 
index b4b6349fb4bb2713b7e2d7a6daa3e9ec06228cc6..d3054b1f8fe439c2d4595f92232ae2b49398b620 100644 (file)
@@ -2172,8 +2172,21 @@ static void FindOutLightmaps( rawLightmap_t *lm )
                                /* store direction */
                                if( deluxemap )
                                {
+                                       if(normalizeDeluxemap)
+                                       {
+                                               if(!VectorNormalize(deluxel, direction))
+                                                       VectorClear(direction);
+                                       }
+                                       else
+                                       {
+                                               if(deluxel[3])
+                                                       VectorScale(deluxel, 1 / deluxel[3], direction);
+                                               else
+                                                       VectorClear(direction);
+                                       }
+
                                        /* normalize average light direction */
-                                       if( VectorNormalize( deluxel, direction ) )
+                                       if(direction[0] != 0 || direction[1] != 0 || direction[2] != 0)
                                        {
                                                /* encode [-1,1] in [0,255] */
                                                pixel = olm->bspDirBytes + (((oy * olm->customWidth) + ox) * 3);
index a4545933dfbcefec49cb991f371d2e5dab4dcf15..af2e3a332d7fa173bd41eb8ffa2f3abc7f4bd5c6 100644 (file)
@@ -265,7 +265,7 @@ constants
 #define SUPER_LUXEL_SIZE               4
 #define SUPER_ORIGIN_SIZE              3
 #define SUPER_NORMAL_SIZE              4
-#define SUPER_DELUXEL_SIZE             3
+#define SUPER_DELUXEL_SIZE             4
 #define BSP_DELUXEL_SIZE               3
 #define SUPER_FLOODLIGHT_SIZE  1
 
@@ -1935,7 +1935,8 @@ Q_EXTERN qboolean                 emitFlares Q_ASSIGN( qfalse );
 Q_EXTERN qboolean                      debugSurfaces Q_ASSIGN( qfalse );
 Q_EXTERN qboolean                      debugInset Q_ASSIGN( qfalse );
 Q_EXTERN qboolean                      debugPortals Q_ASSIGN( qfalse );
-
+Q_EXTERN qboolean           lightmapTriangleCheck Q_ASSIGN(qfalse);
+Q_EXTERN qboolean           lightmapExtraVisClusterNudge Q_ASSIGN(qfalse);
 Q_EXTERN double                                normalEpsilon Q_ASSIGN( 0.00001 );
 Q_EXTERN double                                distanceEpsilon Q_ASSIGN( 0.01 );
 
@@ -2093,6 +2094,7 @@ 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 );