X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=tools%2Fquake3%2Fq3map2%2Flight_ydnar.c;h=e08b12f585577bc2619979e7816832e293c6be2c;hb=c60d22dd261eb98e1cdfa4d1ef2b36913f4e29b5;hp=8d869dfb616826277b822e600df2598cef3ce6a8;hpb=b7a62893a44911750be7faaf66bcfa6008738191;p=xonotic%2Fnetradiant.git diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 8d869dfb..e08b12f5 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -74,7 +74,7 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ) sample[ i ] = pow( sample[ i ] / 255.0f, gamma ) * 255.0f; } - if (lightmapExposure == 1) + if (lightmapExposure == 0) { /* clamp with color normalization */ max = sample[ 0 ]; @@ -87,10 +87,6 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ) } else { - if (lightmapExposure==0) - { - lightmapExposure=1.0f; - } inv=1.f/lightmapExposure; //Exposure @@ -120,6 +116,14 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ) /* compensate for ingame overbrighting/bitshifting */ VectorScale( sample, (1.0f / lightmapCompensate), sample ); + + /* sRGB lightmaps */ + if(lightmapsRGB) + { + sample[0] = floor(Image_sRGBFloatFromLinearFloat(sample[0] * (1.0 / 255.0)) * 255.0 + 0.5); + sample[1] = floor(Image_sRGBFloatFromLinearFloat(sample[1] * (1.0 / 255.0)) * 255.0 + 0.5); + sample[2] = floor(Image_sRGBFloatFromLinearFloat(sample[2] * (1.0 / 255.0)) * 255.0 + 0.5); + } /* store it off */ colorBytes[ 0 ] = sample[ 0 ]; @@ -1788,7 +1792,7 @@ static void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampl vec3_t deluxel[ 3 ]; vec3_t origin[ 4 ], normal[ 4 ]; float biasDirs[ 4 ][ 2 ] = { { -1.0f, -1.0f }, { 1.0f, -1.0f }, { -1.0f, 1.0f }, { 1.0f, 1.0f } }; - vec3_t color, direction, total; + vec3_t color, direction = { 0, 0, 0 }, total; /* limit check */ @@ -1861,7 +1865,10 @@ static void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampl //% VectorClear( color ); //% samples = 0; VectorCopy( lightLuxel, color ); - VectorCopy( lightDeluxel, direction ); + if(lightDeluxel) + { + VectorCopy( lightDeluxel, direction ); + } samples = 1; for( b = 0; b < 4; b++ ) { @@ -3133,9 +3140,10 @@ SetupBrushes() determines opaque brushes in the world and find sky shaders for sunlight calculations */ -void SetupBrushes( void ) +void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ) { - int i, j, b, compileFlags; + int i, j, b; + unsigned int compileFlags, allCompileFlags; qboolean inside; bspBrush_t *brush; bspBrushSide_t *side; @@ -3164,23 +3172,25 @@ void SetupBrushes( void ) /* check all sides */ inside = qtrue; compileFlags = 0; + allCompileFlags = ~(0u); for( j = 0; j < brush->numSides && inside; j++ ) { /* do bsp shader calculations */ side = &bspBrushSides[ brush->firstSide + j ]; shader = &bspShaders[ side->shaderNum ]; - + /* get shader info */ - si = ShaderInfoForShader( shader->shader ); + si = ShaderInfoForShaderNull( shader->shader ); if( si == NULL ) continue; /* or together compile flags */ compileFlags |= si->compileFlags; + allCompileFlags &= si->compileFlags; } - + /* determine if this brush is opaque to light */ - if( !(compileFlags & C_TRANSLUCENT) ) + if( (compileFlags & mask_any) == test_any && (allCompileFlags & mask_all) == test_all ) { opaqueBrushes[ b >> 3 ] |= (1 << (b & 7)); numOpaqueBrushes++; @@ -3191,6 +3201,10 @@ void SetupBrushes( void ) /* emit some statistics */ Sys_FPrintf( SYS_VRB, "%9d opaque brushes\n", numOpaqueBrushes ); } +void SetupBrushes( void ) +{ + SetupBrushesFlags(C_TRANSLUCENT, 0, 0, 0); +} @@ -3201,7 +3215,7 @@ determines if two clusters are visible to each other using the PVS qboolean ClusterVisible( int a, int b ) { - int portalClusters, leafBytes; + int leafBytes; byte *pvs; @@ -3218,7 +3232,7 @@ qboolean ClusterVisible( int a, int b ) return qtrue; /* get pvs data */ - portalClusters = ((int *) bspVisBytes)[ 0 ]; + /* portalClusters = ((int *) bspVisBytes)[ 0 ]; */ leafBytes = ((int*) bspVisBytes)[ 1 ]; pvs = bspVisBytes + VIS_HEADER_SIZE + (a * leafBytes); @@ -4013,7 +4027,7 @@ void SetupFloodLight( void ) int i, j; float angle, elevation, angleStep, elevationStep; const char *value; - double v1,v2,v3,v4,v5; + double v1,v2,v3,v4,v5,v6; /* note it */ Sys_FPrintf( SYS_VRB, "--- SetupFloodLight ---\n" ); @@ -4049,7 +4063,7 @@ void SetupFloodLight( void ) v5=floodlightIntensity; v6=floodlightDirectionScale; - sscanf( value, "%lf %lf %lf %lf %lf %lf", &v1, &v2, &v3, &v4, &v5); + sscanf( value, "%lf %lf %lf %lf %lf %lf", &v1, &v2, &v3, &v4, &v5, &v6); floodlightRGB[0]=v1; floodlightRGB[1]=v2; @@ -4057,7 +4071,7 @@ void SetupFloodLight( void ) if (VectorLength(floodlightRGB)==0) { - VectorSet(floodlightRGB,240,240,255); + VectorSet(floodlightRGB,0.94,0.94,1.0); } if (v4<1) v4=1024; @@ -4073,11 +4087,15 @@ void SetupFloodLight( void ) } else { - VectorSet(floodlightRGB,240,240,255); - //floodlighty = qtrue; - //Sys_Printf( "FloodLighting enabled via worldspawn _floodlight key.\n" ); + VectorSet(floodlightRGB,0.94,0.94,1.0); + } + if(colorsRGB) + { + floodlightRGB[0] = Image_LinearFloatFromsRGBFloat(floodlightRGB[0]); + floodlightRGB[1] = Image_LinearFloatFromsRGBFloat(floodlightRGB[1]); + floodlightRGB[2] = Image_LinearFloatFromsRGBFloat(floodlightRGB[2]); } - VectorNormalize(floodlightRGB,floodlightRGB); + ColorNormalize(floodlightRGB,floodlightRGB); } /*