From: jal Date: Thu, 22 Apr 2010 10:07:00 +0000 (+0200) Subject: fix deluxemapping when using floodlight. Also, add to floodlight the same trick as... X-Git-Tag: xonotic-v0.5.0~262^2~1 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=36e9024e86ff2fbc3b7ab0512df42ce038cf1e3c fix deluxemapping when using floodlight. Also, add to floodlight the same trick as it's done to ambient to have a minimum normal assigned. --- diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 3207928b..dac94b62 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -3888,7 +3888,7 @@ float FloodLightForSample( trace_t *trace , float floodLightDistance, qboolean f 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[ 0 ] == 0.0f && normal[ 1 ] == 0.0f && ( normal[ 2 ] == 1.0f || normal[ 2 ] == -1.0f ) ) { if( normal[ 2 ] == 1.0f ) { @@ -4123,7 +4123,7 @@ void FloodLightRawLightmap( int rawLightmapNum ) /* global pass */ if (floodlighty && floodlightIntensity) - FloodLightRawLightmapPass(lm, floodlightRGB, floodlightIntensity, floodlightDistance, floodlight_lowquality, 0); + FloodLightRawLightmapPass(lm, floodlightRGB, floodlightIntensity, floodlightDistance, floodlight_lowquality, 1.0f); /* custom pass */ if (lm->floodlightIntensity) @@ -4151,7 +4151,6 @@ void FloodlightIlluminateLightmap( rawLightmap_t *lm ) float *luxel, *floodlight, *deluxel, *normal; int *cluster; float brightness; - vec3_t lightvector; int x, y, lightmapNum; /* walk lightmaps */ @@ -4190,11 +4189,18 @@ void FloodlightIlluminateLightmap( rawLightmap_t *lm ) if (luxel[3]==0) luxel[3]=1; /* add to deluxemap */ - if (deluxemap && floodlight[3] > 0) + if (deluxemap && floodlight[3] > 0) { + vec3_t lightvector; + 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]; + brightness *= ( 1.0f / 255.0f ) * floodlight[3]; + + // use AT LEAST this amount of contribution from ambient for the deluxemap, fixes points that receive ZERO light + if(brightness < 0.00390625f) + brightness = 0.00390625f; + VectorScale( normal, brightness, lightvector ); VectorAdd( deluxel, lightvector, deluxel ); }