]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/light_ydnar.c
no, we do NOT want to ignore caulk
[xonotic/netradiant.git] / tools / quake3 / q3map2 / light_ydnar.c
index 09a8e484090463a80981b0a1bc6d6037f92c05f5..bf5bc36c34b90a72d785696daa837368e45f7918 100644 (file)
@@ -44,7 +44,6 @@ ColorToBytes()
 ydnar: moved to here 2001-02-04
 */
 
-#define Image_sRGBFloatFromLinear(c) (((c) < 0.8014848f) ? (c) * 0.05046875f : 1.055f * (float)pow((c)*(1.0f/256.0f), 1.0f/2.4f) - 0.055f)
 void ColorToBytes( const float *color, byte *colorBytes, float scale )
 {
        int             i;
@@ -125,9 +124,9 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale )
        /* sRGB lightmaps */
        if(lightmapsRGB)
        {
-               sample[0] = floor(Image_sRGBFloatFromLinear(sample[0]) * 255.0 + 0.5);
-               sample[1] = floor(Image_sRGBFloatFromLinear(sample[1]) * 255.0 + 0.5);
-               sample[2] = floor(Image_sRGBFloatFromLinear(sample[2]) * 255.0 + 0.5);
+               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 */
@@ -3145,9 +3144,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;
@@ -3176,23 +3176,27 @@ 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;
                }
+
+       Sys_FPrintf( SYS_VRB, "flags: %d (all: %d)\n", compileFlags, allCompileFlags );
                
                /* 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++;
@@ -3203,6 +3207,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);
+}