mirror of
https://github.com/nzp-team/dquakeplus.git
synced 2024-11-22 11:51:21 +00:00
Merge pull request #20 from shpuld/feat/working-16bit-lms
This commit is contained in:
commit
2712c3fdfd
2 changed files with 17 additions and 8 deletions
|
@ -2911,7 +2911,7 @@ int GL_LoadTextureLM (const char *identifier, int width, int height, const byte
|
|||
texture.format = GU_PSM_T8;
|
||||
break;
|
||||
case 2:
|
||||
texture.format = GU_PSM_4444;
|
||||
texture.format = GU_PSM_5551;
|
||||
break;
|
||||
case 3:
|
||||
texture.format = GU_PSM_8888;
|
||||
|
|
|
@ -224,6 +224,7 @@ void R_BuildLightMap (msurface_t *surf, byte *dest, int stride)
|
|||
unsigned scale;
|
||||
int maps;
|
||||
unsigned *bl;
|
||||
int r, g, b, a;
|
||||
|
||||
//unsigned *blcr, *blcg, *blcb;
|
||||
|
||||
|
@ -326,17 +327,25 @@ store:
|
|||
break;
|
||||
case 2:
|
||||
bl = blocklights;
|
||||
union luxel {
|
||||
unsigned short rgb;
|
||||
byte bytes[2];
|
||||
};
|
||||
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
|
||||
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...
|
||||
r = bl[0] >> 7; if (r > 255) r = 255; r = r >> 3;
|
||||
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;
|
||||
// LordHavoc: .lit support end
|
||||
if (t > 255)
|
||||
t = 255;
|
||||
dest[j] = t;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue