apply all of VorteX's changes except deviance (that one sucks :P)

git-svn-id: svn://svn.icculus.org/netradiant/trunk@237 61c419a2-8eb2-4b30-bcec-8cead039b335
This commit is contained in:
divverent 2009-03-29 18:08:19 +00:00
parent 7e4c830250
commit f560e2703b
27 changed files with 869 additions and 3625 deletions

View File

@ -46,7 +46,7 @@ game_t struct
".darkplaces ", /* unix home sub-dir */ ".darkplaces ", /* unix home sub-dir */
"darkplaces", /* magic path word */ "darkplaces", /* magic path word */
"scripts", /* shader directory */ "scripts", /* shader directory */
64, /* max lightmapped surface verts */ 999, /* max lightmapped surface verts */
999, /* max surface verts */ 999, /* max surface verts */
6000, /* max surface indexes */ 6000, /* max surface indexes */
qfalse, /* flares */ qfalse, /* flares */

View File

@ -115,6 +115,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -150,6 +150,14 @@ game_t struct
2.2f, /* lightmap gamma */ 2.2f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -69,6 +69,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"RBSP", /* bsp file prefix */ "RBSP", /* bsp file prefix */
1, /* bsp file version */ 1, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -66,6 +66,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"RBSP", /* bsp file prefix */ "RBSP", /* bsp file prefix */
1, /* bsp file version */ 1, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -65,6 +65,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qtrue, /* disable shader lightstyles hack */
qtrue, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */
@ -131,6 +139,7 @@ game_t struct
{ "nodlight", 0, 0, Q_SURF_NODLIGHT, 0, 0, 0 }, { "nodlight", 0, 0, Q_SURF_NODLIGHT, 0, 0, 0 },
{ "dust", 0, 0, Q_SURF_DUST, 0, 0, 0 }, { "dust", 0, 0, Q_SURF_DUST, 0, 0, 0 },
/* null */ /* null */
{ NULL, 0, 0, 0, 0, 0, 0 } { NULL, 0, 0, 0, 0, 0, 0 }
} }

View File

@ -117,6 +117,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"FBSP", /* bsp file prefix */ "FBSP", /* bsp file prefix */
1, /* bsp file version */ 1, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -114,6 +114,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -66,6 +66,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
47, /* bsp file version */ 47, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -141,6 +141,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"RBSP", /* bsp file prefix */ "RBSP", /* bsp file prefix */
1, /* bsp file version */ 1, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -114,6 +114,14 @@ game_t struct
2.0f, /* lightmap gamma */ 2.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qtrue, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qtrue, /* compile deluxemaps */
0, /* deluxemaps default mode */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -72,6 +72,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -131,6 +131,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -68,6 +68,14 @@ game_t struct
1.0f, /* lightmap gamma */ 1.0f, /* lightmap gamma */
1.0f, /* lightmap exposure */ 1.0f, /* lightmap exposure */
1.0f, /* lightmap compensate */ 1.0f, /* lightmap compensate */
1.0f, /* lightgrid scale */
1.0f, /* lightgrid ambient scale */
qfalse, /* disable shader lightstyles hack */
qfalse, /* keep light entities on bsp */
8, /* default patchMeta subdivisions tolerance */
qfalse, /* patch casting enabled */
qfalse, /* compile deluxemaps */
0, /* deluxemaps default mode */
"IBSP", /* bsp file prefix */ "IBSP", /* bsp file prefix */
46, /* bsp file version */ 46, /* bsp file version */
qfalse, /* cod-style lump len/ofs order */ qfalse, /* cod-style lump len/ofs order */

View File

