From 62fbaf19c9c965cf0190e3577103481f2bcc21ed Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 17 Jan 2024 13:27:32 -0500 Subject: [PATCH] Use old faster luminance calc for HWR blends Not accurate to Software's look but can't be assed to fuck around with legacy HWR to implement this as shader. --- src/hardware/hw_md2.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 8ba786970..d7c8f25b9 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -748,6 +748,9 @@ spritemodelfound: fclose(f); } +//#define BlendLuminance (K_ColorRelativeLuminance(r, g, b)) +#define BlendLuminance(r, g, b) ((UINT8)((r * 0.2126) + (g * 0.7152) + (b * 0.0722))) + static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMipmap_t *grMipmap, INT32 skinnum, skincolornum_t color) { GLPatch_t *hwrPatch = gpatch->hardware; @@ -843,8 +846,9 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi for (i = 0; i < translen; i++) // moved from inside the loop to here { RGBA_t tempc = V_GetColor(translation[i]); - colorbrightnesses[i] = K_ColorRelativeLuminance(tempc.s.red, tempc.s.green, tempc.s.blue); // store brightnesses for comparison + colorbrightnesses[i] = BlendLuminance(tempc.s.red, tempc.s.green, tempc.s.blue); // store brightnesses for comparison } + // generate lookup table for color brightness matching for (b = 0; b < 256; b++) { @@ -968,8 +972,8 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi { UINT16 imagebright, blendbright; - imagebright = K_ColorRelativeLuminance(image->s.red, image->s.green, image->s.blue); - blendbright = K_ColorRelativeLuminance(blendimage->s.red, blendimage->s.green, blendimage->s.blue); + imagebright = BlendLuminance(image->s.red, image->s.green, image->s.blue); + blendbright = BlendLuminance(blendimage->s.red, blendimage->s.green, blendimage->s.blue); // slightly dumb average between the blend image color and base image colour, usually one or the other will be fully opaque anyway brightness = (imagebright*(255-blendimage->s.alpha))/255 + (blendbright*blendimage->s.alpha)/255; @@ -984,7 +988,7 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi } else { - brightness = K_ColorRelativeLuminance(blendimage->s.red, blendimage->s.green, blendimage->s.blue); + brightness = BlendLuminance(blendimage->s.red, blendimage->s.green, blendimage->s.blue); } } @@ -1073,7 +1077,7 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi UINT32 tempcolor; UINT16 colorbright; - colorbright = K_ColorRelativeLuminance(blendcolor.s.red, blendcolor.s.green, blendcolor.s.blue); + colorbright = BlendLuminance(blendcolor.s.red, blendcolor.s.green, blendcolor.s.blue); if (colorbright == 0) {