Skip to content
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

TrueColor: implement optional tablified translucency #1233

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions src/crispy.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static crispy_t crispy_s = {
#ifdef CRISPY_TRUECOLOR
.smoothlight = 1,
.truecolor = 1,
.truecolorblend = 1,
#endif
.vsync = 1,
.widescreen = 1, // match screen by default
Expand Down
8 changes: 8 additions & 0 deletions src/crispy.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ typedef struct
int translucency;
#ifdef CRISPY_TRUECOLOR
int truecolor;
int truecolorblend;
#endif
int uncapped;
int vsync;
Expand Down Expand Up @@ -243,6 +244,13 @@ enum
NUM_SECRETMESSAGE
};

enum
{
TRUECOLORBLEND_OFF,
TRUECOLORBLEND_ON,
NUM_TRUECOLORBLEND
};

enum
{
WIDGETS_OFF,
Expand Down
1 change: 1 addition & 0 deletions src/doom/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ void D_BindVariables(void)
M_BindIntVariable("crispy_translucency", &crispy->translucency);
#ifdef CRISPY_TRUECOLOR
M_BindIntVariable("crispy_truecolor", &crispy->truecolor);
M_BindIntVariable("crispy_truecolorblend", &crispy->truecolorblend);
#endif
M_BindIntVariable("crispy_uncapped", &crispy->uncapped);
M_BindIntVariable("crispy_vsync", &crispy->vsync);
Expand Down
17 changes: 17 additions & 0 deletions src/doom/m_crispy.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ multiitem_t multiitem_sndchannels[4] =
{32, "32"},
};

multiitem_t multiitem_truecolorblend[NUM_TRUECOLORBLEND] =
{
{TRUECOLORBLEND_OFF, "speed"},
{TRUECOLORBLEND_ON, "quality"},
};

multiitem_t multiitem_widgets[NUM_WIDGETS] =
{
{WIDGETS_OFF, "never"},
Expand Down Expand Up @@ -573,6 +579,17 @@ void M_CrispyToggleTranslucency(int choice)
ChangeSettingEnum(&crispy->translucency, choice, NUM_TRANSLUCENCY);
}

#ifdef CRISPY_TRUECOLOR
void M_CrispyToggleTrueColorBlend(int choice)
{
choice = 0;
crispy->truecolorblend = !crispy->truecolorblend;

// [crispy] re-set pointers to blending functions
R_InitBlendQuality();
}
#endif

