ds2->shaderInfo = dp->si;
ds2->fogNum = ds->fogNum; /* why was this -1? */
ds2->lightmapScale = ds->lightmapScale;
+ ds2->shadeAngleDegrees = ds->shadeAngleDegrees;
ds2->numVerts = w->numpoints;
ds2->verts = safe_malloc( ds2->numVerts * sizeof( *ds2->verts ) );
memset( ds2->verts, 0, ds2->numVerts * sizeof( *ds2->verts ) );
epair_t *ep;
const char *classname, *value;
float lightmapScale, shadeAngle;
+ int lightmapSampleSize;
char shader[ MAX_QPATH ];
shaderInfo_t *celShader = NULL;
brush_t *brush;
/* vortex: added _ls key (short name of lightmapscale) */
/* ydnar: get lightmap scaling value for this entity */
+ lightmapScale = 0.0f;
if( strcmp( "", ValueForKey( mapEnt, "lightmapscale" ) ) ||
strcmp( "", ValueForKey( mapEnt, "_lightmapscale" ) ) ||
strcmp( "", ValueForKey( mapEnt, "_ls" ) ) )
lightmapScale = FloatForKey( mapEnt, "_lightmapscale" );
if( lightmapScale <= 0.0f )
lightmapScale = FloatForKey( mapEnt, "_ls" );
+ if( lightmapScale < 0.0f )
+ lightmapScale = 0.0f;
if( lightmapScale > 0.0f )
Sys_Printf( "Entity %d (%s) has lightmap scale of %.4f\n", mapEnt->mapEntityNum, classname, lightmapScale );
}
- else
- lightmapScale = 0.0f;
-
+
/* ydnar: get cel shader :) for this entity */
value = ValueForKey( mapEnt, "_celshader" );
if( value[ 0 ] == '\0' )
if( shadeAngle > 0.0f )
Sys_Printf( "Entity %d (%s) has shading angle of %.4f\n", mapEnt->mapEntityNum, classname, shadeAngle );
+ /* jal : entity based _samplesize */
+ lightmapSampleSize = 0;
+ if ( strcmp( "", ValueForKey( mapEnt, "_lightmapsamplesize" ) ) )
+ lightmapSampleSize = IntForKey( mapEnt, "_lightmapsamplesize" );
+ else if ( strcmp( "", ValueForKey( mapEnt, "_samplesize" ) ) )
+ lightmapSampleSize = IntForKey( mapEnt, "_samplesize" );
+
+ if( lightmapSampleSize < 0 )
+ lightmapSampleSize = 0;
+
+ if( lightmapSampleSize > 0 )
+ Sys_Printf( "Entity %d (%s) has lightmap sample size of %d\n", mapEnt->mapEntityNum, classname, lightmapSampleSize );
/* attach stuff to everything in the entity */
for( brush = mapEnt->brushes; brush != NULL; brush = brush->next )
brush->entityNum = mapEnt->mapEntityNum;
brush->castShadows = castShadows;
brush->recvShadows = recvShadows;
+ brush->lightmapSampleSize = lightmapSampleSize;
brush->lightmapScale = lightmapScale;
brush->celShader = celShader;
brush->shadeAngleDegrees = shadeAngle;
patch->entityNum = mapEnt->mapEntityNum;
patch->castShadows = castShadows;
patch->recvShadows = recvShadows;
+ patch->lightmapSampleSize = lightmapSampleSize;
patch->lightmapScale = lightmapScale;
patch->celShader = celShader;
}
adds a picomodel into the bsp
*/
-void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, float shadeAngle )
+void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle )
{
int i, j, k, s, numSurfaces;
m4x4_t identity, nTransform;
/* fix bogus lightmap scale */
if( lightmapScale <= 0.0f )
lightmapScale = 1.0f;
+
+ /* fix bogus shade angle */
+ if( shadeAngle <= 0.0f )
+ shadeAngle = 0.0f;
/* each surface on the model will become a new map drawsurface */
numSurfaces = PicoGetModelNumSurfaces( model );
if( (si != NULL && si->forceMeta) || (spawnFlags & 4) ) /* 3rd bit */
ds->type = SURFACE_FORCED_META;
- /* get shading angle from shader or entity */
- if( si->shadeAngleDegrees )
- ds->shadeAngleDegrees = si->shadeAngleDegrees;
- else if( shadeAngle )
- ds->shadeAngleDegrees = shadeAngle; /* otherwise it's 0 */
-
/* fix the surface's normals (jal: conditioned by shader info) */
if( !(spawnFlags & 64) && ( shadeAngle == 0.0f || ds->type != SURFACE_FORCED_META ) )
PicoFixSurfaceNormals( surface );
+
+ /* set sample size */
+ if( lightmapSampleSize > 0.0f )
+ ds->sampleSize = lightmapSampleSize;
/* set lightmap scale */
- ds->lightmapScale = lightmapScale;
+ if( lightmapScale > 0.0f )
+ ds->lightmapScale = lightmapScale;
+
+ /* set shading angle */
+ if( shadeAngle > 0.0f )
+ ds->shadeAngleDegrees = shadeAngle;
/* set particulars */
ds->numVerts = PicoGetSurfaceNumVertexes( surface );
shaderInfo_t *celShader;
float temp, baseLightmapScale, lightmapScale;
float shadeAngle;
+ int lightmapSampleSize;
vec3_t origin, scale, angles;
m4x4_t transform;
epair_t *ep;
/* get lightmap scale */
/* vortex: added _ls key (short name of lightmapscale) */
- baseLightmapScale = FloatForKey( e, "_lightmapscale" );
- if( baseLightmapScale <= 0.0f )
- baseLightmapScale = FloatForKey( e, "_ls" );
- if( baseLightmapScale <= 0.0f )
- baseLightmapScale = 0.0f;
+ baseLightmapScale = 0.0f;
+ if( strcmp( "", ValueForKey( e, "lightmapscale" ) ) ||
+ strcmp( "", ValueForKey( e, "_lightmapscale" ) ) ||
+ strcmp( "", ValueForKey( e, "_ls" ) ) )
+ {
+ baseLightmapScale = FloatForKey( e, "lightmapscale" );
+ if( baseLightmapScale <= 0.0f )
+ baseLightmapScale = FloatForKey( e, "_lightmapscale" );
+ if( baseLightmapScale <= 0.0f )
+ baseLightmapScale = FloatForKey( e, "_ls" );
+ if( baseLightmapScale < 0.0f )
+ baseLightmapScale = 0.0f;
+ if( baseLightmapScale > 0.0f )
+ Sys_Printf( "World Entity has lightmap scale of %.4f\n", baseLightmapScale );
+ }
+
/* walk the entity list */
for( num = 1; num < numEntities; num++ )
}
else
celShader = *globalCelShader ? ShaderInfoForShader(globalCelShader) : NULL;
-
+
+ /* jal : entity based _samplesize */
+ lightmapSampleSize = 0;
+ if ( strcmp( "", ValueForKey( e2, "_lightmapsamplesize" ) ) )
+ lightmapSampleSize = IntForKey( e2, "_lightmapsamplesize" );
+ else if ( strcmp( "", ValueForKey( e2, "_samplesize" ) ) )
+ lightmapSampleSize = IntForKey( e2, "_samplesize" );
+
+ if( lightmapSampleSize < 0 )
+ lightmapSampleSize = 0;
+
+ if( lightmapSampleSize > 0.0f )
+ Sys_Printf( "misc_model has lightmap sample size of %.d\n", lightmapSampleSize );
+
/* get lightmap scale */
/* vortex: added _ls key (short name of lightmapscale) */
- lightmapScale = FloatForKey( e2, "_lightmapscale" );
- if( lightmapScale <= 0.0f )
- lightmapScale = FloatForKey( e2, "_ls" );
- if( lightmapScale <= 0.0f )
- lightmapScale = baseLightmapScale;
+ lightmapScale = 0.0f;
+ if( strcmp( "", ValueForKey( e2, "lightmapscale" ) ) ||
+ strcmp( "", ValueForKey( e2, "_lightmapscale" ) ) ||
+ strcmp( "", ValueForKey( e2, "_ls" ) ) )
+ {
+ lightmapScale = FloatForKey( e2, "lightmapscale" );
+ if( lightmapScale <= 0.0f )
+ lightmapScale = FloatForKey( e2, "_lightmapscale" );
+ if( lightmapScale <= 0.0f )
+ lightmapScale = FloatForKey( e2, "_ls" );
+ if( lightmapScale < 0.0f )
+ lightmapScale = 0.0f;
+ if( lightmapScale > 0.0f )
+ Sys_Printf( "misc_model has lightmap scale of %.4f\n", lightmapScale );
+ }
/* jal : entity based _shadeangle */
shadeAngle = 0.0f;
Sys_Printf( "misc_model has shading angle of %.4f\n", shadeAngle );
/* insert the model */
- InsertModel( (char*) model, frame, transform, remap, celShader, mapEntityNum, castShadows, recvShadows, spawnFlags, lightmapScale, shadeAngle );
+ InsertModel( (char*) model, frame, transform, remap, celShader, mapEntityNum, castShadows, recvShadows, spawnFlags, lightmapScale, lightmapSampleSize, shadeAngle );
/* free shader remappings */
while( remap != NULL )
shaderInfo_t *celShader; /* :) */
/* ydnar: gs mods */
+ int lightmapSampleSize; /* jal : entity based _lightmapsamplesize */
float lightmapScale;
float shadeAngleDegrees; /* jal : entity based _shadeangle */
vec3_t eMins, eMaxs;
shaderInfo_t *celShader; /* :) */
/* ydnar: gs mods */
+ int lightmapSampleSize; /* jal : entity based _lightmapsamplesize */
float lightmapScale;
vec3_t eMins, eMaxs;
indexMap_t *im;
void PicoLoadFileFunc( char *name, byte **buffer, int *bufSize );
picoModel_t *FindModel( char *name, int frame );
picoModel_t *LoadModel( char *name, int frame );
-void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, float shadeAngle );
+void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shaderInfo_t *celShader, int eNum, int castShadows, int recvShadows, int spawnFlags, float lightmapScale, int lightmapSampleSize, float shadeAngle );
void AddTriangleModels( entity_t *e );
si->lightmapSampleSize = atoi( token );
}
- /* q3map_lightmapSampleSffset <value> */
+ /* q3map_lightmapSampleOffset <value> */
else if( !Q_stricmp( token, "q3map_lightmapSampleOffset" ) )
{
GetTokenAppend( shaderText, qfalse );
//% Sys_Printf( "Failed to map axis %d onto patch\n", bestAxis );
}
- /* get lightmap sample size */
- if( ds->sampleSize <= 0 )
+ /* calculate lightmap sample size */
+ if( ds->shaderInfo->lightmapSampleSize > 0 ) /* shader value overrides every other */
+ ds->sampleSize = ds->shaderInfo->lightmapSampleSize;
+ else if( ds->sampleSize <= 0 ) /* may contain the entity asigned value */
+ ds->sampleSize = sampleSize; /* otherwise use global default */
+
+ if( ds->lightmapScale > 0.0f ) /* apply surface lightmap scaling factor */
{
- ds->sampleSize = sampleSize;
- if( ds->shaderInfo->lightmapSampleSize )
- ds->sampleSize = ds->shaderInfo->lightmapSampleSize;
- if( ds->lightmapScale > 0 )
- ds->sampleSize *= ds->lightmapScale;
- if( ds->sampleSize <= 0 )
- ds->sampleSize = 1;
- if(ds->sampleSize < minSampleSize)
- ds->sampleSize = minSampleSize;
- if( ds->sampleSize > 16384 ) /* powers of 2 are preferred */
- ds->sampleSize = 16384;
+ ds->sampleSize = ds->lightmapScale * (float)ds->sampleSize;
+ ds->lightmapScale = 0; /* applied */
}
+
+ if( ds->sampleSize < minSampleSize )
+ ds->sampleSize = minSampleSize;
+
+ if( ds->sampleSize < 1 )
+ ds->sampleSize = 1;
+
+ if( ds->sampleSize > 16384 ) /* powers of 2 are preferred */
+ ds->sampleSize = 16384;
}
}
ds->mapBrush = b;
ds->sideRef = AllocSideRef( s, NULL );
ds->fogNum = -1;
+ ds->sampleSize = b->lightmapSampleSize;
ds->lightmapScale = b->lightmapScale;
ds->numVerts = w->numpoints;
ds->verts = safe_malloc( ds->numVerts * sizeof( *ds->verts ) );
ds->celShader = b->celShader;
/* set shade angle */
- if( si->shadeAngleDegrees )
- ds->shadeAngleDegrees = ds->shadeAngleDegrees;
- else
- ds->shadeAngleDegrees = b->shadeAngleDegrees; /* otherwise it's 0 */
+ if( b->shadeAngleDegrees > 0.0f )
+ ds->shadeAngleDegrees = b->shadeAngleDegrees;
/* ydnar: gs mods: moved st biasing elsewhere */
return ds;
ds->shaderInfo = si;
ds->mapMesh = p;
+ ds->sampleSize = p->lightmapSampleSize;
ds->lightmapScale = p->lightmapScale; /* ydnar */
ds->patchWidth = mesh->width;
ds->patchHeight = mesh->height;
}
/* insert the model */
- InsertModel( (char *) model->model, 0, transform, NULL, ds->celShader, ds->entityNum, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0 );
+ InsertModel( (char *) model->model, 0, transform, NULL, ds->celShader, ds->entityNum, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0, 0 );
/* return to sender */
return 1;
m4x4_scale_for_vec3( transform, scale );
/* add the model to the bsp */
- InsertModel( foliage->model, 0, transform, NULL, NULL, src->entityNum, src->castShadows, src->recvShadows, 0, src->lightmapScale, 0 );
+ InsertModel( foliage->model, 0, transform, NULL, NULL, src->entityNum, src->castShadows, src->recvShadows, 0, src->lightmapScale, 0, 0 );
/* walk each new surface */
for( i = oldNumMapDrawSurfs; i < numMapDrawSurfs; i++ )
ds->planeNum = seed->planeNum;
ds->fogNum = seed->fogNum;
ds->sampleSize = seed->sampleSize;
+ ds->shadeAngleDegrees = seed->shadeAngleDegrees;
ds->verts = verts;
ds->indexes = indexes;
VectorCopy( seed->lightmapAxis, ds->lightmapAxis );