Skip to content

Commit 649b94b

Browse files
committed
renderer: implement high precision rendering framebuffers
This is needed to avoid color-banding with the various division/multiplication round trips of the complete overBright implementation. This will also be needed for sRGB colors in the future too. It is enabled by default if a feature requires it. This is optional and can be disabled with r_highPrecisionRendering, or automatically disabled if the hardware doesn't support the feature.
1 parent 4e4e831 commit 649b94b

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/engine/renderer/tr_image.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2408,13 +2408,22 @@ static void R_CreateCurrentRenderImage()
24082408

24092409
imageParams_t imageParams = {};
24102410
imageParams.bits = IF_NOPICMIP;
2411+
2412+
if ( glConfig2.textureFloatAvailable && r_highPrecisionRendering.Get() )
2413+
{
2414+
imageParams.bits |= IF_RGBA16;
2415+
}
2416+
24112417
imageParams.filterType = filterType_t::FT_NEAREST;
24122418
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;
24132419

24142420
tr.currentRenderImage[0] = R_CreateImage( "_currentRender[0]", nullptr, width, height, 1, imageParams );
24152421
tr.currentRenderImage[1] = R_CreateImage( "_currentRender[1]", nullptr, width, height, 1, imageParams );
24162422

2417-
imageParams.bits |= IF_PACKED_DEPTH24_STENCIL8;
2423+
imageParams = {};
2424+
imageParams.bits = IF_NOPICMIP | IF_PACKED_DEPTH24_STENCIL8;
2425+
imageParams.filterType = filterType_t::FT_NEAREST;
2426+
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;
24182427

24192428
tr.currentDepthImage = R_CreateImage( "_currentDepth", nullptr, width, height, 1, imageParams );
24202429
}

src/engine/renderer/tr_init.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
186186
cvar_t *r_halfLambertLighting;
187187
cvar_t *r_rimLighting;
188188
cvar_t *r_rimExponent;
189+
190+
Cvar::Cvar<bool> r_highPrecisionRendering("r_highPrecisionRendering", "use high precision frame buffers for rendering and blending", Cvar::NONE, true);
191+
189192
cvar_t *r_gamma;
190193
cvar_t *r_lockpvs;
191194
cvar_t *r_noportals;
@@ -1254,6 +1257,8 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p
12541257
r_rimExponent = Cvar_Get( "r_rimExponent", "3", CVAR_CHEAT | CVAR_LATCH );
12551258
AssertCvarRange( r_rimExponent, 0.5, 8.0, false );
12561259

1260+
Cvar::Latch( r_highPrecisionRendering );
1261+
12571262
r_drawBuffer = Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT );
12581263
r_lockpvs = Cvar_Get( "r_lockpvs", "0", CVAR_CHEAT );
12591264
r_noportals = Cvar_Get( "r_noportals", "0", CVAR_CHEAT );

src/engine/renderer/tr_local.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,8 @@ enum class dynamicLightRenderer_t { LEGACY, TILED };
30323032
extern cvar_t *r_rimLighting;
30333033
extern cvar_t *r_rimExponent;
30343034

3035+
extern Cvar::Cvar<bool> r_highPrecisionRendering;
3036+
30353037
extern cvar_t *r_logFile; // number of frames to emit GL logs
30363038

30373039
extern cvar_t *r_clear; // force screen clear every frame

0 commit comments

Comments
 (0)