@ -314,6 +314,14 @@ void CreateEntityLights( void )
flags &= ~LIGHT_SURFACES; flags &= ~LIGHT_SURFACES;
} }
/* vortex: unnormalized? */
if (spawnflags & 32)
flags |= LIGHT_UNNORMALIZED;
/* vortex: distance atten? */
if (spawnflags & 64)
flags |= LIGHT_ATTEN_DISTANCE;
/* store the flags */ /* store the flags */
light->flags = flags; light->flags = flags;
@ -385,14 +393,16 @@ void CreateEntityLights( void )
if( _color && _color[ 0 ] ) if( _color && _color[ 0 ] )
{ {
sscanf( _color, "%f %f %f", &light->color[ 0 ], &light->color[ 1 ], &light->color[ 2 ] ); sscanf( _color, "%f %f %f", &light->color[ 0 ], &light->color[ 1 ], &light->color[ 2 ] );
if (!(light->flags & LIGHT_UNNORMALIZED))
{
ColorNormalize( light->color, light->color ); ColorNormalize( light->color, light->color );
} }
}
else else
light->color[ 0 ] = light->color[ 1 ] = light->color[ 2 ] = 1.0f; light->color[ 0 ] = light->color[ 1 ] = light->color[ 2 ] = 1.0f;
intensity = intensity * pointScale; intensity = intensity * pointScale;
light->photons = intensity; light->photons = intensity;
light->type = EMIT_POINT; light->type = EMIT_POINT;
/* set falloff threshold */ /* set falloff threshold */
@ -741,6 +751,7 @@ int LightContributionToSample( trace_t *trace )
/* clear color */ /* clear color */
VectorClear( trace->color ); VectorClear( trace->color );
VectorClear( trace->colorNoShadow );
/* ydnar: early out */ /* ydnar: early out */
if( !(light->flags & LIGHT_SURFACES) || light->envelope <= 0.0f ) if( !(light->flags & LIGHT_SURFACES) || light->envelope <= 0.0f )
@ -766,7 +777,6 @@ int LightContributionToSample( trace_t *trace )
float d; float d;
vec3_t pushedOrigin; vec3_t pushedOrigin;
/* project sample point into light plane */ /* project sample point into light plane */
d = DotProduct( trace->origin, light->normal ) - light->dist; d = DotProduct( trace->origin, light->normal ) - light->dist;
if( d < 3.0f ) if( d < 3.0f )
@ -882,7 +892,6 @@ int LightContributionToSample( trace_t *trace )
float distByNormal, radiusAtDist, sampleRadius; float distByNormal, radiusAtDist, sampleRadius;
vec3_t pointAtDist, distToSample; vec3_t pointAtDist, distToSample;
/* do cone calculation */ /* do cone calculation */
distByNormal = -DotProduct( trace->displacement, light->normal ); distByNormal = -DotProduct( trace->displacement, light->normal );
if( distByNormal < 0.0f ) if( distByNormal < 0.0f )
@ -923,6 +932,9 @@ int LightContributionToSample( trace_t *trace )
if( add <= 0.0f ) if( add <= 0.0f )
return 0; return 0;
/* VorteX: set noShadow color */
VectorScale(light->color, add, trace->colorNoShadow);
/* setup trace */ /* setup trace */
trace->testAll = qtrue; trace->testAll = qtrue;
VectorScale( light->color, add, trace->color ); VectorScale( light->color, add, trace->color );
@ -943,6 +955,9 @@ int LightContributionToSample( trace_t *trace )
return 1; return 1;
} }
/* VorteX: set noShadow color */
VectorScale(light->color, add, trace->colorNoShadow);
/* ydnar: changed to a variable number */ /* ydnar: changed to a variable number */
if( add <= 0.0f || (add <= light->falloffTolerance && (light->flags & LIGHT_FAST_ACTUAL)) ) if( add <= 0.0f || (add <= light->falloffTolerance && (light->flags & LIGHT_FAST_ACTUAL)) )
return 0; return 0;
@ -1409,7 +1424,7 @@ void TraceGrid( int num )
trace.normal[2]=-1; trace.normal[2]=-1;
} }
f = FloodLightForSample(&trace); f = FloodLightForSample(&trace, floodlightDistance, floodlight_lowquality);
contributions[ numCon ].color[0]=col[0]*f; contributions[ numCon ].color[0]=col[0]*f;
contributions[ numCon ].color[1]=col[1]*f; contributions[ numCon ].color[1]=col[1]*f;
@ -1470,6 +1485,9 @@ void TraceGrid( int num )
/* ambient light will be at 1/4 the value of directed light */ /* ambient light will be at 1/4 the value of directed light */
/* (ydnar: nuke this in favor of more dramatic lighting?) */ /* (ydnar: nuke this in favor of more dramatic lighting?) */
/* (PM: how about actually making it work? d=1 when it got here for single lights/sun :P */
// d = 0.25f;
/* (Hobbes: always setting it to .25 is hardly any better) */
d = 0.25f * (1.0f - d); d = 0.25f * (1.0f - d);
VectorMA( gp->ambient[ j ], d, contributions[ i ].color, gp->ambient[ j ] ); VectorMA( gp->ambient[ j ], d, contributions[ i ].color, gp->ambient[ j ] );
} }
@ -1487,8 +1505,10 @@ void TraceGrid( int num )
for( j = 0; j < 3; j++ ) for( j = 0; j < 3; j++ )
if( color[ j ] < minGridLight[ j ] ) if( color[ j ] < minGridLight[ j ] )
color[ j ] = minGridLight[ j ]; color[ j ] = minGridLight[ j ];
ColorToBytes( color, bgp->ambient[ i ], 1.0f );
ColorToBytes( gp->directed[ i ], bgp->directed[ i ], 1.0f ); /* vortex: apply gridscale and gridambientscale here */
ColorToBytes( color, bgp->ambient[ i ], gridScale*gridAmbientScale );
ColorToBytes( gp->directed[ i ], bgp->directed[ i ], gridScale );
} }
/* debug code */ /* debug code */
@ -1711,12 +1731,8 @@ void LightWorld( void )
RunThreadsOnIndividual( numRawLightmaps, qtrue, DirtyRawLightmap ); RunThreadsOnIndividual( numRawLightmaps, qtrue, DirtyRawLightmap );
} }
/* floodlight them up */ /* floodlight pass */
if( floodlighty ) FloodlightRawLightmaps();
{
Sys_Printf( "--- FloodlightRawLightmap ---\n" );
RunThreadsOnIndividual( numRawLightmaps, qtrue, FloodLightRawLightmap );
}
/* ydnar: set up light envelopes */ /* ydnar: set up light envelopes */
SetupEnvelopes( qfalse, fast ); SetupEnvelopes( qfalse, fast );
@ -1832,12 +1848,64 @@ int LightMain( int argc, char **argv )
/* note it */ /* note it */
Sys_Printf( "--- Light ---\n" ); Sys_Printf( "--- Light ---\n" );
Sys_Printf( "--- ProcessGameSpecific ---\n" );
/* set standard game flags */ /* set standard game flags */
wolfLight = game->wolfLight; wolfLight = game->wolfLight;
if (wolfLight == qtrue)
Sys_Printf( " lightning model: wolf\n" );
else
Sys_Printf( " lightning model: quake3\n" );
lmCustomSize = game->lightmapSize; lmCustomSize = game->lightmapSize;
Sys_Printf( " lightmap size: %d x %d pixels\n", lmCustomSize, lmCustomSize );
lightmapGamma = game->lightmapGamma; lightmapGamma = game->lightmapGamma;
Sys_Printf( " lightning gamma: %f\n", lightmapGamma );
lightmapCompensate = game->lightmapCompensate; lightmapCompensate = game->lightmapCompensate;
Sys_Printf( " lightning compensation: %f\n", lightmapCompensate );
lightmapExposure = game->lightmapExposure;
Sys_Printf( " lightning exposure: %f\n", lightmapExposure );
gridScale = game->gridScale;
Sys_Printf( " lightgrid scale: %f\n", gridScale );
gridAmbientScale = game->gridAmbientScale;
Sys_Printf( " lightgrid ambient scale: %f\n", gridAmbientScale );
noStyles = game->noStyles;
if (noStyles == qtrue)
Sys_Printf( " shader lightstyles hack: disabled\n" );
else
Sys_Printf( " shader lightstyles hack: enabled\n" );
keepLights = game->keepLights;
if (keepLights == qtrue)
Sys_Printf( " keep lights: enabled\n" );
else
Sys_Printf( " keep lights: disabled\n" );
patchShadows = game->patchShadows;
if (patchShadows == qtrue)
Sys_Printf( " patch shadows: enabled\n" );
else
Sys_Printf( " patch shadows: disabled\n" );
deluxemap = game->deluxeMap;
deluxemode = game->deluxeMode;
if (deluxemap == qtrue)
{
if (deluxemode)
Sys_Printf( " deluxemapping: enabled with tangentspace deluxemaps\n" );
else
Sys_Printf( " deluxemapping: enabled with modelspace deluxemaps\n" );
}
else
Sys_Printf( " deluxemapping: disabled\n" );
Sys_Printf( "--- ProcessCommandLine ---\n" );
/* process commandline arguments */ /* process commandline arguments */
for( i = 1; i < (argc - 1); i++ ) for( i = 1; i < (argc - 1); i++ )
@ -1886,6 +1954,22 @@ int LightMain( int argc, char **argv )
i++; i++;
} }
else if( !strcmp( argv[ i ], "-gridscale" ) )
{
f = atof( argv[ i + 1 ] );
Sys_Printf( "Grid lightning scaled by %f\n", f );
gridScale *= f;
i++;
}
else if( !strcmp( argv[ i ], "-gridambientscale" ) )
{
f = atof( argv[ i + 1 ] );
Sys_Printf( "Grid ambient lightning scaled by %f\n", f );
gridAmbientScale *= f;
i++;
}
else if( !strcmp( argv[ i ], "-gamma" ) ) else if( !strcmp( argv[ i ], "-gamma" ) )
{ {
f = atof( argv[ i + 1 ] ); f = atof( argv[ i + 1 ] );
@ -1955,12 +2039,6 @@ int LightMain( int argc, char **argv )
Sys_Printf( "Dark lightmap seams enabled\n" ); Sys_Printf( "Dark lightmap seams enabled\n" );
} }
else if( !strcmp( argv[ i ], "-shadeangle" ) ) else if( !strcmp( argv[ i ], "-shadeangle" ) )
{ {
shadeAngleDegrees = atof( argv[ i + 1 ] ); shadeAngleDegrees = atof( argv[ i + 1 ] );
@ -1993,13 +2071,28 @@ int LightMain( int argc, char **argv )
Sys_Printf( "Approximating lightmaps within a byte tolerance of %d\n", approximateTolerance ); Sys_Printf( "Approximating lightmaps within a byte tolerance of %d\n", approximateTolerance );
i++; i++;
} }
else if( !strcmp( argv[ i ], "-deluxe" ) || !strcmp( argv[ i ], "-deluxemap" ) ) else if( !strcmp( argv[ i ], "-deluxe" ) || !strcmp( argv[ i ], "-deluxemap" ) )
{ {
deluxemap = qtrue; deluxemap = qtrue;
Sys_Printf( "Generating deluxemaps for average light direction\n" ); Sys_Printf( "Generating deluxemaps for average light direction\n" );
} }
else if( !strcmp( argv[ i ], "-deluxemode" ))
{
deluxemode = atoi( argv[ i + 1 ] );
if (deluxemode == 0 || deluxemode > 1 || deluxemode < 0)
{
Sys_Printf( "Generating modelspace deluxemaps\n" );
deluxemode = 0;
}
else
Sys_Printf( "Generating tangentspace deluxemaps\n" );
i++;
}
else if( !strcmp( argv[ i ], "-nodeluxe" ) || !strcmp( argv[ i ], "-nodeluxemap" ) )
{
deluxemap = qfalse;
Sys_Printf( "Disabling generating of deluxemaps for average light direction\n" );
}
else if( !strcmp( argv[ i ], "-external" ) ) else if( !strcmp( argv[ i ], "-external" ) )
{ {
externalLightmaps = qtrue; externalLightmaps = qtrue;
@ -2234,6 +2327,12 @@ int LightMain( int argc, char **argv )
i++; i++;
Sys_Printf( "Minimum lightmap sample size set to %dx%d units\n", minSampleSize, minSampleSize ); Sys_Printf( "Minimum lightmap sample size set to %dx%d units\n", minSampleSize, minSampleSize );
} }
else if( !strcmp( argv[ i ], "-samplescale" ) )
{
sampleScale = atoi( argv[ i + 1 ] );
i++;
Sys_Printf( "Lightmaps sample scale set to %d\n", sampleScale);
}
else if( !strcmp( argv[ i ], "-novertex" ) ) else if( !strcmp( argv[ i ], "-novertex" ) )
{ {
noVertexLighting = qtrue; noVertexLighting = qtrue;
@ -2269,6 +2368,16 @@ int LightMain( int argc, char **argv )
noStyles = qtrue; noStyles = qtrue;
Sys_Printf( "Disabling lightstyles\n" ); Sys_Printf( "Disabling lightstyles\n" );
} }
else if( !strcmp( argv[ i ], "-style" ) || !strcmp( argv[ i ], "-styles" ) )
{
noStyles = qfalse;
Sys_Printf( "Enabling lightstyles\n" );
}
else if( !strcmp( argv[ i ], "-keeplights" ))
{
keepLights = qtrue;
Sys_Printf( "Leaving light entities on map after compile\n" );
}
else if( !strcmp( argv[ i ], "-cpma" ) ) else if( !strcmp( argv[ i ], "-cpma" ) )
{ {
cpmaHack = qtrue; cpmaHack = qtrue;

View File

@ -56,7 +56,7 @@ several games based on the Quake III Arena engine, in the form of "Q3Map2."
#define GROW_TRACE_NODES 16384 //% 16384 #define GROW_TRACE_NODES 16384 //% 16384
#define GROW_NODE_ITEMS 16 //% 256 #define GROW_NODE_ITEMS 16 //% 256
#define MAX_TW_VERTS 12 #define MAX_TW_VERTS 24 // vortex: increased from 12 to 24 for ability co compile some insane maps with large curve count
#define TRACE_ON_EPSILON 0.1f #define TRACE_ON_EPSILON 0.1f

View File

@ -2107,7 +2107,7 @@ void IlluminateRawLightmap( int rawLightmapNum )
if(DotProduct(normal, trace.direction) > 0) // do not take light from the back side if(DotProduct(normal, trace.direction) > 0) // do not take light from the back side
{ {
/* color to grayscale (photoshop rgb weighting) */ /* color to grayscale (photoshop rgb weighting) */
brightness = trace.color[ 0 ] * 0.3f + trace.color[ 1 ] * 0.59f + trace.color[ 2 ] * 0.11f; brightness = trace.colorNoShadow[ 0 ] * 0.3f + trace.colorNoShadow[ 1 ] * 0.59f + trace.colorNoShadow[ 2 ] * 0.11f;
brightness *= (1.0 / 255.0); brightness *= (1.0 / 255.0);
VectorScale( trace.direction, brightness, trace.direction ); VectorScale( trace.direction, brightness, trace.direction );
VectorAdd( deluxel, trace.direction, deluxel ); VectorAdd( deluxel, trace.direction, deluxel );
@ -2346,56 +2346,8 @@ void IlluminateRawLightmap( int rawLightmapNum )
/* free light list */ /* free light list */
FreeTraceLights( &trace ); FreeTraceLights( &trace );
/* ----------------------------------------------------------------- /* floodlight pass */
floodlight pass FloodlightIlluminateLightmap(lm);
----------------------------------------------------------------- */
if( floodlighty )
{
/* walk lightmaps */
for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
{
/* early out */
if( lm->superLuxels[ lightmapNum ] == NULL )
continue;
/* apply floodlight to each luxel */
for( y = 0; y < lm->sh; y++ )
{
for( x = 0; x < lm->sw; x++ )
{
/* get cluster */
cluster = SUPER_CLUSTER( x, y );
if( *cluster < 0 )
continue;
/* get particulars */
luxel = SUPER_LUXEL( lightmapNum, x, y );
floodlight = SUPER_FLOODLIGHT( x, y );
flood[0]=floodlightRGB[0]*floodlightIntensity;
flood[1]=floodlightRGB[1]*floodlightIntensity;
flood[2]=floodlightRGB[2]*floodlightIntensity;
/* scale light value */
VectorScale( flood, *floodlight, flood );
luxel[0]+=flood[0];
luxel[1]+=flood[1];
luxel[2]+=flood[2];
if (luxel[3]==0) luxel[3]=1;
if(deluxemap)
{
brightness = flood[ 0 ] * 0.3f + flood[ 1 ] * 0.59f + flood[ 2 ] * 0.11f;
brightness *= (1.0 / 255.0);
VectorScale( normal, brightness, temp );
VectorAdd( deluxel, temp, deluxel );
}
}
}
}
}
if (debugnormals) if (debugnormals)
{ {
@ -3908,24 +3860,145 @@ void SetupFloodLight( void )
VectorNormalize(floodlightRGB,floodlightRGB); VectorNormalize(floodlightRGB,floodlightRGB);
} }
//27 - lighttracer style ambient occlusion light hack. /*
//Kudos to the dirtmapping author for most of this source. FloodLightForSample()
void FloodLightRawLightmap( int rawLightmapNum ) calculates floodlight value for a given sample
once again, kudos to the dirtmapping coder
*/
float FloodLightForSample( trace_t *trace , float floodLightDistance, qboolean floodLightLowQuality)
{ {
int i, x, y, sx, sy, *cluster; int i;
float *origin, *normal, *floodlight, *floodlight2, average, samples; float d;
rawLightmap_t *lm; float contribution;
int sub = 0;
float gatherLight, outLight;
vec3_t normal, worldUp, myUp, myRt, direction, displacement;
float dd;
int vecs = 0;
gatherLight=0;
/* dummy check */
//if( !dirty )
// return 1.0f;
if( trace == NULL || trace->cluster < 0 )
return 0.0f;
/* setup */
dd = floodLightDistance;
VectorCopy( trace->normal, normal );
/* check if the normal is aligned to the world-up */
if( normal[ 0 ] == 0.0f && normal[ 1 ] == 0.0f )
{
if( normal[ 2 ] == 1.0f )
{
VectorSet( myRt, 1.0f, 0.0f, 0.0f );
VectorSet( myUp, 0.0f, 1.0f, 0.0f );
}
else if( normal[ 2 ] == -1.0f )
{
VectorSet( myRt, -1.0f, 0.0f, 0.0f );
VectorSet( myUp, 0.0f, 1.0f, 0.0f );
}
}
else
{
VectorSet( worldUp, 0.0f, 0.0f, 1.0f );
CrossProduct( normal, worldUp, myRt );
VectorNormalize( myRt, myRt );
CrossProduct( myRt, normal, myUp );
VectorNormalize( myUp, myUp );
}
/* vortex: optimise floodLightLowQuality a bit */
if ( floodLightLowQuality == qtrue )
{
/* iterate through ordered vectors */
for( i = 0; i < numFloodVectors; i++ )
if (rand()%10 != 0 ) continue;
}
else
{
/* iterate through ordered vectors */
for( i = 0; i < numFloodVectors; i++ )
{
vecs++;
/* transform vector into tangent space */
direction[ 0 ] = myRt[ 0 ] * floodVectors[ i ][ 0 ] + myUp[ 0 ] * floodVectors[ i ][ 1 ] + normal[ 0 ] * floodVectors[ i ][ 2 ];
direction[ 1 ] = myRt[ 1 ] * floodVectors[ i ][ 0 ] + myUp[ 1 ] * floodVectors[ i ][ 1 ] + normal[ 1 ] * floodVectors[ i ][ 2 ];
direction[ 2 ] = myRt[ 2 ] * floodVectors[ i ][ 0 ] + myUp[ 2 ] * floodVectors[ i ][ 1 ] + normal[ 2 ] * floodVectors[ i ][ 2 ];
/* set endpoint */
VectorMA( trace->origin, dd, direction, trace->end );
//VectorMA( trace->origin, 1, direction, trace->origin );
SetupTrace( trace );
/* trace */
TraceLine( trace );
contribution=1;
if (trace->compileFlags & C_SKY )
{
contribution=1.0f;
}
else if ( trace->opaque )
{
VectorSubtract( trace->hit, trace->origin, displacement );
d=VectorLength( displacement );
// d=trace->distance;
//if (d>256) gatherDirt+=1;
contribution=d/dd;
if (contribution>1) contribution=1.0f;
//gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
}
gatherLight+=contribution;
}
}
/* early out */
if( gatherLight <= 0.0f )
return 0.0f;
sub=vecs;
if (sub<1) sub=1;
gatherLight/=(sub);
outLight=gatherLight;
if( outLight > 1.0f )
outLight = 1.0f;
/* return to sender */
return outLight;
}
/*
FloodLightRawLightmap
lighttracer style ambient occlusion light hack.
Kudos to the dirtmapping author for most of this source.
VorteX: modified to floodlight up custom surfaces (q3map_floodLight)
VorteX: fixed problems with deluxemapping
*/
// floodlight pass on a lightmap
void FloodLightRawLightmapPass( rawLightmap_t *lm , vec3_t lmFloodLightRGB, float lmFloodLightIntensity, float lmFloodLightDistance, qboolean lmFloodLightLowQuality, float floodlightDirectionScale)
{
int i, x, y, *cluster;
float *origin, *normal, *floodlight, floodLightAmount;
surfaceInfo_t *info; surfaceInfo_t *info;
trace_t trace; trace_t trace;
// int sx, sy;
/* bail if this number exceeds the number of raw lightmaps */ // float samples, average, *floodlight2;
if( rawLightmapNum >= numRawLightmaps )
return;
/* get lightmap */
lm = &rawLightmaps[ rawLightmapNum ];
memset(&trace,0,sizeof(trace_t)); memset(&trace,0,sizeof(trace_t));
/* setup trace */ /* setup trace */
trace.testOcclusion = qtrue; trace.testOcclusion = qtrue;
trace.forceSunlight = qfalse; trace.forceSunlight = qfalse;
@ -3952,7 +4025,7 @@ void FloodLightRawLightmap( int rawLightmapNum )
} }
} }
/* gather dirt */ /* gather floodlight */
for( y = 0; y < lm->sh; y++ ) for( y = 0; y < lm->sh; y++ )
{ {
for( x = 0; x < lm->sw; x++ ) for( x = 0; x < lm->sw; x++ )
@ -3975,16 +4048,22 @@ void FloodLightRawLightmap( int rawLightmapNum )
VectorCopy( origin, trace.origin ); VectorCopy( origin, trace.origin );
VectorCopy( normal, trace.normal ); VectorCopy( normal, trace.normal );
/* get floodlight */
floodLightAmount = FloodLightForSample( &trace , lmFloodLightDistance, lmFloodLightLowQuality)*lmFloodLightIntensity;
/* add floodlight */
/* get dirt */ floodlight[0] += lmFloodLightRGB[0]*floodLightAmount;
*floodlight = FloodLightForSample( &trace ); floodlight[1] += lmFloodLightRGB[1]*floodLightAmount;
floodlight[2] += lmFloodLightRGB[2]*floodLightAmount;
floodlight[3] += floodlightDirectionScale;
} }
} }
/* testing no filtering */ /* testing no filtering */
return; return;
#if 0
/* filter "dirt" */ /* filter "dirt" */
for( y = 0; y < lm->sh; y++ ) for( y = 0; y < lm->sh; y++ )
{ {
@ -3992,7 +4071,7 @@ void FloodLightRawLightmap( int rawLightmapNum )
{ {
/* get luxel */ /* get luxel */
cluster = SUPER_CLUSTER( x, y ); cluster = SUPER_CLUSTER( x, y );
floodlight = SUPER_FLOODLIGHT( x, y ); floodlight = SUPER_FLOODLIGHT(x, y );
/* filter dirt by adjacency to unmapped luxels */ /* filter dirt by adjacency to unmapped luxels */
average = *floodlight; average = *floodlight;
@ -4031,118 +4110,97 @@ void FloodLightRawLightmap( int rawLightmapNum )
*floodlight = average / samples; *floodlight = average / samples;
} }
} }
#endif
}
void FloodLightRawLightmap( int rawLightmapNum )
{
rawLightmap_t *lm;
/* bail if this number exceeds the number of raw lightmaps */
if( rawLightmapNum >= numRawLightmaps )
return;
/* get lightmap */
lm = &rawLightmaps[ rawLightmapNum ];
/* global pass */
if (floodlighty && floodlightIntensity)
FloodLightRawLightmapPass(lm, floodlightRGB, floodlightIntensity, floodlightDistance, floodlight_lowquality, 0);
/* custom pass */
if (lm->floodlightIntensity)
{
FloodLightRawLightmapPass(lm, lm->floodlightRGB, lm->floodlightIntensity, lm->floodlightDistance, qfalse, lm->floodlightDirectionScale);
numSurfacesFloodlighten += 1;
}
}
void FloodlightRawLightmaps()
{
Sys_Printf( "--- FloodlightRawLightmap ---\n" );
numSurfacesFloodlighten = 0;
RunThreadsOnIndividual( numRawLightmaps, qtrue, FloodLightRawLightmap );
Sys_Printf( "%9d custom lightmaps floodlighted\n", numSurfacesFloodlighten );
} }
/* /*
FloodLightForSample() FloodLightIlluminate()
calculates floodlight value for a given sample illuminate floodlight into lightmap luxels
once again, kudos to the dirtmapping coder
*/ */
float FloodLightForSample( trace_t *trace )
void FloodlightIlluminateLightmap( rawLightmap_t *lm )
{ {
int i; float *luxel, *floodlight, *deluxel, *normal;
float d; int *cluster;
float contribution; float brightness;
int sub = 0; vec3_t lightvector;
float gatherLight, outLight; int x, y, lightmapNum;
vec3_t normal, worldUp, myUp, myRt, direction, displacement;
float dd;
int vecs = 0;
gatherLight=0; /* walk lightmaps */
/* dummy check */ for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
//if( !dirty )
// return 1.0f;
if( trace == NULL || trace->cluster < 0 )
return 0.0f;
/* setup */
dd = floodlightDistance;
VectorCopy( trace->normal, normal );
/* check if the normal is aligned to the world-up */
if( normal[ 0 ] == 0.0f && normal[ 1 ] == 0.0f )
{ {
if( normal[ 2 ] == 1.0f )
{
VectorSet( myRt, 1.0f, 0.0f, 0.0f );
VectorSet( myUp, 0.0f, 1.0f, 0.0f );
}
else if( normal[ 2 ] == -1.0f )
{
VectorSet( myRt, -1.0f, 0.0f, 0.0f );
VectorSet( myUp, 0.0f, 1.0f, 0.0f );
}
}
else
{
VectorSet( worldUp, 0.0f, 0.0f, 1.0f );
CrossProduct( normal, worldUp, myRt );
VectorNormalize( myRt, myRt );
CrossProduct( myRt, normal, myUp );
VectorNormalize( myUp, myUp );
}
/* iterate through ordered vectors */
for( i = 0; i < numFloodVectors; i++ )
{
if (floodlight_lowquality==qtrue)
{
if (rand()%10 != 0 ) continue;
}
vecs++;
/* transform vector into tangent space */
direction[ 0 ] = myRt[ 0 ] * floodVectors[ i ][ 0 ] + myUp[ 0 ] * floodVectors[ i ][ 1 ] + normal[ 0 ] * floodVectors[ i ][ 2 ];
direction[ 1 ] = myRt[ 1 ] * floodVectors[ i ][ 0 ] + myUp[ 1 ] * floodVectors[ i ][ 1 ] + normal[ 1 ] * floodVectors[ i ][ 2 ];
direction[ 2 ] = myRt[ 2 ] * floodVectors[ i ][ 0 ] + myUp[ 2 ] * floodVectors[ i ][ 1 ] + normal[ 2 ] * floodVectors[ i ][ 2 ];
/* set endpoint */
VectorMA( trace->origin, dd, direction, trace->end );
//VectorMA( trace->origin, 1, direction, trace->origin );
SetupTrace( trace );
/* trace */
TraceLine( trace );
contribution=1;
if (trace->compileFlags & C_SKY )
{
contribution=1.0f;
}
else if ( trace->opaque )
{
VectorSubtract( trace->hit, trace->origin, displacement );
d=VectorLength( displacement );
// d=trace->distance;
//if (d>256) gatherDirt+=1;
contribution=d/dd;
if (contribution>1) contribution=1.0f;
//gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
}
gatherLight+=contribution;
}
/* early out */ /* early out */
if( gatherLight <= 0.0f ) if( lm->superLuxels[ lightmapNum ] == NULL )
return 0.0f; continue;
sub=vecs; /* apply floodlight to each luxel */
for( y = 0; y < lm->sh; y++ )
{
for( x = 0; x < lm->sw; x++ )
{
/* get floodlight */
floodlight = SUPER_FLOODLIGHT( x, y );
if (!floodlight[0] && !floodlight[1] && !floodlight[2])
continue;
if (sub<1) sub=1; /* get cluster */
gatherLight/=(sub); cluster = SUPER_CLUSTER( x, y );
outLight=gatherLight; /* only process mapped luxels */
if( outLight > 1.0f ) if( *cluster < 0 )
outLight = 1.0f; continue;
/* return to sender */ /* get particulars */
return outLight; luxel = SUPER_LUXEL( lightmapNum, x, y );
deluxel = SUPER_DELUXEL( x, y );
/* add to lightmap */
luxel[0]+=floodlight[0];
luxel[1]+=floodlight[1];
luxel[2]+=floodlight[2];
if (luxel[3]==0) luxel[3]=1;
/* add to deluxemap */
if (deluxemap && floodlight[3] > 0)
{
normal = SUPER_NORMAL( x, y );
brightness = floodlight[ 0 ] * 0.3f + floodlight[ 1 ] * 0.59f + floodlight[ 2 ] * 0.11f;
brightness *= ( 1.0f / 255.0f ) * floodlight[3];
VectorScale( normal, brightness, lightvector );
VectorAdd( deluxel, lightvector, deluxel );
}
}
}
}
} }

