diff --git a/src/client/refresh/soft/sw_alias.c b/src/client/refresh/soft/sw_alias.c index b4aa0e59..04fe3bca 100644 --- a/src/client/refresh/soft/sw_alias.c +++ b/src/client/refresh/soft/sw_alias.c @@ -586,7 +586,7 @@ R_AliasSetupLighting(entity_t *currententity) } } - if(r_colorlight->value == 0) + if(r_colorlight->value < 2) { float temp = (light[0] + light[1] + light[2]) / 3; diff --git a/src/client/refresh/soft/sw_image.c b/src/client/refresh/soft/sw_image.c index 0ff4519e..4ac01b5b 100644 --- a/src/client/refresh/soft/sw_image.c +++ b/src/client/refresh/soft/sw_image.c @@ -332,8 +332,6 @@ static byte *d_16to8table = NULL; // 16 to 8 bit conversion table /* * Apply color light to texture pixel * - * vid_colormap[pix + ( llight & 0xFF00 )]; - * * TODO: -22% fps lost */ pixel_t @@ -341,9 +339,18 @@ R_ApplyLight(pixel_t pix, const light3_t light) { byte b_r, b_g, b_b; int i_c; + light3_t light_masked; + + light_masked[0] = light[0] & LIGHTMASK; + light_masked[1] = light[1] & LIGHTMASK; + light_masked[2] = light[2] & LIGHTMASK; + + /* same light or colorlight == 0 */ + if (light_masked[0] == light_masked[1] && light_masked[0] == light_masked[2]) + return vid_colormap[pix + light_masked[0]]; /* full light, code could skip light processing */ - if (((light[0] | light[1] | light[2]) & LIGHTMASK) <= vid_lightthreshold) + if ((light_masked[0] | light_masked[1] | light_masked[2]) <= vid_lightthreshold) return pix; /* get color component for each component */ @@ -352,9 +359,9 @@ R_ApplyLight(pixel_t pix, const light3_t light) b_b = d_8to24table[pix * 4 + 2]; /* scale by light */ - b_r = vid_lightmap[(light[0] & LIGHTMASK) + b_r]; - b_g = vid_lightmap[(light[1] & LIGHTMASK) + b_g]; - b_b = vid_lightmap[(light[2] & LIGHTMASK) + b_b]; + b_r = vid_lightmap[light_masked[0] + b_r]; + b_g = vid_lightmap[light_masked[1] + b_g]; + b_b = vid_lightmap[light_masked[2] + b_b]; /* convert back to indexed color */ b_r = ( b_r >> 3 ) & 31;