From c13784bc3a6d650c77e2b7f101d57bacd4548e49 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 22 Sep 2010 08:49:43 +0200 Subject: [PATCH] force subsampling only where REALLY needed --- tools/quake3/q3map2/light.c | 4 +++- tools/quake3/q3map2/light_trace.c | 2 +- tools/quake3/q3map2/light_ydnar.c | 4 ++-- tools/quake3/q3map2/q3map2.h | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index 882c7b6..2a20d6c 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -758,7 +758,7 @@ int LightContributionToSample( trace_t *trace ) light = trace->light; /* clear color */ - trace->forceSubsampling = qfalse; /* to make sure */ + trace->forceSubsampling = 0.0f; /* to make sure */ VectorClear( trace->color ); VectorClear( trace->colorNoShadow ); VectorClear( trace->directionContribution ); @@ -1091,6 +1091,7 @@ int LightContributionToSample( trace_t *trace ) { /* trace */ TraceLine( trace ); + trace->forceSubsampling *= add; if( !(trace->compileFlags & C_SKY) || trace->opaque ) { VectorClear( trace->color ); @@ -1145,6 +1146,7 @@ int LightContributionToSample( trace_t *trace ) /* raytrace */ TraceLine( trace ); + trace->forceSubsampling *= add; if( trace->passSolid || trace->opaque ) { VectorClear( trace->color ); diff --git a/tools/quake3/q3map2/light_trace.c b/tools/quake3/q3map2/light_trace.c index 5194962..d52f816 100644 --- a/tools/quake3/q3map2/light_trace.c +++ b/tools/quake3/q3map2/light_trace.c @@ -1513,7 +1513,7 @@ qboolean TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace ) } /* force subsampling because the lighting is texture dependent */ - trace->forceSubsampling = qtrue; + trace->forceSubsampling = 1.0; /* try to avoid double shadows near triangle seams */ if( u < -ASLF_EPSILON || u > (1.0f + ASLF_EPSILON) || diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index dc4c692..8ba5a9a 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -1817,7 +1817,7 @@ static void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampl /* sample light */ LightContributionToSample( trace ); - if(trace->forceSubsampling) + if(trace->forceSubsampling > 1.0f) { /* alphashadow: we subsample as deep as we can */ ++lighted; @@ -2152,7 +2152,7 @@ void IlluminateRawLightmap( int rawLightmapNum ) VectorAdd( deluxel, trace.directionContribution, deluxel ); /* check for evilness */ - if(trace.forceSubsampling && lightSamples > 1 && luxelFilterRadius == 0) + if(trace.forceSubsampling > 1.0f && lightSamples > 1 && luxelFilterRadius == 0) { totalLighted++; *flag |= FLAG_FORCE_SUBSAMPLING; /* force */ diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 0494cd4..078f46e 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1363,7 +1363,7 @@ typedef struct int compileFlags; /* for determining surface compile flags traced through */ qboolean passSolid; qboolean opaque; - qboolean forceSubsampling; /* needs subsampling (alphashadow) */ + vec_t forceSubsampling; /* needs subsampling (alphashadow), value = max color contribution possible from it */ /* working data */ int numTestNodes; -- 2.39.2