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;
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
{
//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++)
{
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 );
/* 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;
}
}
{
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;
}
{
VectorCopy( ambientColor, luxel );
if( deluxemap )
+ {
VectorScale( normal, 0.00390625f, deluxel );
+ deluxel[3] = 0.00390625f;
+ }
luxel[ 3 ] = 1.0f;
}
}
/* 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;
}
}
}
{
/* get cluster */
cluster = SUPER_CLUSTER( x, y );
- //% if( *cluster < 0 )
- //% continue;
+ if( *cluster < 0 )
+ continue;
/* get particulars */
luxel = SUPER_LUXEL( lightmapNum, x, y );
{
/* 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 */
}
}
}
+
+
+#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
}
#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
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 );
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 );