fix deluxemapping when using floodlight. Also, add to floodlight the same trick as it's done to ambient to have a minimum normal assigned.

This commit is contained in:
jal 2010-04-22 12:07:00 +02:00
parent d5283a9692
commit 36e9024e86

View File

@ -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 );
}