From 778af4dde04279ffa15f729e95c66048c05dbd32 Mon Sep 17 00:00:00 2001 From: jal Date: Sat, 29 May 2010 12:22:02 +0200 Subject: [PATCH] add shader key q3map_noDirty, which disables the dirty pass on the surface. It's handy for lightmapped terrain models where dirty produces odd darkness on mesh splits. --- tools/quake3/q3map2/light_ydnar.c | 24 +++++++++++++++++++++++- tools/quake3/q3map2/q3map2.h | 3 ++- tools/quake3/q3map2/shaders.c | 8 +++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index d26b05e..6a54389 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -1546,7 +1546,8 @@ void DirtyRawLightmap( int rawLightmapNum ) rawLightmap_t *lm; surfaceInfo_t *info; trace_t trace; - + qboolean noDirty; + /* bail if this number exceeds the number of raw lightmaps */ if( rawLightmapNum >= numRawLightmaps ) @@ -1578,6 +1579,20 @@ void DirtyRawLightmap( int rawLightmapNum ) break; } } + + noDirty = qfalse; + for( i = 0; i < trace.numSurfaces; i++ ) + { + /* get surface */ + info = &surfaceInfos[ trace.surfaces[ i ] ]; + + /* check twosidedness */ + if( info->si->noDirty ) + { + noDirty = qtrue; + break; + } + } /* gather dirt */ for( y = 0; y < lm->sh; y++ ) @@ -1596,6 +1611,13 @@ void DirtyRawLightmap( int rawLightmapNum ) /* only look at mapped luxels */ if( *cluster < 0 ) continue; + + /* don't apply dirty on this surface */ + if( noDirty ) + { + *dirt = 1.0f; + continue; + } /* copy to trace */ trace.cluster = *cluster; diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 1b86f12..c88b4ed 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -749,7 +749,8 @@ typedef struct shaderInfo_s qb_t noFog; /* ydnar: supress fogging */ qb_t clipModel; /* ydnar: solid model hack */ qb_t noVertexLight; /* ydnar: leave vertex color alone */ - + qb_t noDirty; /* jal: do not apply the dirty pass to this surface */ + byte styleMarker; /* ydnar: light styles hack */ float vertexScale; /* vertex light scale */ diff --git a/tools/quake3/q3map2/shaders.c b/tools/quake3/q3map2/shaders.c index 74f5e59..3bf6cbe 100644 --- a/tools/quake3/q3map2/shaders.c +++ b/tools/quake3/q3map2/shaders.c @@ -1523,6 +1523,12 @@ static void ParseShaderFile( const char *filename ) GetTokenAppend( shaderText, qfalse ); si->floodlightDirectionScale = atof( token ); } + + /* jal: q3map_nodirty : skip dirty */ + else if( !Q_stricmp( token, "q3map_nodirty" ) ) + { + si->noDirty = qtrue; + } /* q3map_lightmapSampleSize */ else if( !Q_stricmp( token, "q3map_lightmapSampleSize" ) ) @@ -1668,7 +1674,7 @@ static void ParseShaderFile( const char *filename ) si->offset = atof( token ); } - /* ydnar: q3map_textureSize (substitute for q3map_lightimage derivation for terrain) */ + /* ydnar: q3map_fur */ else if( !Q_stricmp( token, "q3map_fur" ) ) { GetTokenAppend( shaderText, qfalse ); -- 2.39.2