Add cv_debugrender_contrast, adjusts contrast of level geometry

debugrender_contrast -1.0 to 1.0, default 0.0 (no change).
Higher values add more contrast (darkens the level), lower
values add less (brighten). Does not affect thing drawing.
Software mode only.

Adds r_debug.cpp
This commit is contained in:
James R 2023-03-06 04:52:43 -08:00
parent ff838a08a5
commit 1de5046623
6 changed files with 66 additions and 4 deletions

View file

@ -64,6 +64,7 @@ add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32
tables.c
r_bsp.c
r_data.c
r_debug.cpp
r_draw.c
r_fps.c
r_main.c

38
src/r_debug.cpp Normal file
View file

@ -0,0 +1,38 @@
// RING RACERS
//-----------------------------------------------------------------------------
// Copyright (C) 2023 by James Robert Roman.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file r_debug.cpp
/// \brief Software renderer debugging
#include <algorithm> // std::clamp
#include "cxxutil.hpp"
#include "command.h"
#include "m_fixed.h"
#include "r_main.h"
namespace
{
CV_PossibleValue_t contrast_cons_t[] = {{-FRACUNIT, "MIN"}, {FRACUNIT, "MAX"}, {}};
}; // namespace
consvar_t cv_debugrender_contrast =
CVAR_INIT("debugrender_contrast", "0.0", CV_CHEAT | CV_FLOAT, contrast_cons_t, nullptr);
INT32 R_AdjustLightLevel(INT32 light)
{
constexpr fixed_t kRange = (LIGHTLEVELS - 1) * FRACUNIT;
const fixed_t adjust = FixedMul(cv_debugrender_contrast.value, kRange);
light = std::clamp((light * FRACUNIT) - adjust, 0, kRange);
return light / FRACUNIT;
}

View file

@ -1656,4 +1656,8 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_fpscap);
CV_RegisterVar(&cv_drawpickups);
// debugging
CV_RegisterVar(&cv_debugrender_contrast);
}

View file

@ -123,6 +123,13 @@ extern consvar_t cv_skybox;
extern consvar_t cv_tailspickup;
extern consvar_t cv_drawpickups;
// debugging
INT32 R_AdjustLightLevel(INT32 light);
extern consvar_t
cv_debugrender_contrast;
// Called by startup code.
void R_Init(void);

View file

@ -1030,6 +1030,8 @@ void R_DrawSinglePlane(visplane_t *pl)
if (light < 0)
light = 0;
light = R_AdjustLightLevel(light);
if (pl->slope)
{
mapfunc = R_MapTiltedPlane;

View file

@ -298,6 +298,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
else if (P_ApplyLightOffset(lightnum))
lightnum += curline->lightOffset;
lightnum = R_AdjustLightLevel(lightnum);
if (lightnum < 0)
walllights = scalelight[0];
else if (lightnum >= LIGHTLEVELS)
@ -413,12 +415,14 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
if ((rlight->flags & FOF_NOSHADE))
continue;
if (rlight->lightnum < 0)
lightnum = R_AdjustLightLevel(rlight->lightnum);
if (lightnum < 0)
xwalllights = scalelight[0];
else if (rlight->lightnum >= LIGHTLEVELS)
else if (lightnum >= LIGHTLEVELS)
xwalllights = scalelight[LIGHTLEVELS-1];
else
xwalllights = scalelight[rlight->lightnum];
xwalllights = scalelight[lightnum];
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
@ -789,6 +793,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
else if (P_ApplyLightOffset(lightnum))
lightnum += curline->lightOffset;
lightnum = R_AdjustLightLevel(lightnum);
if (lightnum < 0)
walllights = scalelight[0];
else if (lightnum >= LIGHTLEVELS)
@ -963,7 +969,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
lighteffect = !(dc_lightlist[i].flags & FOF_NOSHADE);
if (lighteffect)
{
lightnum = rlight->lightnum;
lightnum = R_AdjustLightLevel(rlight->lightnum);
if (lightnum < 0)
xwalllights = scalelight[0];
@ -1379,6 +1385,8 @@ static void R_RenderSegLoop (void)
else if (P_ApplyLightOffset(lightnum))
lightnum += curline->lightOffset;
lightnum = R_AdjustLightLevel(lightnum);
if (lightnum < 0)
xwalllights = scalelight[0];
else if (lightnum >= LIGHTLEVELS)
@ -2425,6 +2433,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (P_ApplyLightOffset(lightnum))
lightnum += curline->lightOffset;
lightnum = R_AdjustLightLevel(lightnum);
if (lightnum < 0)
walllights = scalelight[0];
else if (lightnum >= LIGHTLEVELS)