Skip to content

Commit

Permalink
Apply brightmaps to translucent and translated columns (#1128)
Browse files Browse the repository at this point in the history
* For Doom, Heretic and Hexen. Strife doesn't need this, as there are no custom Crispy brightmaps there.
  • Loading branch information
JNechaevsky authored Dec 21, 2023
1 parent ef9cd31 commit c36d6b1
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 23 deletions.
24 changes: 16 additions & 8 deletions src/doom/r_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,9 @@ void R_DrawTranslatedColumn (void)
// used with PLAY sprites.
// Thus the "green" ramp of the player 0 sprite
// is mapped to gray, red, black/indigo.
*dest = dc_colormap[0][dc_translation[dc_source[frac>>FRACBITS]]];
// [crispy] brightmaps
const byte source = dc_source[frac>>FRACBITS];
*dest = dc_colormap[dc_brightmap[source]][dc_translation[source]];
dest += SCREENWIDTH;

frac += fracstep;
Expand Down Expand Up @@ -615,8 +617,10 @@ void R_DrawTranslatedColumnLow (void)
// used with PLAY sprites.
// Thus the "green" ramp of the player 0 sprite
// is mapped to gray, red, black/indigo.
*dest = dc_colormap[0][dc_translation[dc_source[frac>>FRACBITS]]];
*dest2 = dc_colormap[0][dc_translation[dc_source[frac>>FRACBITS]]];
// [crispy] brightmaps
const byte source = dc_source[frac>>FRACBITS];
*dest = dc_colormap[dc_brightmap[source]][dc_translation[source]];
*dest2 = dc_colormap[dc_brightmap[source]][dc_translation[source]];
dest += SCREENWIDTH;
dest2 += SCREENWIDTH;

Expand Down Expand Up @@ -652,11 +656,13 @@ void R_DrawTLColumn (void)

do
{
// [crispy] brightmaps
const byte source = dc_source[frac>>FRACBITS];
#ifndef CRISPY_TRUECOLOR
// actual translucency map lookup taken from boom202s/R_DRAW.C:255
*dest = tranmap[(*dest<<8)+dc_colormap[0][dc_source[frac>>FRACBITS]]];
*dest = tranmap[(*dest<<8)+dc_colormap[dc_brightmap[source]][source]];
#else
const pixel_t destrgb = dc_colormap[0][dc_source[frac>>FRACBITS]];
const pixel_t destrgb = dc_colormap[dc_brightmap[source]][source];
*dest = blendfunc(*dest, destrgb);
#endif
dest += SCREENWIDTH;
Expand Down Expand Up @@ -699,11 +705,13 @@ void R_DrawTLColumnLow (void)

do
{
// [crispy] brightmaps
const byte source = dc_source[frac>>FRACBITS];
#ifndef CRISPY_TRUECOLOR
*dest = tranmap[(*dest<<8)+dc_colormap[0][dc_source[frac>>FRACBITS]]];
*dest2 = tranmap[(*dest2<<8)+dc_colormap[0][dc_source[frac>>FRACBITS]]];
*dest = tranmap[(*dest<<8)+dc_colormap[dc_brightmap[source]][source]];
*dest2 = tranmap[(*dest2<<8)+dc_colormap[dc_brightmap[source]][source]];
#else
const pixel_t destrgb = dc_colormap[0][dc_source[frac>>FRACBITS]];
const pixel_t destrgb = dc_colormap[dc_brightmap[source]][source];
*dest = blendfunc(*dest, destrgb);
*dest2 = blendfunc(*dest2, destrgb);
#endif
Expand Down
23 changes: 15 additions & 8 deletions src/heretic/r_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void R_DrawColumn(void)
do
{
// [crispy] brightmaps
const byte source = dc_source[frac>>FRACBITS];
const byte source = dc_source[frac >> FRACBITS];
*dest = dc_colormap[dc_brightmap[source]][source];
dest += SCREENWIDTH;
if ((frac += fracstep) >= heightmask)
Expand Down Expand Up @@ -213,12 +213,14 @@ void R_DrawTLColumn(void)

do
{
// [crispy] brightmaps
const byte source = dc_source[frac >> FRACBITS];
#ifndef CRISPY_TRUECOLOR
*dest =
tinttable[((*dest) << 8) +
dc_colormap[0][dc_source[frac >> FRACBITS]]];
dc_colormap[dc_brightmap[source]][source]];
#else
const pixel_t destrgb = dc_colormap[0][dc_source[frac >> FRACBITS]];
const pixel_t destrgb = dc_colormap[dc_brightmap[source]][source];
*dest = blendfunc(*dest, destrgb);
#endif
dest += SCREENWIDTH;
Expand All @@ -230,12 +232,14 @@ void R_DrawTLColumn(void)
{
do
{
// [crispy] brightmaps
const byte source = dc_source[(frac >> FRACBITS) & heightmask];
#ifndef CRISPY_TRUECOLOR
*dest =
tinttable[((*dest) << 8) +
dc_colormap[0][dc_source[(frac >> FRACBITS) & heightmask]]];
dc_colormap[dc_brightmap[source]][source]];
#else
const pixel_t destrgb = dc_colormap[0][dc_source[(frac >> FRACBITS) & heightmask]];
const pixel_t destrgb = dc_colormap[dc_brightmap[source]][source];
*dest = blendfunc(*dest, destrgb);
#endif

Expand Down Expand Up @@ -279,7 +283,9 @@ void R_DrawTranslatedColumn(void)

do
{
*dest = dc_colormap[0][dc_translation[dc_source[frac >> FRACBITS]]];
// [crispy] brightmaps
const byte source = dc_source[frac>>FRACBITS];
*dest = dc_colormap[dc_brightmap[source]][dc_translation[source]];
dest += SCREENWIDTH;
frac += fracstep;
}
Expand Down Expand Up @@ -308,11 +314,12 @@ void R_DrawTranslatedTLColumn(void)

do
{
// [crispy] brightmaps
byte src = dc_translation[dc_source[frac >> FRACBITS]];
#ifndef CRISPY_TRUECOLOR
*dest = tinttable[((*dest) << 8)
+
dc_colormap[0][dc_translation
[dc_source[frac >> FRACBITS]]]];
dc_colormap[dc_brightmap[src]][src]];
#else
const pixel_t destrgb = dc_colormap[0][dc_translation[dc_source[frac >> FRACBITS]]];

This comment has been minimized.

Copy link
@JNechaevsky

JNechaevsky Dec 21, 2023

Author Collaborator

Oops, I missed this one for true color. Should be as simple as:

const pixel_t destrgb = dc_colormap[dc_brightmap[src]][src];
*dest = blendfunc(*dest, destrgb);
Expand Down
25 changes: 18 additions & 7 deletions src/hexen/r_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ void R_DrawTLColumn(void)

do
{
// [crispy] brightmaps
const byte source = dc_source[frac >> FRACBITS];
*dest = tinttable[*dest +
(dc_colormap[0][dc_source[frac >> FRACBITS]] <<
(dc_colormap[dc_brightmap[source]][source] <<
8)];
dest += SCREENWIDTH;
if ((frac += fracstep) >= heightmask)
Expand All @@ -220,8 +222,10 @@ void R_DrawTLColumn(void)
{
do
{
// [crispy] brightmaps
const byte source = dc_source[(frac >> FRACBITS) & heightmask];
*dest = tinttable[*dest +
(dc_colormap[0][dc_source[(frac >> FRACBITS) & heightmask]] <<
(dc_colormap[dc_brightmap[source]][source] <<
8)];
dest += SCREENWIDTH;
frac += fracstep;
Expand Down Expand Up @@ -274,8 +278,10 @@ void R_DrawAltTLColumn(void)

do
{
// [crispy] brightmaps
const byte source = dc_source[frac >> FRACBITS];
*dest = tinttable[((*dest) << 8)
+ dc_colormap[0][dc_source[frac >> FRACBITS]]];
+ dc_colormap[dc_brightmap[source]][source]];
dest += SCREENWIDTH;
if ((frac += fracstep) >= heightmask)
frac -= heightmask;
Expand All @@ -285,8 +291,10 @@ void R_DrawAltTLColumn(void)
{
do
{
// [crispy] brightmaps
const byte source = dc_source[(frac >> FRACBITS) & heightmask];
*dest = tinttable[((*dest) << 8)
+ dc_colormap[0][dc_source[(frac >> FRACBITS) & heightmask]]];
+ dc_colormap[dc_brightmap[source]][source]];
dest += SCREENWIDTH;
frac += fracstep;
} while (count--);
Expand Down Expand Up @@ -326,7 +334,9 @@ void R_DrawTranslatedColumn(void)

do
{
*dest = dc_colormap[0][dc_translation[dc_source[frac >> FRACBITS]]];
// [crispy] brightmaps
const byte source = dc_source[frac >> FRACBITS];
*dest = dc_colormap[dc_brightmap[source]][dc_translation[source]];
dest += SCREENWIDTH;
frac += fracstep;
}
Expand Down Expand Up @@ -361,10 +371,11 @@ void R_DrawTranslatedTLColumn(void)

do
{
// [crispy] brightmaps
byte src = dc_translation[dc_source[frac >> FRACBITS]];
*dest = tinttable[((*dest) << 8)
+
dc_colormap[0][dc_translation
[dc_source[frac >> FRACBITS]]]];
dc_colormap[dc_brightmap[src]][src]];
dest += SCREENWIDTH;
frac += fracstep;
}
Expand Down

0 comments on commit c36d6b1

Please sign in to comment.