#define SAMPLE_GRANULARITY 6
static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, shaderInfo_t *si, radWinding_t *rw, vec3_t average, vec3_t gradient, int *style ){
- int i, j, k, l, v, x, y, samples;
+ int i, j, k, l, v, x, y, samples, avgcolor;
vec3_t color, mins, maxs;
vec4_t textureColor;
float alpha, alphaI, bf;
float st[ 2 ], lightmap[ 2 ], *radLuxel;
radVert_t *rv[ 3 ];
+ if (!bouncing)
+ Sys_Printf( "BUG: RadSample: !bouncing shouldn't happen\n" );
/* initial setup */
ClearBounds( mins, maxs );
VectorCopy( si->averageColor, textureColor );
textureColor[ 4 ] = 255.0f;
}
+ avgcolor = ( textureColor[ 0 ] + textureColor[ 1 ] + textureColor[ 2 ] ) / 3;
for ( i = 0; i < 3; i++ )
- color[ i ] = ( textureColor[ i ] / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f );
+ color[ i ] = ( ( textureColor[ i ] * bounceColorRatio + ( avgcolor * ( 1 - bounceColorRatio ) ) ) / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f );
+// color[ i ] = ( textureColor[ i ] / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f );
AddPointToBounds( color, mins, maxs );
VectorAdd( average, color, average );
VectorCopy( si->averageColor, textureColor );
textureColor[ 4 ] = 255;
}
- for ( i = 0; i < 3; i++ )
- color[ i ] = ( textureColor[ i ] / 255 ) * ( radLuxel[ i ] / 255 );
-
+ avgcolor = ( textureColor[ 0 ] + textureColor[ 1 ] + textureColor[ 2 ] ) / 3;
+ for ( l = 0; l < 3; l++ ){
+ color[ l ] = ( ( textureColor[ l ] * bounceColorRatio + ( avgcolor * ( 1 - bounceColorRatio ) ) ) / 255 ) * ( radLuxel[ l ] / 255 );
+ //Sys_Printf( "%i %i %i %i %i \n", (int) textureColor[ 0 ], (int) textureColor[ 1 ], (int) textureColor[ 2 ], (int) avgcolor, (int) color[ i ] );
+ }
AddPointToBounds( color, mins, maxs );
VectorAdd( average, color, average );
light->falloffTolerance = falloffTolerance;
/* bouncing light? */
- if ( !bouncing ) {
+ if ( bouncing == qfalse ) {
+ /* This is weird. This actually handles surfacelight and not
+ * bounces. */
+
/* handle first-pass lights in normal q3a style */
value = si->value;
light->photons = value * area * areaScale;
light->dist = DotProduct( light->origin, normal );
}
+ if (light->photons < 0 || light->add < 0 || light->color[0] < 0 || light->color[1] < 0 || light->color[2] < 0)
+ Sys_Printf( "BUG: RadSubdivideDiffuseLight created a darkbulb\n" );
+
/* emit light from both sides? */
if ( si->compileFlags & C_FOG || si->twoSided ) {
light->flags |= LIGHT_TWOSIDED;