-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
additive translucency for fullbright sprites #1968
Comments
There is additive translucency in Eternity: https://github.com/team-eternity/eternity/blob/c234b59625a6eef795b0ca596d3190111b31c799/source/r_draw.cpp#L927 |
Cool. I think we already have the necessary code "borrowed" into Woof anyway. |
Hm, not sure if we should got with this approach, though. Additive translucency is pretty unambiguous, i.e. there are no varying levels of foreground translucency. Instead of converting pixel colors to RGB, reduce their bit depth and pass them into a LUT, we could just as well create a LUT for the palette indices. This proof-of-concept patch replaces the current diff --git a/src/r_data.c b/src/r_data.c
index f8dd7282..c5504e51 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -31,6 +31,7 @@
#include "doomstat.h"
#include "i_printf.h"
#include "i_system.h"
+#include "i_video.h"
#include "info.h"
#include "m_argv.h" // M_CheckParm()
#include "m_fixed.h"
@@ -921,6 +922,8 @@ int tran_filter_pct = 66; // filter percent
#define TSC 12 /* number of fixed point digits in filter percent */
+enum {r, g, b};
+
void R_InitTranMap(int progress)
{
int lump = W_CheckNumForName("TRANMAP");
@@ -959,6 +962,24 @@ void R_InitTranMap(int progress)
fread(main_tranmap, 256, 256, cachefp) != 256 || // killough 4/11/98
force_rebuild)
{
+ byte *tp = main_tranmap;
+
+ for (int i = 0; i < 256; i++)
+ {
+ for (int j = 0; j < 256; j++)
+ {
+ byte *bg = playpal + 3*i;
+ byte *fg = playpal + 3*j;
+ byte blend[3];
+
+ blend[r] = MIN(fg[r] + bg[r], 255);
+ blend[g] = MIN(fg[g] + bg[g], 255);
+ blend[b] = MIN(fg[b] + bg[b], 255);
+
+ *tp++ = I_GetNearestColor(playpal, blend[r], blend[g], blend[b]);
+ }
+ }
+/*
long pal[3][256], tot[256], pal_w1[3][256];
long w1 = ((unsigned long) tran_filter_pct<<TSC)/100;
long w2 = (1l<<TSC)-w1;
@@ -1021,10 +1042,11 @@ void R_InitTranMap(int progress)
while (--color >= 0);
}
}
+ }
+*/
// [FG] finish progress line
if (progress)
I_PutChar(VB_INFO, '\n');
- }
if (cachefp && !force_rebuild) // write out the cached translucency map
{
cache.pct = tran_filter_pct; It still looks a bit weird, though: |
Should we offer it anyway? 🤷 |
Probably a bit better (i.e. less orange/pink) if we take preference from the red and green channels: diff --git a/src/g_game.c b/src/g_game.c
index 8f619bea..b8ee5af7 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -687,7 +687,7 @@ static void AdjustWeaponSelection(int *newweapon)
static boolean FilterDeathUseAction(void)
{
- if (players[consoleplayer].playerstate & PST_DEAD)
+ if (gamestate == GS_LEVEL && (players[consoleplayer].playerstate & PST_DEAD))
{
switch (death_use_action)
{
diff --git a/src/r_data.c b/src/r_data.c
index f8dd7282..0385b15d 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -31,6 +31,7 @@
#include "doomstat.h"
#include "i_printf.h"
#include "i_system.h"
+#include "i_video.h"
#include "info.h"
#include "m_argv.h" // M_CheckParm()
#include "m_fixed.h"
@@ -921,6 +922,8 @@ int tran_filter_pct = 66; // filter percent
#define TSC 12 /* number of fixed point digits in filter percent */
+enum {r, g, b};
+
void R_InitTranMap(int progress)
{
int lump = W_CheckNumForName("TRANMAP");
@@ -959,6 +962,25 @@ void R_InitTranMap(int progress)
fread(main_tranmap, 256, 256, cachefp) != 256 || // killough 4/11/98
force_rebuild)
{
+ byte *tp = main_tranmap;
+
+ for (int i = 0; i < 256; i++)
+ {
+ for (int j = 0; j < 256; j++)
+ {
+ byte *bg = playpal + 3*i;
+ byte *fg = playpal + 3*j;
+ byte blend[3];
+
+ int btmp = fg[b] * 1.666 < (fg[r] + fg[g]) ? 100 : 150;
+ blend[r] = MIN(100 * (fg[r] + bg[r]) / btmp, 255);
+ blend[g] = MIN(100 * (fg[g] + bg[g]) / btmp, 255);
+ blend[b] = MIN(100 * (fg[b] + bg[b]) / 100, 255);
+
+ *tp++ = I_GetNearestColor(playpal, blend[r], blend[g], blend[b]);
+ }
+ }
+/*
long pal[3][256], tot[256], pal_w1[3][256];
long w1 = ((unsigned long) tran_filter_pct<<TSC)/100;
long w2 = (1l<<TSC)-w1;
@@ -1021,10 +1043,11 @@ void R_InitTranMap(int progress)
while (--color >= 0);
}
}
+ }
+*/
// [FG] finish progress line
if (progress)
I_PutChar(VB_INFO, '\n');
- }
if (cachefp && !force_rebuild) // write out the cached translucency map
{
cache.pct = tran_filter_pct; |
Someone asked for this in the DW forums. Crispy has this for the truecolor rederer, no idea how well this works with a paletted renderer and a LUT.
The text was updated successfully, but these errors were encountered: