}
}
- if ( sampleSize != lm->sampleSize && lmLimitSize == 0 ) {
- Sys_FPrintf( SYS_VRB,"WARNING: surface at (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) too large for desired samplesize/lightmapsize/lightmapscale combination, increased samplesize from %d to %d\n",
- info->mins[0],
- info->mins[1],
- info->mins[2],
- info->maxs[0],
- info->maxs[1],
- info->maxs[2],
- lm->sampleSize,
- (int) sampleSize );
+ if ( sampleSize != lm->sampleSize && lmLimitSize == 0 ){
+ if ( debugSampleSize == 1 || lm->customWidth > 128 ){
+ Sys_FPrintf( SYS_VRB,"WARNING: surface at (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) too large for desired samplesize/lightmapsize/lightmapscale combination, increased samplesize from %d to %d\n",
+ info->mins[0],
+ info->mins[1],
+ info->mins[2],
+ info->maxs[0],
+ info->maxs[1],
+ info->maxs[2],
+ lm->sampleSize,
+ (int) sampleSize );
+ }
+ else if ( debugSampleSize == 0 ){
+ Sys_FPrintf( SYS_VRB,"WARNING: surface at (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) too large for desired samplesize/lightmapsize/lightmapscale combination, increased samplesize from %d to %d\n",
+ info->mins[0],
+ info->mins[1],
+ info->mins[2],
+ info->maxs[0],
+ info->maxs[1],
+ info->maxs[2],
+ lm->sampleSize,
+ (int) sampleSize );
+ debugSampleSize--;
+ }
+ else{
+ debugSampleSize--;
+ }
}
/* set actual sample size */
/* determine if surface requires a lightmap */
if ( ds->surfaceType == MST_TRIANGLE_SOUP ||
ds->surfaceType == MST_FOLIAGE ||
- ( info->si->compileFlags & C_VERTEXLIT ) ) {
+ ( info->si->compileFlags & C_VERTEXLIT ) ||
+ nolm == qtrue ) {
numSurfsVertexLit++;
}
else
FinishRawLightmap( lm );
}
+ if ( debugSampleSize < -1 ){
+ Sys_FPrintf( SYS_VRB, "+%d similar occurrences;\t-debugSampleSize to show ones\n", -debugSampleSize - 1 );
+ }
+
/* allocate vertex luxel storage */
for ( k = 0; k < MAX_LIGHTMAPS; k++ )
{
/* allocate LIGHTMAP_RESERVE_COUNT new output lightmaps */
numOutLightmaps += LIGHTMAP_RESERVE_COUNT;
olm = safe_malloc( numOutLightmaps * sizeof( outLightmap_t ) );
+ if ( !olm ){
+ Error( "FindOutLightmaps: Failed to allocate memory.\n" );
+ }
+
if ( outLightmaps != NULL && numOutLightmaps > LIGHTMAP_RESERVE_COUNT ) {
memcpy( olm, outLightmaps, ( numOutLightmaps - LIGHTMAP_RESERVE_COUNT ) * sizeof( outLightmap_t ) );
free( outLightmaps );
/* 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" );