From 79e9c8c3d0d4d469c802adb179183f4e328b4be8 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 25 Apr 2017 15:02:22 +0200 Subject: [PATCH] GL3: gl3_intensity_2D cvar for HUD, menu, console, video intensity there have been complaints that those things look too bright, so let people configure their intensity independently of the general intensity used for levels, monsters etc. fixes #189 --- src/client/refresh/gl3/gl3_main.c | 6 +++++- src/client/refresh/gl3/gl3_shaders.c | 8 ++++++-- src/client/refresh/gl3/header/local.h | 4 +++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/client/refresh/gl3/gl3_main.c b/src/client/refresh/gl3/gl3_main.c index 06b4b7a2..7d6e2124 100644 --- a/src/client/refresh/gl3/gl3_main.c +++ b/src/client/refresh/gl3/gl3_main.c @@ -104,6 +104,7 @@ cvar_t *gl_lefthand; cvar_t *gl_farsee; cvar_t *gl3_intensity; +cvar_t *gl3_intensity_2D; cvar_t *gl_lightlevel; cvar_t *gl3_overbrightbits; @@ -226,6 +227,7 @@ GL3_Register(void) vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE); vid_gamma = ri.Cvar_Get("vid_gamma", "1.2", CVAR_ARCHIVE); gl3_intensity = ri.Cvar_Get("gl3_intensity", "1.5", CVAR_ARCHIVE); + gl3_intensity_2D = ri.Cvar_Get("gl3_intensity_2D", "1.5", CVAR_ARCHIVE); gl_lightlevel = ri.Cvar_Get("gl_lightlevel", "0", 0); gl3_overbrightbits = ri.Cvar_Get("gl3_overbrightbits", "1.3", CVAR_ARCHIVE); @@ -1619,13 +1621,15 @@ GL3_BeginFrame(float camera_separation) } #endif // 0 - if (vid_gamma->modified || gl3_intensity->modified) + if (vid_gamma->modified || gl3_intensity->modified || gl3_intensity_2D->modified) { vid_gamma->modified = false; gl3_intensity->modified = false; + gl3_intensity_2D->modified = false; gl3state.uniCommonData.gamma = 1.0f/vid_gamma->value; gl3state.uniCommonData.intensity = gl3_intensity->value; + gl3state.uniCommonData.intensity2D = gl3_intensity_2D->value; GL3_UpdateUBOCommon(); } diff --git a/src/client/refresh/gl3/gl3_shaders.c b/src/client/refresh/gl3/gl3_shaders.c index d868b255..43466194 100644 --- a/src/client/refresh/gl3/gl3_shaders.c +++ b/src/client/refresh/gl3/gl3_shaders.c @@ -192,6 +192,7 @@ static const char* fragmentSrc2D = MULTILINE_STRING(#version 150\n { float gamma; float intensity; + float intensity2D; // for HUD, menu etc vec4 color; }; @@ -210,7 +211,7 @@ static const char* fragmentSrc2D = MULTILINE_STRING(#version 150\n discard; // apply gamma correction and intensity - texel.rgb *= intensity; + texel.rgb *= intensity2D; outColor.rgb = pow(texel.rgb, vec3(gamma)); outColor.a = texel.a; // I think alpha shouldn't be modified by gamma and intensity } @@ -240,6 +241,7 @@ static const char* fragmentSrc2Dcolor = MULTILINE_STRING(#version 150\n { float gamma; float intensity; + float intensity2D; // for HUD, menus etc vec4 color; }; @@ -248,7 +250,7 @@ static const char* fragmentSrc2Dcolor = MULTILINE_STRING(#version 150\n void main() { - vec3 col = color.rgb * intensity; + vec3 col = color.rgb * intensity2D; outColor.rgb = pow(col, vec3(gamma)); outColor.a = color.a; } @@ -296,6 +298,7 @@ static const char* fragmentCommon3D = MULTILINE_STRING(#version 150\n { float gamma; // this is 1.0/vid_gamma float intensity; + float intensity2D; // for HUD, menus etc vec4 color; // really? @@ -934,6 +937,7 @@ static void initUBOs(void) { gl3state.uniCommonData.gamma = 1.0f/vid_gamma->value; gl3state.uniCommonData.intensity = gl3_intensity->value; + gl3state.uniCommonData.intensity2D = gl3_intensity_2D->value; gl3state.uniCommonData.color = HMM_Vec4(1, 1, 1, 1); glGenBuffers(1, &gl3state.uniCommonUBO); diff --git a/src/client/refresh/gl3/header/local.h b/src/client/refresh/gl3/header/local.h index 78e72535..752896c6 100644 --- a/src/client/refresh/gl3/header/local.h +++ b/src/client/refresh/gl3/header/local.h @@ -123,10 +123,11 @@ typedef struct { GLfloat gamma; GLfloat intensity; + GLfloat intensity2D; // for HUD, menus etc // entries of std140 UBOs are aligned to multiples of their own size // so we'll need to pad accordingly for following vec4 - GLfloat _padding[2]; + GLfloat _padding; hmm_vec4 color; } gl3UniCommon_t; @@ -498,6 +499,7 @@ extern cvar_t *gl_drawworld; extern cvar_t *vid_gamma; extern cvar_t *gl3_intensity; +extern cvar_t *gl3_intensity_2D; extern cvar_t *gl_anisotropic; extern cvar_t *gl_lightlevel;