*/
ColorToBytesNonZero(color, bgp->ambient[i], gridScale * gridAmbientScale);
} else {
- ColorToBytes(color, bgp->ambient[i], gridScale * gridAmbientScale);
+ ColorToBytes( color, bgp->ambient[ i ], gridScale * gridAmbientScale );
}
ColorToBytes( gp->directed[ i ], bgp->directed[ i ], gridScale );
}
UnparseEntities();
if ( storeForReal ) {
- Sys_Printf( "Writing %s\n", BSPFilePath );
- WriteBSPFile( BSPFilePath );
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
}
/* note it */
const char *value;
int lightmapMergeSize = 0;
qboolean lightSamplesInsist = qfalse;
- qboolean fastAllocate = qfalse;
+ qboolean fastAllocate = qtrue;
qboolean noBounceStore = qfalse;
/* note it */
Sys_Printf( "Slow lightmap allocation mode enabled (default)\n" );
}
+ else if ( !strcmp( argv[ i ], "-slowallocate" ) ) {
+ fastAllocate = qfalse;
+ Sys_Printf( "Slow allocation mode enabled\n" );
+ }
+
else if ( !strcmp( argv[ i ], "-fastgrid" ) ) {
fastgrid = qtrue;
Sys_Printf( "Fast grid lighting enabled\n" );
/* get min number of surfaces */
min = ( alm->numLightSurfaces < blm->numLightSurfaces ? alm->numLightSurfaces : blm->numLightSurfaces );
+//#define allocate_bigger_first
+#ifdef allocate_bigger_first
+ /* compare size, allocate bigger first */
+ // fastAllocate commit part: can kick fps by unique lightmap/shader combinations*=~2 + bigger compile time
+ //return -diff; makes packing faster and rough
+ diff = ( blm->w * blm->h ) - ( alm->w * alm->h );
+ if ( diff != 0 ) {
+ return diff;
+ }
+#endif
/* iterate */
for ( i = 0; i < min; i++ )
{
if ( diff ) {
return diff;
}
-
+#ifndef allocate_bigger_first
/* compare size */
diff = ( blm->w * blm->h ) - ( alm->w * alm->h );
if ( diff != 0 ) {
return diff;
}
-
+#endif
/* must be equivalent */
return 0;
}
}
}
-
-
/*
StoreSurfaceLightmaps()
stores the surface lightmaps into the bsp as byte rgb triplets
*/
void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){
- int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples;
+ int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples, timer_start;
int style, size, lightmapNum, lightmapNum2;
float *normal, *luxel, *bspLuxel, *bspLuxel2, *radLuxel, samples, occludedSamples;
vec3_t sample, occludedSample, dirSample, colorMins, colorMaxs;
/* note it */
Sys_FPrintf( SYS_VRB, "Subsampling..." );
+ timer_start = I_FloatTime();
+
/* walk the list of raw lightmaps */
numUsed = 0;
numTwins = 0;
}
}
+ Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
/* -----------------------------------------------------------------
convert modelspace deluxemaps to tangentspace
----------------------------------------------------------------- */
vec3_t worldUp, myNormal, myTangent, myBinormal;
float dist;
+ timer_start = I_FloatTime();
+
Sys_Printf( "converting..." );
for ( i = 0; i < numRawLightmaps; i++ )
}
}
}
+
+ Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
}
}
/* note it */
Sys_FPrintf( SYS_VRB, "collapsing..." );
+ timer_start = I_FloatTime();
+
/* set all twin refs to null */
for ( i = 0; i < numRawLightmaps; i++ )
{
}
}
}
+
+ Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
}
/* -----------------------------------------------------------------
/* note it */
Sys_FPrintf( SYS_VRB, "sorting..." );
+ timer_start = I_FloatTime();
+
/* allocate a new sorted list */
if ( sortLightmaps == NULL ) {
sortLightmaps = safe_malloc( numRawLightmaps * sizeof( int ) );
sortLightmaps[ i ] = i;
qsort( sortLightmaps, numRawLightmaps, sizeof( int ), CompareRawLightmap );
+ Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
/* -----------------------------------------------------------------
allocate output lightmaps
----------------------------------------------------------------- */
/* note it */
Sys_FPrintf( SYS_VRB, "allocating..." );
+ timer_start = I_FloatTime();
+
/* kill all existing output lightmaps */
if ( outLightmaps != NULL ) {
for ( i = 0; i < numOutLightmaps; i++ )
}
}
+ Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
/* -----------------------------------------------------------------
store output lightmaps
----------------------------------------------------------------- */
/* note it */
Sys_FPrintf( SYS_VRB, "storing..." );
+ timer_start = I_FloatTime();
+
/* count the bsp lightmaps and allocate space */
if ( bspLightBytes != NULL ) {
free( bspLightBytes );
}
}
+ Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
/* -----------------------------------------------------------------
project the lightmaps onto the bsp surfaces
----------------------------------------------------------------- */
/* note it */
Sys_FPrintf( SYS_VRB, "projecting..." );
+ timer_start = I_FloatTime();
+
/* walk the list of surfaces */
for ( i = 0; i < numBSPDrawSurfaces; i++ )
{
}
}
+ Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) );
+
/* finish */
Sys_FPrintf( SYS_VRB, "done.\n" );