replaced r_(map)OverBrightBits with r_(map)Brightness

This commit is contained in:
myT 2017-11-22 18:59:51 +01:00
parent 964879bc5e
commit 9b60bd762d
7 changed files with 27 additions and 35 deletions

View File

@ -1,6 +1,11 @@
DD Mmm 17 - 1.49
chg: r_brightness <0.25..32> (default: 2) replaces r_overBrightBits
r_mapBrightness <0.25..32> (default: 4) replaces r_mapOverBrightBits
the new cvars use floating-point values (more control) and a linear scale (more intuitive)
new_cvar_value = pow(2, old_cvar_value), i.e. 0->1, 1->2, 2->4, 3->8, 4->16
chg: r_mode selects the video mode
r_mode 0 (default) = no screen mode change, desktop resolution
r_mode 1 = no screen mode change, custom resolution, custom upscale mode

View File

@ -33,13 +33,13 @@ static byte* fileBase;
static void R_ColorShiftLightingBytes( const byte in[4], byte out[4] )
{
// shift the color data based on overbright range
const int shift = Com_ClampInt( 0, 2, r_mapOverBrightBits->integer - tr.overbrightBits );
const float brightness = Com_Clamp( 0.25f, 32.0f, r_mapBrightness->value - r_brightness->value );
const int scale16 = (int)( brightness * 65536.0f );
// shift the data based on overbright range
int r = in[0] << shift;
int g = in[1] << shift;
int b = in[2] << shift;
// scale based on brightness
int r = ( (int)in[0] * scale16 ) >> 16;
int g = ( (int)in[1] * scale16 ) >> 16;
int b = ( (int)in[2] * scale16 ) >> 16;
// normalize by color instead of saturating to white
if ( ( r | g | b ) > 255 ) {

View File

@ -657,11 +657,10 @@ static GLSL_GammaProgramAttribs gammaProgAttribs;
static void GL2_PostProcessGamma()
{
const int obBits = r_overBrightBits->integer;
const float obScale = (float)( 1 << obBits );
const float brightness = r_brightness->value;
const float gamma = 1.0f / r_gamma->value;
if ( gamma == 1.0f && obBits == 0 )
if ( gamma == 1.0f && brightness == 1.0f )
return;
GL2_FBO_Swap();
@ -669,7 +668,7 @@ static void GL2_PostProcessGamma()
GL_Program( gammaProg );
qglUniform1i( gammaProgAttribs.texture, 0 ); // we use texture unit 0
qglUniform4f( gammaProgAttribs.gammaOverbright, gamma, gamma, gamma, obScale );
qglUniform4f( gammaProgAttribs.gammaOverbright, gamma, gamma, gamma, brightness );
GL_SelectTexture( 0 );
qglBindTexture( GL_TEXTURE_2D, frameBuffersPostProcess[frameBufferReadIndex ^ 1].color );
GL2_FullScreenQuad();

View File

@ -14,19 +14,9 @@
"allows image downscaling before texture upload\n" \
"The maximum scale ratio is 2 on both the horizontal and vertical axis."
#define help_r_overBrightBits \
"linear brightness scale\n" \
" 0 = 1x\n" \
" 1 = 2x\n" \
" 2 = 4x"
#define help_r_mapOverBrightBits \
"linear map brightness scale\n" \
"This increases the maximum brightness of the map.\n" \
"The amount of over-brighting applied is r_mapOverBrightBits - r_overBrightBits.\n" \
" 0 = 1x\n" \
" 1 = 2x\n" \
" 2 = 4x"
#define help_r_mapBrightness \
"brightness of lightmap textures\n" \
"The lightmaps' brightness will be: r_mapBrightness - r_brightness."
#define help_r_mode \
"video mode to use when r_fullscreen is 1\n" \

View File

@ -862,8 +862,7 @@ static void R_CreateBuiltinImages()
void R_SetColorMappings()
{
tr.overbrightBits = r_overBrightBits->integer;
tr.identityLight = 1.0f / (float)( 1 << tr.overbrightBits );
tr.identityLight = 1.0f / r_brightness->value;
tr.identityLightByte = (int)( 255.0f * tr.identityLight );
for (int i = 0; i < 256; ++i) {

View File

@ -95,8 +95,8 @@ cvar_t *r_width;
cvar_t *r_height;
cvar_t *r_customaspect;
cvar_t *r_overBrightBits;
cvar_t *r_mapOverBrightBits;
cvar_t *r_brightness;
cvar_t *r_mapBrightness;
cvar_t *r_debugSurface;
@ -495,8 +495,6 @@ void GfxInfo_f( void )
else
ri.Printf( PRINT_ALL, "\n" );
ri.Printf( PRINT_DEVELOPER, "GAMMA: %d overbright bits\n", tr.overbrightBits );
ri.Printf( PRINT_DEVELOPER, "texturemode: %s\n", r_textureMode->string );
ri.Printf( PRINT_DEVELOPER, "picmip: %d\n", r_picmip->integer );
ri.Printf( PRINT_DEVELOPER, "ambient pass: %s\n", r_vertexLight->integer ? "vertex" : "lightmap" );
@ -536,9 +534,13 @@ static const cvarTableItem_t r_cvars[] =
{ &r_roundImagesDown, "r_roundImagesDown", "0", CVAR_ARCHIVE | CVAR_LATCH, CVART_BOOL, NULL, NULL, help_r_roundImagesDown },
{ &r_colorMipLevels, "r_colorMipLevels", "0", CVAR_LATCH, CVART_BOOL, NULL, NULL, "colorizes textures based on their mip level" },
{ &r_detailTextures, "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_BOOL, NULL, NULL, "enables detail textures shader stages" },
{ &r_overBrightBits, "r_overBrightBits", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "0", "2", help_r_overBrightBits },
{ &r_mode, "r_mode", "0", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "0", XSTRING(VIDEOMODE_MAX), help_r_mode },
{ &r_blitMode, "r_blitMode", "0", CVAR_ARCHIVE, CVART_INTEGER, "0", XSTRING(BLITMODE_MAX), help_r_blitMode },
{ &r_brightness, "r_brightness", "2", CVAR_ARCHIVE | CVAR_LATCH, CVART_FLOAT, "0.25", "32", "overall brightness" },
// should be called r_lightmapBrightness
{ &r_mapBrightness, "r_mapBrightness", "4", CVAR_ARCHIVE | CVAR_LATCH, CVART_FLOAT, "0.25", "32", help_r_mapBrightness },
// should be called r_textureBrightness
{ &r_intensity, "r_intensity", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_FLOAT, "1", NULL, "brightness of non-lightmap textures" },
{ &r_fullscreen, "r_fullscreen", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_BOOL, NULL, NULL, "full-screen mode" },
{ &r_width, "r_width", "1280", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "320", "65535", "custom window/render width" help_r_mode01 },
{ &r_height, "r_height", "720", CVAR_ARCHIVE | CVAR_LATCH, CVART_INTEGER, "240", "65535", "custom window/render height" help_r_mode01 },
@ -551,8 +553,6 @@ static const cvarTableItem_t r_cvars[] =
// latched variables that can only change over a restart
//
{ &r_displayRefresh, "r_displayRefresh", "0", CVAR_LATCH, CVART_INTEGER, "0", "480", "0 lets the driver decide" },
{ &r_mapOverBrightBits, "r_mapOverBrightBits", "2", CVAR_LATCH, CVART_INTEGER, "0", "2", help_r_mapOverBrightBits },
{ &r_intensity, "r_intensity", "1", CVAR_ARCHIVE | CVAR_LATCH, CVART_FLOAT, "1", NULL, "linear brightness scale for textures and dynamic lights" },
{ &r_singleShader, "r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH },
//

View File

@ -873,7 +873,6 @@ typedef struct {
float identityLight; // 1.0 / ( 1 << overbrightBits )
int identityLightByte; // identityLight * 255
int overbrightBits; // r_overbrightBits->integer
orientationr_t orient; // for current entity
@ -996,8 +995,8 @@ extern cvar_t *r_lodCurveError;
extern cvar_t *r_ignoreGLErrors;
extern cvar_t *r_overBrightBits;
extern cvar_t *r_mapOverBrightBits;
extern cvar_t *r_brightness;
extern cvar_t *r_mapBrightness;
extern cvar_t *r_debugSurface;