View File

@ -1111,12 +1111,20 @@ void SetupSurfaceLightmaps( void )
lm->splotchFix = info->si->splotchFix; lm->splotchFix = info->si->splotchFix;
lm->firstLightSurface = numLightSurfaces; lm->firstLightSurface = numLightSurfaces;
lm->numLightSurfaces = 0; lm->numLightSurfaces = 0;
/* vortex: multiply lightmap sample size by -samplescale */
if (sampleScale > 0)
lm->sampleSize = info->sampleSize*sampleScale;
else
lm->sampleSize = info->sampleSize; lm->sampleSize = info->sampleSize;
lm->actualSampleSize = info->sampleSize; lm->actualSampleSize = lm->sampleSize;
lm->entityNum = info->entityNum; lm->entityNum = info->entityNum;
lm->recvShadows = info->recvShadows; lm->recvShadows = info->recvShadows;
lm->brightness = info->si->lmBrightness; lm->brightness = info->si->lmBrightness;
lm->filterRadius = info->si->lmFilterRadius; lm->filterRadius = info->si->lmFilterRadius;
VectorCopy(info->si->floodlightRGB, lm->floodlightRGB);
lm->floodlightDistance = info->si->floodlightDistance;
lm->floodlightIntensity = info->si->floodlightIntensity;
lm->floodlightDirectionScale = info->si->floodlightDirectionScale;
VectorCopy( info->axis, lm->axis ); VectorCopy( info->axis, lm->axis );
lm->plane = info->plane; lm->plane = info->plane;
VectorCopy( info->mins, lm->mins ); VectorCopy( info->mins, lm->mins );
@ -2295,7 +2303,7 @@ void StoreSurfaceLightmaps( void )
----------------------------------------------------------------- */ ----------------------------------------------------------------- */
/* note it */ /* note it */
Sys_FPrintf( SYS_VRB, "Subsampling..." ); Sys_Printf( "Subsampling..." );
/* walk the list of raw lightmaps */ /* walk the list of raw lightmaps */
numUsed = 0; numUsed = 0;
@ -2631,6 +2639,135 @@ void StoreSurfaceLightmaps( void )
} }
} }
/* -----------------------------------------------------------------
convert modelspace deluxemaps to tangentspace
----------------------------------------------------------------- */
/* note it */
if( !bouncing )
{
if( deluxemap && deluxemode == 1)
{
vec3_t worldUp, myNormal, myTangent, myBinormal;
float dist;
Sys_Printf( "converting..." );
for( i = 0; i < numRawLightmaps; i++ )
{
/* get lightmap */
lm = &rawLightmaps[ i ];
/* walk lightmap samples */
for( y = 0; y < lm->sh; y++ )
{
for( x = 0; x < lm->sw; x++ )
{
/* get normal and deluxel */
normal = SUPER_NORMAL(x, y);
cluster = SUPER_CLUSTER(x, y);
bspDeluxel = BSP_DELUXEL( x, y );
deluxel = SUPER_DELUXEL( x, y );
/* get normal */
VectorSet( myNormal, normal[0], normal[1], normal[2] );
/* get tangent vectors */
if( myNormal[ 0 ] == 0.0f && myNormal[ 1 ] == 0.0f )
{
if( myNormal[ 2 ] == 1.0f )
{
VectorSet( myTangent, 1.0f, 0.0f, 0.0f );
VectorSet( myBinormal, 0.0f, 1.0f, 0.0f );
}
else if( myNormal[ 2 ] == -1.0f )
{
VectorSet( myTangent, -1.0f, 0.0f, 0.0f );
VectorSet( myBinormal, 0.0f, 1.0f, 0.0f );
}
}
else
{
VectorSet( worldUp, 0.0f, 0.0f, 1.0f );
CrossProduct( myNormal, worldUp, myTangent );
VectorNormalize( myTangent, myTangent );
CrossProduct( myTangent, myNormal, myBinormal );
VectorNormalize( myBinormal, myBinormal );
}
/* project onto plane */
dist = -DotProduct(myTangent, myNormal);
VectorMA(myTangent, dist, myNormal, myTangent);
dist = -DotProduct(myBinormal, myNormal);
VectorMA(myBinormal, dist, myNormal, myBinormal);
/* renormalize */
VectorNormalize( myTangent, myTangent );
VectorNormalize( myBinormal, myBinormal );
/* convert modelspace deluxel to tangentspace */
dirSample[0] = bspDeluxel[0];
dirSample[1] = bspDeluxel[1];
dirSample[2] = bspDeluxel[2];
VectorNormalize(dirSample, dirSample);
/* fix tangents to world matrix */
if (myNormal[0] > 0 || myNormal[1] < 0 || myNormal[2] < 0)
VectorNegate(myTangent, myTangent);
/* build tangentspace vectors */
bspDeluxel[0] = DotProduct(dirSample, myTangent);
bspDeluxel[1] = DotProduct(dirSample, myBinormal);
bspDeluxel[2] = DotProduct(dirSample, myNormal);
}
}
}
}
}
/* -----------------------------------------------------------------
blend lightmaps
----------------------------------------------------------------- */
#ifdef sdfsdfwq312323
/* note it */
Sys_Printf( "blending..." );
for( i = 0; i < numRawLightmaps; i++ )
{
vec3_t myColor;
float myBrightness;
/* get lightmap */
lm = &rawLightmaps[ i ];
/* walk individual lightmaps */
for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
{
/* early outs */
if( lm->superLuxels[ lightmapNum ] == NULL )
continue;
/* walk lightmap samples */
for( y = 0; y < lm->sh; y++ )
{
for( x = 0; x < lm->sw; x++ )
{
/* get luxel */
bspLuxel = BSP_LUXEL( lightmapNum, x, y );
/* get color */
VectorNormalize(bspLuxel, myColor);
myBrightness = VectorLength(bspLuxel);
myBrightness *= (1 / 127.0f);
myBrightness = myBrightness*myBrightness;
myBrightness *= 127.0f;
VectorScale(myColor, myBrightness, bspLuxel);
}
}
}
}
#endif
/* ----------------------------------------------------------------- /* -----------------------------------------------------------------
collapse non-unique lightmaps collapse non-unique lightmaps
----------------------------------------------------------------- */ ----------------------------------------------------------------- */
@ -2638,7 +2775,7 @@ void StoreSurfaceLightmaps( void )
if( noCollapse == qfalse && deluxemap == qfalse ) if( noCollapse == qfalse && deluxemap == qfalse )
{ {
/* note it */ /* note it */
Sys_FPrintf( SYS_VRB, "collapsing..." ); Sys_Printf( "collapsing..." );
/* set all twin refs to null */ /* set all twin refs to null */
for( i = 0; i < numRawLightmaps; i++ ) for( i = 0; i < numRawLightmaps; i++ )
@ -2706,7 +2843,7 @@ void StoreSurfaceLightmaps( void )
----------------------------------------------------------------- */ ----------------------------------------------------------------- */
/* note it */ /* note it */
Sys_FPrintf( SYS_VRB, "sorting..." ); Sys_Printf( "sorting..." );
/* allocate a new sorted list */ /* allocate a new sorted list */
if( sortLightmaps == NULL ) if( sortLightmaps == NULL )
@ -2722,7 +2859,7 @@ void StoreSurfaceLightmaps( void )
----------------------------------------------------------------- */ ----------------------------------------------------------------- */
/* note it */ /* note it */
Sys_FPrintf( SYS_VRB, "allocating..." ); Sys_Printf( "allocating..." );
/* kill all existing output lightmaps */ /* kill all existing output lightmaps */
if( outLightmaps != NULL ) if( outLightmaps != NULL )
@ -2775,7 +2912,7 @@ void StoreSurfaceLightmaps( void )
----------------------------------------------------------------- */ ----------------------------------------------------------------- */
/* note it */ /* note it */
Sys_FPrintf( SYS_VRB, "storing..." ); Sys_Printf( "storing..." );
/* count the bsp lightmaps and allocate space */ /* count the bsp lightmaps and allocate space */
if( bspLightBytes != NULL ) if( bspLightBytes != NULL )
@ -2843,7 +2980,7 @@ void StoreSurfaceLightmaps( void )
} }
if( numExtLightmaps > 0 ) if( numExtLightmaps > 0 )
Sys_FPrintf( SYS_VRB, "\n" ); Sys_Printf( "\n" );
/* delete unused external lightmaps */ /* delete unused external lightmaps */
for( i = numExtLightmaps; i; i++ ) for( i = numExtLightmaps; i; i++ )
@ -2862,7 +2999,7 @@ void StoreSurfaceLightmaps( void )
----------------------------------------------------------------- */ ----------------------------------------------------------------- */
/* note it */ /* note it */
Sys_FPrintf( SYS_VRB, "projecting..." ); Sys_Printf( "projecting..." );
/* walk the list of surfaces */ /* walk the list of surfaces */
for( i = 0; i < numBSPDrawSurfaces; i++ ) for( i = 0; i < numBSPDrawSurfaces; i++ )
@ -3134,7 +3271,7 @@ void StoreSurfaceLightmaps( void )
} }
/* finish */ /* finish */
Sys_FPrintf( SYS_VRB, "done.\n" ); Sys_Printf( "done.\n" );
/* calc num stored */ /* calc num stored */
numStored = numBSPLightBytes / 3; numStored = numBSPLightBytes / 3;