void M_CrispyToggleUncapped(int choice)
{
choice = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/doom/m_crispy.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extern multiitem_t multiitem_sndchannels[4];
extern multiitem_t multiitem_secretmessage[NUM_SECRETMESSAGE];
extern multiitem_t multiitem_statsformat[NUM_STATSFORMATS];
extern multiitem_t multiitem_translucency[NUM_TRANSLUCENCY];
extern multiitem_t multiitem_truecolorblend[NUM_TRUECOLORBLEND];
extern multiitem_t multiitem_widgets[NUM_WIDGETS];
extern multiitem_t multiitem_widescreen[NUM_RATIOS];
extern multiitem_t multiitem_difficulties[NUM_SKILLS];
Expand Down Expand Up @@ -84,6 +85,7 @@ extern void M_CrispyToggleSoundfixes(int choice);
extern void M_CrispyToggleSoundMono(int choice);
extern void M_CrispyToggleStatsFormat(int choice);
extern void M_CrispyToggleTranslucency(int choice);
extern void M_CrispyToggleTrueColorBlend(int choice);
extern void M_CrispyToggleUncapped(int choice);
extern void M_CrispyToggleVsync(int choice);
extern void M_CrispyToggleWidescreen(int choice);
Expand Down
27 changes: 14 additions & 13 deletions src/doom/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,17 +468,19 @@ enum
crispness_fpslimit,
crispness_vsync,
crispness_smoothscaling,
crispness_sep_rendering_,

crispness_sep_visual,
crispness_coloredhud,
crispness_translucency,
#ifdef CRISPY_TRUECOLOR
crispness_truecolorblend,
#endif
crispness_smoothlight,
crispness_brightmaps,
crispness_coloredblood,
crispness_flipcorpses,
crispness_sep_visual_,

crispness1_sep_empty,
crispness1_next,
crispness1_prev,
crispness1_end
Expand All @@ -494,9 +496,11 @@ static menuitem_t Crispness1Menu[]=
{3,"", M_CrispyToggleVsync,'v'},
{3,"", M_CrispyToggleSmoothScaling,'s'},
{-1,"",0,'\0'},
{-1,"",0,'\0'},
{3,"", M_CrispyToggleColoredhud,'c'},
{3,"", M_CrispyToggleTranslucency,'e'},
#ifdef CRISPY_TRUECOLOR
{3,"", M_CrispyToggleTrueColorBlend,'t'},
#endif
{3,"", M_CrispyToggleSmoothLighting,'s'},
{3,"", M_CrispyToggleBrightmaps,'b'},
{3,"", M_CrispyToggleColoredblood,'c'},
Expand All @@ -523,7 +527,6 @@ enum
crispness_soundfix,
crispness_sndchannels,
crispness_soundmono,
crispness_sep_audible_,

crispness_sep_navigational,
crispness_extautomap,
Expand All @@ -533,8 +536,8 @@ enum
crispness_leveltime,
crispness_playercoords,
crispness_secretmessage,
crispness_sep_navigational_,


crispness2_sep_empty,
crispness2_next,
crispness2_prev,
crispness2_end
Expand All @@ -548,7 +551,6 @@ static menuitem_t Crispness2Menu[]=
{3,"", M_CrispyToggleSndChannels,'s'},
{3,"", M_CrispyToggleSoundMono,'m'},
{-1,"",0,'\0'},
{-1,"",0,'\0'},
{3,"", M_CrispyToggleExtAutomap,'e'},
{3,"", M_CrispyToggleSmoothMap,'m'},
{3,"", M_CrispyToggleAutomapstats,'s'},
Expand Down Expand Up @@ -581,15 +583,14 @@ enum
crispness_pitch,
crispness_neghealth,
crispness_defaultskill,
crispness_sep_tactical_,

crispness_sep_crosshair,
crispness_crosshair,
crispness_crosshairtype,
crispness_crosshairhealth,
crispness_crosshairtarget,
crispness_sep_crosshair_,

crispness3_sep_empty,
crispness3_next,
crispness3_prev,
crispness3_end
Expand All @@ -606,7 +607,6 @@ static menuitem_t Crispness3Menu[]=
{3,"", M_CrispyToggleNeghealth,'n'},
{3,"", M_CrispyToggleDefaultSkill,'d'},
{-1,"",0,'\0'},
{-1,"",0,'\0'},
{3,"", M_CrispyToggleCrosshair,'d'},
{3,"", M_CrispyToggleCrosshairtype,'c'},
{3,"", M_CrispyToggleCrosshairHealth,'c'},
Expand All @@ -632,15 +632,14 @@ enum
crispness_freeaim,
crispness_jumping,
crispness_overunder,
crispness_sep_physical_,

crispness_sep_demos,
crispness_demotimer,
crispness_demotimerdir,
crispness_demobar,
crispness_demousetimer,
crispness_sep_demos_,

crispness4_sep_empty,
crispness4_next,
crispness4_prev,
crispness4_end
Expand All @@ -654,7 +653,6 @@ static menuitem_t Crispness4Menu[]=
{3,"", M_CrispyToggleJumping,'a'},
{3,"", M_CrispyToggleOverunder,'w'},
{-1,"",0,'\0'},
{-1,"",0,'\0'},
{3,"", M_CrispyToggleDemoTimer,'v'},
{3,"", M_CrispyToggleDemoTimerDir,'a'},
{3,"", M_CrispyToggleDemoBar,'w'},
Expand Down Expand Up @@ -1574,6 +1572,9 @@ static void M_DrawCrispness1(void)
M_DrawCrispnessSeparator(crispness_sep_visual, "Visual");
M_DrawCrispnessMultiItem(crispness_coloredhud, "Colorize HUD Elements", multiitem_coloredhud, crispy->coloredhud, true);
M_DrawCrispnessMultiItem(crispness_translucency, "Enable Translucency", multiitem_translucency, crispy->translucency, true);
#ifdef CRISPY_TRUECOLOR
M_DrawCrispnessMultiItem(crispness_truecolorblend, "Translucency mode", multiitem_truecolorblend, crispy->truecolorblend, true);
#endif
M_DrawCrispnessItem(crispness_smoothlight, "Smooth Diminishing Lighting", crispy->smoothlight, true);
M_DrawCrispnessMultiItem(crispness_brightmaps, "Apply Brightmaps to", multiitem_brightmaps, crispy->brightmaps, true);
M_DrawCrispnessMultiItem(crispness_coloredblood, "Colored Blood", multiitem_coloredblood, crispy->coloredblood, gameversion != exe_chex);
Expand Down
6 changes: 6 additions & 0 deletions src/doom/r_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,12 @@ void R_InitData (void)
R_InitHSVColors ();
#ifndef CRISPY_TRUECOLOR
R_InitTranMap(); // [crispy] prints a mark itself
#else
// [crispy] Initialize blending maps for tablified additive and
// overlay translucency, used by TrueColor renderer.
R_InitBlendMaps(doom);
// [crispy] Set pointers to blending functions.
R_InitBlendQuality();
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/doom/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ void R_ProjectSprite (mobj_t* thing)
// [crispy] translucent sprites
if (thing->flags & MF_TRANSLUCENT)
{
vis->blendfunc = (thing->frame & FF_FULLBRIGHT) ? I_BlendAdd : I_BlendOverTranmap;
vis->blendfunc = (thing->frame & FF_FULLBRIGHT) ? I_BlendAddFunc : I_BlendOverTranmap;
}
#endif
}
Expand Down
1 change: 1 addition & 0 deletions src/heretic/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ void D_BindVariables(void)
M_BindIntVariable("crispy_soundmono", &crispy->soundmono);
#ifdef CRISPY_TRUECOLOR
M_BindIntVariable("crispy_truecolor", &crispy->truecolor);
M_BindIntVariable("crispy_truecolorblend", &crispy->truecolorblend);
#endif
M_BindIntVariable("crispy_uncapped", &crispy->uncapped);
M_BindIntVariable("crispy_vsync", &crispy->vsync);
Expand Down
Loading
Loading