From e0608f50d17bee0ccd2e8cb8e3a43428d9a285df Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Feb 2016 10:45:33 +0100 Subject: [PATCH] - create a separate translation table for Heretic's rain pillar. These objects are supposed to be bright, but the standard translations for player do not take this into account, creating dark and/or invisible projectiles depending on the color being used. The new translation uses hue and saturation from the player color, but combines brightness from the original color with the one for the player in an 8:2 ratio, so that no matter for the player color, these always remain bright and visible. --- src/g_heretic/a_hereticweaps.cpp | 2 +- src/r_data/r_translate.cpp | 33 +++++++++++++++++++++++++++++--- src/r_data/r_translate.h | 1 + 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 899514139..c6ccc6ae6 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -1033,7 +1033,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) if (moceiling >= 0) mo->SetZ(newz - mo->height, false); mo->Translation = multiplayer ? - TRANSLATION(TRANSLATION_PlayersExtra,self->special2) : 0; + TRANSLATION(TRANSLATION_RainPillar,self->special2) : 0; mo->target = self->target; mo->velx = 1; // Force collision detection mo->velz = -mo->Speed; diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index d11388e6e..d25ceb904 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -700,6 +700,7 @@ void R_InitTranslationTables () { PushIdentityTable(TRANSLATION_Players); PushIdentityTable(TRANSLATION_PlayersExtra); + PushIdentityTable(TRANSLATION_RainPillar); } // The menu player also gets a separate translation table PushIdentityTable(TRANSLATION_Players); @@ -865,6 +866,29 @@ static void SetRemap(FRemapTable *table, int i, float r, float g, float b) table->Palette[i] = PalEntry(255, ir, ig, ib); } +//---------------------------------------------------------------------------- +// +// Sets the translation Heretic's the rain pillar +// This tries to create a translation that preserves the brightness of +// the rain projectiles so that their effect isn't ruined. +// +//---------------------------------------------------------------------------- + +static void SetPillarRemap(FRemapTable *table, int i, float h, float s, float v) +{ + float ph, ps, pv; + float fr = GPalette.BaseColors[i].r / 255.f; + float fg = GPalette.BaseColors[i].g / 255.f; + float fb = GPalette.BaseColors[i].b / 255.f; + RGBtoHSV(fr, fg, fb, &ph, &ps, &pv); + HSVtoRGB(&fr, &fg, &fb, h, s, (v*0.2f + pv*0.8f)); + int ir = clamp (int(fr * 255.f), 0, 255); + int ig = clamp (int(fg * 255.f), 0, 255); + int ib = clamp (int(fb * 255.f), 0, 255); + table->Remap[i] = ColorMatcher.Pick (ir, ig, ib); + table->Palette[i] = PalEntry(255, ir, ig, ib); +} + //---------------------------------------------------------------------------- static bool SetRange(FRemapTable *table, int start, int end, int first, int last) @@ -900,7 +924,7 @@ static bool SetRange(FRemapTable *table, int start, int end, int first, int last //---------------------------------------------------------------------------- static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerColorSet *colorset, - FPlayerSkin *skin, FRemapTable *table, FRemapTable *alttable) + FPlayerSkin *skin, FRemapTable *table, FRemapTable *alttable, FRemapTable *pillartable) { int i; BYTE start = skin->range0start; @@ -1023,6 +1047,7 @@ static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerC v = MIN (1.f, (0.2102f + 0.0489f*(float)(i - 144)) * basev); HSVtoRGB (&r, &g, &b, h, s, v); SetRemap(alttable, i, r, g, b); + SetPillarRemap(pillartable, i, h, s, v); } alttable->UpdateNative(); } @@ -1103,7 +1128,9 @@ void R_BuildPlayerTranslation (int player) R_CreatePlayerTranslation (h, s, v, colorset, &skins[players[player].userinfo.GetSkin()], translationtables[TRANSLATION_Players][player], - translationtables[TRANSLATION_PlayersExtra][player]); + translationtables[TRANSLATION_PlayersExtra][player], + translationtables[TRANSLATION_RainPillar][player] + ); } //---------------------------------------------------------------------------- @@ -1123,5 +1150,5 @@ void R_GetPlayerTranslation (int color, const FPlayerColorSet *colorset, FPlayer RGBtoHSV (RPART(color)/255.f, GPART(color)/255.f, BPART(color)/255.f, &h, &s, &v); - R_CreatePlayerTranslation (h, s, v, colorset, skin, table, NULL); + R_CreatePlayerTranslation (h, s, v, colorset, skin, table, NULL, NULL); } diff --git a/src/r_data/r_translate.h b/src/r_data/r_translate.h index 23490cfb8..b469f8616 100644 --- a/src/r_data/r_translate.h +++ b/src/r_data/r_translate.h @@ -18,6 +18,7 @@ enum TRANSLATION_PlayerCorpses, TRANSLATION_Decorate, TRANSLATION_Blood, + TRANSLATION_RainPillar, NUM_TRANSLATION_TABLES };