View File

@ -872,6 +872,10 @@ int main( int argc, char **argv )
/* ydnar: new path initialization */ /* ydnar: new path initialization */
InitPaths( &argc, argv ); InitPaths( &argc, argv );
/* set game options */
if (!patchSubdivisions)
patchSubdivisions = game->patchSubdivisions;
/* check if we have enough options left to attempt something */ /* check if we have enough options left to attempt something */
if( argc < 2 ) if( argc < 2 )
Error( "Usage: %s [general options] [options] mapfile", argv[ 0 ] ); Error( "Usage: %s [general options] [options] mapfile", argv[ 0 ] );

View File

@ -237,6 +237,7 @@ constants
#define LIGHT_FAST_TEMP 512 #define LIGHT_FAST_TEMP 512
#define LIGHT_FAST_ACTUAL (LIGHT_FAST | LIGHT_FAST_TEMP) #define LIGHT_FAST_ACTUAL (LIGHT_FAST | LIGHT_FAST_TEMP)
#define LIGHT_NEGATIVE 1024 #define LIGHT_NEGATIVE 1024
#define LIGHT_UNNORMALIZED 2048 /* vortex: do not normalize _color */
#define LIGHT_SUN_DEFAULT (LIGHT_ATTEN_ANGLE | LIGHT_GRID | LIGHT_SURFACES) #define LIGHT_SUN_DEFAULT (LIGHT_ATTEN_ANGLE | LIGHT_GRID | LIGHT_SURFACES)
#define LIGHT_AREA_DEFAULT (LIGHT_ATTEN_ANGLE | LIGHT_ATTEN_DISTANCE | LIGHT_GRID | LIGHT_SURFACES) /* q3a and wolf are the same */ #define LIGHT_AREA_DEFAULT (LIGHT_ATTEN_ANGLE | LIGHT_ATTEN_DISTANCE | LIGHT_GRID | LIGHT_SURFACES) /* q3a and wolf are the same */
@ -270,7 +271,7 @@ constants
#define SUPER_NORMAL_SIZE 4 #define SUPER_NORMAL_SIZE 4
#define SUPER_DELUXEL_SIZE 3 #define SUPER_DELUXEL_SIZE 3
#define BSP_DELUXEL_SIZE 3 #define BSP_DELUXEL_SIZE 3
#define SUPER_FLOODLIGHT_SIZE 1 #define SUPER_FLOODLIGHT_SIZE 4
#define VERTEX_LUXEL( s, v ) (vertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE)) #define VERTEX_LUXEL( s, v ) (vertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
#define RAD_VERTEX_LUXEL( s, v )(radVertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE)) #define RAD_VERTEX_LUXEL( s, v )(radVertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
@ -550,6 +551,14 @@ typedef struct game_s
float lightmapGamma; /* default lightmap gamma */ float lightmapGamma; /* default lightmap gamma */
float lightmapExposure; /* default lightmap exposure */ float lightmapExposure; /* default lightmap exposure */
float lightmapCompensate; /* default lightmap compensate value */ float lightmapCompensate; /* default lightmap compensate value */
float gridScale; /* vortex: default lightgrid scale (affects both directional and ambient spectres) */
float gridAmbientScale; /* vortex: default lightgrid ambient spectre scale */
qboolean noStyles; /* use lightstyles hack or not */
qboolean keepLights; /* keep light entities on bsp */
int patchSubdivisions; /* default patch subdivisions tolerance */
qboolean patchShadows; /* patch casting enabled */
qboolean deluxeMap; /* compile deluxemaps */
int deluxeMode; /* deluxemap mode (0 - modelspace, 1 - tangentspace with renormalization, 2 - tangentspace without renormalization) */
char *bspIdent; /* 4-letter bsp file prefix */ char *bspIdent; /* 4-letter bsp file prefix */
int bspVersion; /* bsp version to use */ int bspVersion; /* bsp version to use */
qboolean lumpSwap; /* cod-style len/ofs order */ qboolean lumpSwap; /* cod-style len/ofs order */
@ -672,6 +681,7 @@ typedef struct shaderInfo_s
char *backShader; /* for surfaces that generate different front and back passes */ char *backShader; /* for surfaces that generate different front and back passes */
char *cloneShader; /* ydnar: for cloning of a surface */ char *cloneShader; /* ydnar: for cloning of a surface */
char *remapShader; /* ydnar: remap a shader in final stage */ char *remapShader; /* ydnar: remap a shader in final stage */
char *deprecateShader; /* vortex: shader is deprecated and replaced by this on use */
surfaceModel_t *surfaceModel; /* ydnar: for distribution of models */ surfaceModel_t *surfaceModel; /* ydnar: for distribution of models */
foliage_t *foliage; /* ydnar/splash damage: wolf et foliage */ foliage_t *foliage; /* ydnar/splash damage: wolf et foliage */
@ -749,6 +759,12 @@ typedef struct shaderInfo_s
vec3_t averageColor; vec3_t averageColor;
byte lightStyle; byte lightStyle;
/* vortex: per-surface floodlight */
float floodlightDirectionScale;
vec3_t floodlightRGB;
float floodlightIntensity;
float floodlightDistance;
qb_t lmMergable; /* ydnar */ qb_t lmMergable; /* ydnar */
int lmCustomWidth, lmCustomHeight; /* ydnar */ int lmCustomWidth, lmCustomHeight; /* ydnar */
float lmBrightness; /* ydnar */ float lmBrightness; /* ydnar */
@ -1072,6 +1088,7 @@ typedef struct
int firstBrush, numBrushes; /* only valid during BSP compile */ int firstBrush, numBrushes; /* only valid during BSP compile */
epair_t *epairs; epair_t *epairs;
vec3_t originbrush_origin; vec3_t originbrush_origin;
qboolean forceNormalSmoothing; /* vortex: true if entity has _smoothnormals/_sn/_smooth key */
} }
entity_t; entity_t;
@ -1307,6 +1324,7 @@ typedef struct
/* input and output */ /* input and output */
vec3_t color; /* starts out at full color, may be reduced if transparent surfaces are crossed */ vec3_t color; /* starts out at full color, may be reduced if transparent surfaces are crossed */
vec3_t colorNoShadow; /* result color with no shadow casting */
/* output */ /* output */
vec3_t hit; vec3_t hit;
@ -1378,6 +1396,13 @@ typedef struct rawLightmap_s
int numLightClusters, *lightClusters; int numLightClusters, *lightClusters;
int sampleSize, actualSampleSize, axisNum; int sampleSize, actualSampleSize, axisNum;
/* vortex: per-surface floodlight */
float floodlightDirectionScale;
vec3_t floodlightRGB;
float floodlightIntensity;
float floodlightDistance;
int entityNum; int entityNum;
int recvShadows; int recvShadows;
vec3_t mins, maxs, axis, origin, *vecs; vec3_t mins, maxs, axis, origin, *vecs;
@ -1433,8 +1458,6 @@ typedef struct surfaceInfo_s
} }
surfaceInfo_t; surfaceInfo_t;
/* ------------------------------------------------------------------------------- /* -------------------------------------------------------------------------------
prototypes prototypes
@ -1568,6 +1591,7 @@ void FreeTreePortals_r( node_t *node );
void ParsePatch( qboolean onlyLights ); void ParsePatch( qboolean onlyLights );
mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength ); mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength );
void PatchMapDrawSurfs( entity_t *e ); void PatchMapDrawSurfs( entity_t *e );
void TriangulatePatchSurface( entity_t *e , mapDrawSurface_t *ds );
/* tjunction.c */ /* tjunction.c */
@ -1622,6 +1646,8 @@ void SubdivideFaceSurfaces( entity_t *e, tree_t *tree );
void AddEntitySurfaceModels( entity_t *e ); void AddEntitySurfaceModels( entity_t *e );
int AddSurfaceModels( mapDrawSurface_t *ds ); int AddSurfaceModels( mapDrawSurface_t *ds );
void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree ); void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree );
void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds );
void EmitTriangleSurface( mapDrawSurface_t *ds );
/* surface_fur.c */ /* surface_fur.c */
@ -1719,7 +1745,9 @@ float DirtForSample( trace_t *trace );
void DirtyRawLightmap( int num ); void DirtyRawLightmap( int num );
void SetupFloodLight(); void SetupFloodLight();
float FloodLightForSample( trace_t *trace ); void FloodlightRawLightmaps();
void FloodlightIlluminateLightmap( rawLightmap_t *lm );
float FloodLightForSample( trace_t *trace , float floodLightDistance, qboolean floodLightLowQuality);
void FloodLightRawLightmap( int num ); void FloodLightRawLightmap( int num );
void IlluminateRawLightmap( int num ); void IlluminateRawLightmap( int num );
@ -1871,6 +1899,12 @@ Q_EXTERN game_t games[]
, ,
#include "game_qfusion.h" /* qfusion game */ #include "game_qfusion.h" /* qfusion game */
, ,
#include "game_darkplaces.h" /* vortex: darkplaces q1 engine */
,
#include "game_dq.h" /* vortex: deluxe quake game ( darkplaces q1 engine) */
,
#include "game_prophecy.h" /* vortex: prophecy game ( darkplaces q1 engine) */
,
{ NULL } /* null game */ { NULL } /* null game */
}; };
#endif #endif
@ -1957,6 +1991,7 @@ Q_EXTERN char outbase[ 32 ];
Q_EXTERN int sampleSize; /* lightmap sample size in units */ Q_EXTERN int sampleSize; /* lightmap sample size in units */
Q_EXTERN int minSampleSize; /* minimum sample size to use at all */ Q_EXTERN int minSampleSize; /* minimum sample size to use at all */
Q_EXTERN int sampleScale; /* vortex: lightmap sample scale (ie quality)*/
Q_EXTERN int mapEntityNum Q_ASSIGN( 0 ); Q_EXTERN int mapEntityNum Q_ASSIGN( 0 );
@ -2083,6 +2118,7 @@ light global variables
Q_EXTERN qboolean wolfLight Q_ASSIGN( qfalse ); Q_EXTERN qboolean wolfLight Q_ASSIGN( qfalse );
Q_EXTERN qboolean loMem Q_ASSIGN( qfalse ); Q_EXTERN qboolean loMem Q_ASSIGN( qfalse );
Q_EXTERN qboolean noStyles Q_ASSIGN( qfalse ); Q_EXTERN qboolean noStyles Q_ASSIGN( qfalse );
Q_EXTERN qboolean keepLights Q_ASSIGN( qfalse );
Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE ); Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE );
Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE ); Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE );
@ -2096,6 +2132,7 @@ Q_EXTERN qboolean cpmaHack Q_ASSIGN( qfalse );
Q_EXTERN qboolean deluxemap Q_ASSIGN( qfalse ); Q_EXTERN qboolean deluxemap Q_ASSIGN( qfalse );
Q_EXTERN qboolean debugDeluxemap Q_ASSIGN( qfalse ); Q_EXTERN qboolean debugDeluxemap Q_ASSIGN( qfalse );
Q_EXTERN int deluxemode Q_ASSIGN( 0 ); /* deluxemap format (0 - modelspace, 1 - tangentspace with renormalization, 2 - tangentspace without renormalization) */
Q_EXTERN qboolean fast Q_ASSIGN( qfalse ); Q_EXTERN qboolean fast Q_ASSIGN( qfalse );
Q_EXTERN qboolean faster Q_ASSIGN( qfalse ); Q_EXTERN qboolean faster Q_ASSIGN( qfalse );
@ -2130,12 +2167,13 @@ Q_EXTERN float dirtDepth Q_ASSIGN( 128.0f );
Q_EXTERN float dirtScale Q_ASSIGN( 1.0f ); Q_EXTERN float dirtScale Q_ASSIGN( 1.0f );
Q_EXTERN float dirtGain Q_ASSIGN( 1.0f ); Q_EXTERN float dirtGain Q_ASSIGN( 1.0f );
/* 27: floodlighting */
Q_EXTERN qboolean debugnormals Q_ASSIGN( qfalse ); Q_EXTERN qboolean debugnormals Q_ASSIGN( qfalse );
Q_EXTERN qboolean floodlighty Q_ASSIGN( qfalse ); Q_EXTERN qboolean floodlighty Q_ASSIGN( qfalse );
Q_EXTERN qboolean floodlight_lowquality Q_ASSIGN( qfalse ); Q_EXTERN qboolean floodlight_lowquality Q_ASSIGN( qfalse );
Q_EXTERN vec3_t floodlightRGB; Q_EXTERN vec3_t floodlightRGB;
Q_EXTERN float floodlightIntensity Q_ASSIGN( 512 ); Q_EXTERN float floodlightIntensity Q_ASSIGN( 512.0f );
Q_EXTERN float floodlightDistance Q_ASSIGN( 1024 ); Q_EXTERN float floodlightDistance Q_ASSIGN( 1024.0f );
Q_EXTERN qboolean dump Q_ASSIGN( qfalse ); Q_EXTERN qboolean dump Q_ASSIGN( qfalse );
Q_EXTERN qboolean debug Q_ASSIGN( qfalse ); Q_EXTERN qboolean debug Q_ASSIGN( qfalse );
@ -2154,6 +2192,10 @@ Q_EXTERN float areaScale Q_ASSIGN( 0.25f );
Q_EXTERN float skyScale Q_ASSIGN( 1.0f ); Q_EXTERN float skyScale Q_ASSIGN( 1.0f );
Q_EXTERN float bounceScale Q_ASSIGN( 0.25f ); Q_EXTERN float bounceScale Q_ASSIGN( 0.25f );
/* vortex: gridscale and gridambientscale */
Q_EXTERN float gridScale Q_ASSIGN( 1.0f );
Q_EXTERN float gridAmbientScale Q_ASSIGN( 1.0f );
/* ydnar: lightmap gamma/compensation */ /* ydnar: lightmap gamma/compensation */
Q_EXTERN float lightmapGamma Q_ASSIGN( 1.0f ); Q_EXTERN float lightmapGamma Q_ASSIGN( 1.0f );
Q_EXTERN float lightmapExposure Q_ASSIGN( 1.0f ); Q_EXTERN float lightmapExposure Q_ASSIGN( 1.0f );
@ -2264,6 +2306,9 @@ Q_EXTERN int numBSPLightmaps Q_ASSIGN( 0 );
Q_EXTERN int numExtLightmaps Q_ASSIGN( 0 ); Q_EXTERN int numExtLightmaps Q_ASSIGN( 0 );
Q_EXTERN outLightmap_t *outLightmaps Q_ASSIGN( NULL ); Q_EXTERN outLightmap_t *outLightmaps Q_ASSIGN( NULL );
/* vortex: per surface floodlight statictics */
Q_EXTERN int numSurfacesFloodlighten Q_ASSIGN( 0 );
/* grid points */ /* grid points */
Q_EXTERN int numRawGridPoints Q_ASSIGN( 0 ); Q_EXTERN int numRawGridPoints Q_ASSIGN( 0 );
Q_EXTERN rawGridPoint_t *rawGridPoints Q_ASSIGN( NULL ); Q_EXTERN rawGridPoint_t *rawGridPoints Q_ASSIGN( NULL );

