From d18a8fe98891f18dda5da6719ac0d7d9ffc4422a Mon Sep 17 00:00:00 2001 From: Goodlyay Date: Wed, 15 May 2024 22:12:44 -0700 Subject: [PATCH] Fix overly bright env colors --- src/ModernLighting.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ModernLighting.c b/src/ModernLighting.c index 1e77c004a..27bd08ccc 100644 --- a/src/ModernLighting.c +++ b/src/ModernLighting.c @@ -100,11 +100,9 @@ static void ModernLighting_InitPalette(PackedCol* palette, float shaded, PackedC lavaColor = PackedCol_Lerp(0, Env.LavaLightCol, 1 - blockLerp); - lampColor = PackedCol_ScreenBlend(lampColor, ambientColor); - lavaColor = PackedCol_ScreenBlend(lavaColor, ambientColor); - + /* Blend the two light colors together, then blend that with the ambient color, then shade that by the face darkness */ palette[Modern_MakePaletteIndex(lampLevel, lavaLevel)] = - PackedCol_Scale(PackedCol_ScreenBlend(lampColor, lavaColor), shaded); + PackedCol_Scale(PackedCol_ScreenBlend(PackedCol_ScreenBlend(lampColor, lavaColor), ambientColor), shaded); } } } @@ -146,13 +144,14 @@ static void ModernLighting_AllocState(void) { } static void ModernLighting_FreeState(void) { - ClassicLighting_FreeState(); - ModernLighting_FreePalettes(); - int i; + ClassicLighting_FreeState(); + /* This function can be called multiple times without calling ModernLighting_AllocState, so... */ if (!chunkLightingDataFlags) return; + ModernLighting_FreePalettes(); + for (i = 0; i < chunksCount; i++) { Mem_Free(chunkLightingData[i]); } @@ -548,7 +547,7 @@ static PackedCol ModernLighting_Color_Core(int x, int y, int z, int paletteFace, ////palette test //cc_uint8 thing = y % MODERN_LIGHTING_LEVELS; //cc_uint8 thing2 = z % MODERN_LIGHTING_LEVELS; - //return palettes[0][thing | (thing2 << 4)]; + //return palettes[paletteFace][thing | (thing2 << 4)]; return palettes[paletteFace][lightData]; }