Color swizzle & software lighting fix

This commit is contained in:
Johnny 2014-02-03 05:04:11 -02:00 committed by Bill Currie
parent d80342e0a8
commit d1a8c1b277
2 changed files with 38 additions and 18 deletions

View File

@ -193,12 +193,12 @@ R_BuildLightMap (void)
if (surf->dlightframe == r_framecount)
R_AddDynamicLights ();
// // LordHavoc: changed to positive (not inverse) lighting
// for (i = 0; i < size; i++) {
// t = bound(256, blocklights[i] >> (8 - VID_CBITS),
// 256 * (VID_GRADES - 1));
// blocklights[i] = t;
// }
/*
* JohnnyonFlame:
* 32 and 16bpp modes uses the positive lighting, unlike 8bpp
*/
switch (sw32_r_pixbytes) {
case 1:
// bound, invert, and shift
for (i = 0; i < size; i++) {
t = (255 * 256 - blocklights[i]) >> (8 - VID_CBITS);
@ -208,6 +208,16 @@ R_BuildLightMap (void)
blocklights[i] = t;
}
break;
default:
// LordHavoc: changed to positive (not inverse) lighting
for (i = 0; i < size; i++) {
t = bound(256, blocklights[i] >> (8 - VID_CBITS),
256 * (VID_GRADES - 1));
blocklights[i] = t;
}
break;
}
}
void

View File

@ -55,31 +55,41 @@ VID_MakeColormap32 (void *outcolormap, byte *pal)
int c, l;
byte *out;
out = (byte *)&d_8to24table;
/*
* Generates colors not affected by lighting, such as
* HUD pieces and general sprites (such as explosions)
*/
for (c = 0; c < 256; c++) {
*out++ = pal[c*3+0];
*out++ = pal[c*3+1];
*out++ = pal[c*3+2];
*out++ = pal[c*3+1];
*out++ = pal[c*3+0];
*out++ = 255;
}
d_8to24table[255] = 0; // 255 is transparent
out = (byte *) outcolormap;
/*
* Generates colors affected by lighting, such as the
* world and other models that give it life, like foes and pickups.
*/
for (l = 0;l < VID_GRADES;l++)
{
for (c = 0;c < vid.fullbright;c++)
{
out[(l*256+c)*4+0] = bound(0, (pal[c*3+0] * l) >> (VID_CBITS - 1),
out[(l*256+c)*4+0] = bound(0, (pal[c*3+2] * l) >> (VID_CBITS - 1),
255);
out[(l*256+c)*4+1] = bound(0, (pal[c*3+1] * l) >> (VID_CBITS - 1),
255);
out[(l*256+c)*4+2] = bound(0, (pal[c*3+2] * l) >> (VID_CBITS - 1),
out[(l*256+c)*4+2] = bound(0, (pal[c*3+0] * l) >> (VID_CBITS - 1),
255);
out[(l*256+c)*4+3] = 255;
}
for (;c < 255;c++)
{
out[(l*256+c)*4+0] = pal[c*3+0];
out[(l*256+c)*4+0] = pal[c*3+2];
out[(l*256+c)*4+1] = pal[c*3+1];
out[(l*256+c)*4+2] = pal[c*3+2];
out[(l*256+c)*4+2] = pal[c*3+0];
out[(l*256+c)*4+3] = 255;
}
out[(l*256+255)*4+0] = 0;