File diff suppressed because it is too large Load Diff

View File

@ -827,13 +827,15 @@ ShaderInfoForShader()
finds a shaderinfo for a named shader finds a shaderinfo for a named shader
*/ */
#define MAX_SHADER_DEPRECATION_DEPTH 16
shaderInfo_t *ShaderInfoForShader( const char *shaderName ) shaderInfo_t *ShaderInfoForShader( const char *shaderName )
{ {
int i; int i;
int deprecationDepth;
shaderInfo_t *si; shaderInfo_t *si;
char shader[ MAX_QPATH ]; char shader[ MAX_QPATH ];
/* dummy check */ /* dummy check */
if( shaderName == NULL || shaderName[ 0 ] == '\0' ) if( shaderName == NULL || shaderName[ 0 ] == '\0' )
{ {
@ -846,11 +848,27 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName )
StripExtension( shader ); StripExtension( shader );
/* search for it */ /* search for it */
deprecationDepth = 0;
for( i = 0; i < numShaderInfo; i++ ) for( i = 0; i < numShaderInfo; i++ )
{ {
si = &shaderInfo[ i ]; si = &shaderInfo[ i ];
if( !Q_stricmp( shader, si->shader ) ) if( !Q_stricmp( shader, si->shader ) )
{ {
/* check if shader is deprecated */
if (deprecationDepth < MAX_SHADER_DEPRECATION_DEPTH && si->deprecateShader && si->deprecateShader[ 0 ] )
{
/* override name */
strcpy( shader, si->deprecateShader );
StripExtension( shader );
/* increase deprecation depth */
deprecationDepth++;
if (deprecationDepth == MAX_SHADER_DEPRECATION_DEPTH)
Sys_Printf("WARNING: Max deprecation depth of %i is reached on shader '%s'\n", MAX_SHADER_DEPRECATION_DEPTH, shader);
/* search again from beginning */
i = -1;
continue;
}
/* load image if necessary */ /* load image if necessary */
if( si->finished == qfalse ) if( si->finished == qfalse )
{ {
@ -1363,7 +1381,6 @@ static void ParseShaderFile( const char *filename )
{ {
surfaceModel_t *model; surfaceModel_t *model;
/* allocate new model and attach it */ /* allocate new model and attach it */
model = safe_malloc( sizeof( *model ) ); model = safe_malloc( sizeof( *model ) );
memset( model, 0, sizeof( *model ) ); memset( model, 0, sizeof( *model ) );
@ -1489,6 +1506,24 @@ static void ParseShaderFile( const char *filename )
si->backsplashDistance = atof( token ); si->backsplashDistance = atof( token );
} }
/* q3map_floodLight <r> <g> <b> <diste> <intensity> <light_direction_power> */
else if( !Q_stricmp( token, "q3map_floodLight" ) )
{
/* get color */
GetTokenAppend( shaderText, qfalse );
si->floodlightRGB[ 0 ] = atof( token );
GetTokenAppend( shaderText, qfalse );
si->floodlightRGB[ 1 ] = atof( token );
GetTokenAppend( shaderText, qfalse );
si->floodlightRGB[ 2 ] = atof( token );
GetTokenAppend( shaderText, qfalse );
si->floodlightDistance = atof( token );
GetTokenAppend( shaderText, qfalse );
si->floodlightIntensity = atof( token );
GetTokenAppend( shaderText, qfalse );
si->floodlightDirectionScale = atof( token );
}
/* q3map_lightmapSampleSize <value> */ /* q3map_lightmapSampleSize <value> */
else if( !Q_stricmp( token, "q3map_lightmapSampleSize" ) ) else if( !Q_stricmp( token, "q3map_lightmapSampleSize" ) )
{ {
@ -1614,6 +1649,18 @@ static void ParseShaderFile( const char *filename )
} }
} }
/* q3map_deprecateShader <shader> */
else if( !Q_stricmp( token, "q3map_deprecateShader" ) )
{
GetTokenAppend( shaderText, qfalse );
if( token[ 0 ] != '\0' )
{
si->deprecateShader = safe_malloc( strlen( token ) + 1 );
strcpy( si->deprecateShader, token );
}
}
/* ydnar: q3map_offset <value> */ /* ydnar: q3map_offset <value> */
else if( !Q_stricmp( token, "q3map_offset" ) ) else if( !Q_stricmp( token, "q3map_offset" ) )
{ {
@ -1933,12 +1980,14 @@ static void ParseShaderFile( const char *filename )
si->styleMarker = 2; si->styleMarker = 2;
/* ydnar: default to searching for q3map_<surfaceparm> */ /* ydnar: default to searching for q3map_<surfaceparm> */
#if 0
else else
{ {
//% Sys_FPrintf( SYS_VRB, "Attempting to match %s with a known surfaceparm\n", token ); Sys_FPrintf( SYS_VRB, "Attempting to match %s with a known surfaceparm\n", token );
if( ApplySurfaceParm( &token[ 6 ], &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse ) if( ApplySurfaceParm( &token[ 6 ], &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse )
;//% Sys_Printf( "WARNING: Unknown q3map_* directive \"%s\"\n", token ); Sys_Printf( "WARNING: Unknown q3map_* directive \"%s\"\n", token );
} }
#endif
} }

View File

@ -2446,26 +2446,28 @@ void EmitFlareSurface( mapDrawSurface_t *ds )
numSurfacesByType[ ds->type ]++; numSurfacesByType[ ds->type ]++;
} }
/* /*
EmitPatchSurface() EmitPatchSurface()
emits a bsp patch drawsurface emits a bsp patch drawsurface
*/ */
void EmitPatchSurface( mapDrawSurface_t *ds ) void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds )
{ {
int i, j; int i, j;
bspDrawSurface_t *out; bspDrawSurface_t *out;
int surfaceFlags, contentFlags; int surfaceFlags, contentFlags;
int forcePatchMeta;
/* vortex: _patchMeta support */
forcePatchMeta = IntForKey(e, "_patchMeta" );
if (!forcePatchMeta)
forcePatchMeta = IntForKey(e, "patchMeta" );
/* invert the surface if necessary */ /* invert the surface if necessary */
if( ds->backSide || ds->shaderInfo->invert ) if( ds->backSide || ds->shaderInfo->invert )
{ {
bspDrawVert_t *dv1, *dv2, temp; bspDrawVert_t *dv1, *dv2, temp;
/* walk the verts, flip the normal */ /* walk the verts, flip the normal */
for( i = 0; i < ds->numVerts; i++ ) for( i = 0; i < ds->numVerts; i++ )
VectorScale( ds->verts[ i ].normal, -1.0f, ds->verts[ i ].normal ); VectorScale( ds->verts[ i ].normal, -1.0f, ds->verts[ i ].normal );
@ -2499,7 +2501,7 @@ void EmitPatchSurface( mapDrawSurface_t *ds )
out->surfaceType = MST_PATCH; out->surfaceType = MST_PATCH;
if( debugSurfaces ) if( debugSurfaces )
out->shaderNum = EmitShader( "debugsurfaces", NULL, NULL ); out->shaderNum = EmitShader( "debugsurfaces", NULL, NULL );
else if( patchMeta ) else if( patchMeta || forcePatchMeta )
{ {
/* patch meta requires that we have nodraw patches for collision */ /* patch meta requires that we have nodraw patches for collision */
surfaceFlags = ds->shaderInfo->surfaceFlags; surfaceFlags = ds->shaderInfo->surfaceFlags;
@ -2549,8 +2551,6 @@ void EmitPatchSurface( mapDrawSurface_t *ds )
numSurfacesByType[ ds->type ]++; numSurfacesByType[ ds->type ]++;
} }
/* /*
OptimizeTriangleSurface() - ydnar OptimizeTriangleSurface() - ydnar
optimizes the vertex/index data in a triangle surface optimizes the vertex/index data in a triangle surface
@ -2674,12 +2674,11 @@ EmitTriangleSurface()
creates a bsp drawsurface from arbitrary triangle surfaces creates a bsp drawsurface from arbitrary triangle surfaces
*/ */
static void EmitTriangleSurface( mapDrawSurface_t *ds ) void EmitTriangleSurface( mapDrawSurface_t *ds )
{ {
int i, temp; int i, temp;
bspDrawSurface_t *out; bspDrawSurface_t *out;
/* invert the surface if necessary */ /* invert the surface if necessary */
if( ds->backSide || ds->shaderInfo->invert ) if( ds->backSide || ds->shaderInfo->invert )
{ {
@ -2805,15 +2804,14 @@ EmitFaceSurface()
emits a bsp planar winding (brush face) drawsurface emits a bsp planar winding (brush face) drawsurface
*/ */
static void EmitFaceSurface( mapDrawSurface_t *ds ) static void EmitFaceSurface(mapDrawSurface_t *ds )
{ {
/* strip/fan finding was moved elsewhere */ /* strip/fan finding was moved elsewhere */
StripFaceSurface( ds ); StripFaceSurface( ds );
EmitTriangleSurface( ds ); EmitTriangleSurface(ds);
} }
/* /*
MakeDebugPortalSurfs_r() - ydnar MakeDebugPortalSurfs_r() - ydnar
generates drawsurfaces for passable portals in the bsp generates drawsurfaces for passable portals in the bsp
@ -3503,7 +3501,7 @@ void FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree )
if( refs == 0 ) if( refs == 0 )
refs = FilterPatchIntoTree( ds, tree ); refs = FilterPatchIntoTree( ds, tree );
if( refs > 0 ) if( refs > 0 )
EmitPatchSurface( ds ); EmitPatchSurface( e, ds );
break; break;
/* handle triangle surfaces */ /* handle triangle surfaces */

View File

@ -312,23 +312,41 @@ TriangulatePatchSurface()
creates triangles from a patch creates triangles from a patch
*/ */
void TriangulatePatchSurface( mapDrawSurface_t *ds ) void TriangulatePatchSurface( entity_t *e , mapDrawSurface_t *ds )
{ {
int iterations, x, y, pw[ 5 ], r; int iterations, x, y, pw[ 5 ], r;
mapDrawSurface_t *dsNew; mapDrawSurface_t *dsNew;
mesh_t src, *subdivided, *mesh; mesh_t src, *subdivided, *mesh;
int forcePatchMeta;
int patchQuality;
int patchSubdivision;
/* vortex: _patchMeta, _patchQuality, _patchSubdivide support */
forcePatchMeta = IntForKey(e, "_patchMeta" );
if (!forcePatchMeta)
forcePatchMeta = IntForKey(e, "patchMeta" );
patchQuality = IntForKey(e, "_patchQuality" );
if (!patchQuality)
patchQuality = IntForKey(e, "patchQuality" );
if (!patchQuality)
patchQuality = 1.0;
patchSubdivision = IntForKey(e, "_patchSubdivide" );
if (!patchSubdivision)
patchSubdivision = IntForKey(e, "patchSubdivide" );
/* try to early out */ /* try to early out */
if( ds->numVerts == 0 || ds->type != SURFACE_PATCH || patchMeta == qfalse ) if(ds->numVerts == 0 || ds->type != SURFACE_PATCH || ( patchMeta == qfalse && !forcePatchMeta) )
return; return;
/* make a mesh from the drawsurf */ /* make a mesh from the drawsurf */
src.width = ds->patchWidth; src.width = ds->patchWidth;
src.height = ds->patchHeight; src.height = ds->patchHeight;
src.verts = ds->verts; src.verts = ds->verts;
//% subdivided = SubdivideMesh( src, 8, 999 ); //% subdivided = SubdivideMesh( src, 8, 999 );
iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions ); if (patchSubdivision)
iterations = IterationsForCurve( ds->longestCurve, patchSubdivision );
else
iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions / patchQuality );
subdivided = SubdivideMesh2( src, iterations ); //% ds->maxIterations subdivided = SubdivideMesh2( src, iterations ); //% ds->maxIterations
/* fit it to the curve and remove colinear verts on rows/columns */ /* fit it to the curve and remove colinear verts on rows/columns */
@ -667,7 +685,7 @@ void MakeEntityMetaTriangles( entity_t *e )
break; break;
case SURFACE_PATCH: case SURFACE_PATCH:
TriangulatePatchSurface( ds ); TriangulatePatchSurface(e, ds );
break; break;
case SURFACE_TRIANGLES: case SURFACE_TRIANGLES:
@ -987,7 +1005,7 @@ void SmoothMetaTriangles( void )
vec3_t average, diff; vec3_t average, diff;
int indexes[ MAX_SAMPLES ]; int indexes[ MAX_SAMPLES ];
vec3_t votes[ MAX_SAMPLES ]; vec3_t votes[ MAX_SAMPLES ];
const char *classname;
/* note it */ /* note it */
Sys_FPrintf( SYS_VRB, "--- SmoothMetaTriangles ---\n" ); Sys_FPrintf( SYS_VRB, "--- SmoothMetaTriangles ---\n" );
@ -1009,11 +1027,31 @@ void SmoothMetaTriangles( void )
and set per-vertex smoothing angle */ and set per-vertex smoothing angle */
for( i = 0, tri = &metaTriangles[ i ]; i < numMetaTriangles; i++, tri++ ) for( i = 0, tri = &metaTriangles[ i ]; i < numMetaTriangles; i++, tri++ )
{ {
/* vortex: try get smoothing from entity key */
shadeAngle = FloatForKey(&entities[tri->entityNum], "_smoothnormals");
if (shadeAngle <= 0.0f)
shadeAngle = FloatForKey(&entities[tri->entityNum], "_sn");
if (shadeAngle <= 0.0f)
shadeAngle = FloatForKey(&entities[tri->entityNum], "_smooth");
if (shadeAngle > 0.0f)
{
if (entities[tri->entityNum].forceNormalSmoothing == qfalse)
{
entities[tri->entityNum].forceNormalSmoothing = qtrue;
classname = ValueForKey( &entities[tri->entityNum], "classname" );
Sys_Printf( "Entity %d (%s) has vertex normal smoothing with breaking angle of %3.0f\n", tri->entityNum, classname, shadeAngle );
}
shadeAngle = DEG2RAD( shadeAngle );
}
/* get shader for shade angle */ /* get shader for shade angle */
if (shadeAngle <= 0.0f)
{
if( tri->si->shadeAngleDegrees > 0.0f ) if( tri->si->shadeAngleDegrees > 0.0f )
shadeAngle = DEG2RAD( tri->si->shadeAngleDegrees ); shadeAngle = DEG2RAD( tri->si->shadeAngleDegrees );
else else
shadeAngle = defaultShadeAngle; shadeAngle = defaultShadeAngle;
}
if( shadeAngle > maxShadeAngle ) if( shadeAngle > maxShadeAngle )
maxShadeAngle = shadeAngle; maxShadeAngle = shadeAngle;

View File

@ -280,7 +280,6 @@ sets style keys for entity lights
void SetLightStyles( void ) void SetLightStyles( void )
{ {
int i, j, style, numStyles; int i, j, style, numStyles;
qboolean keepLights;
const char *t; const char *t;
entity_t *e; entity_t *e;
epair_t *ep, *next; epair_t *ep, *next;
@ -288,10 +287,12 @@ void SetLightStyles( void )
char lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ]; char lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ];
int lightStyles[ MAX_SWITCHED_LIGHTS ]; int lightStyles[ MAX_SWITCHED_LIGHTS ];
/* ydnar: determine if we keep lights in the bsp */ /* ydnar: determine if we keep lights in the bsp */
if (KeyExists(&entities[ 0 ], "_keepLights") == qtrue)
{
t = ValueForKey( &entities[ 0 ], "_keepLights" ); t = ValueForKey( &entities[ 0 ], "_keepLights" );
keepLights = (t[ 0 ] == '1') ? qtrue : qfalse; keepLights = (t[ 0 ] == '1') ? qtrue : qfalse;
}
/* any light that is controlled (has a targetname) must have a unique style number generated for it */ /* any light that is controlled (has a targetname) must have a unique style number generated for it */
numStyles = 0; numStyles = 0;