From 0f695e203fc25c7a5c1281ddee5bfc029af26d96 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 5720223a9..3e32c2f4f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -704,6 +704,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; @@ -799,8 +802,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++) { @@ -922,8 +926,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; @@ -938,7 +942,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); } } @@ -1045,7 +1049,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) {