Merge pull request #20 from shpuld/feat/working-16bit-lms

This commit is contained in:
cypress 2023-09-12 05:36:26 -04:00 committed by GitHub
commit 2712c3fdfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View file

@ -2911,7 +2911,7 @@ int GL_LoadTextureLM (const char *identifier, int width, int height, const byte
texture.format = GU_PSM_T8; texture.format = GU_PSM_T8;
break; break;
case 2: case 2:
texture.format = GU_PSM_4444; texture.format = GU_PSM_5551;
break; break;
case 3: case 3:
texture.format = GU_PSM_8888; texture.format = GU_PSM_8888;

View file

@ -224,6 +224,7 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
unsigned scale; unsigned scale;
int maps; int maps;
unsigned *bl; unsigned *bl;
int r, g, b, a;
//unsigned *blcr, *blcg, *blcb; //unsigned *blcr, *blcg, *blcb;
@ -326,17 +327,25 @@ store:
break; break;
case 2: case 2:
bl = blocklights; bl = blocklights;
union luxel {
unsigned short rgb;
byte bytes[2];
};
for (i=0 ; i<tmax ; i++ ,dest += stride) for (i=0 ; i<tmax ; i++ ,dest += stride)
{ {
for (j=0 ; j<smax ; j++) for (j=0 ; j<smax*2 ; j++)
{ {
// LordHavoc: .lit support begin r = bl[0] >> 7; if (r > 255) r = 255; r = r >> 3;
t = ((bl[0] + bl[1] + bl[2]) * 85) >> 15; // LordHavoc: basically / 3, but faster and combined with >> 7 shift down, note: actual number would be 85.3333... g = bl[1] >> 7; if (g > 255) g = 255; g = g >> 3;
b = bl[2] >> 7; if (b > 255) b = 255; b = b >> 3;
luxel lx;
lx.rgb = (a << 15) | (b << 10) | (g << 5) | (r);
dest[j] = lx.bytes[0];
j++;
dest[j] = lx.bytes[1];
bl += 3; bl += 3;
// LordHavoc: .lit support end
if (t > 255)
t = 255;
dest[j] = t;
} }
} }
break; break;