From 5904b538d7fd639429a450b0ad7928cd311213fd Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sun, 28 Jun 2015 00:42:21 +0200 Subject: Make cg_brighten more precise. --- src/cgame/cg_draw.c | 35 ++++++++++++++++++++++++++--------- src/cgame/cg_local.h | 4 +++- src/cgame/cg_main.c | 9 +++++++-- 3 files changed, 36 insertions(+), 12 deletions(-) (limited to 'src/cgame') diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index a439b51..0ee4042 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -4141,13 +4141,28 @@ static void CG_DrawHealthBars( void ) CG_Brighten ================= */ -static void CG_Brighten( int iterations ) +static void CG_Brighten( float target ) { int i; - for( i = 0; i < iterations; i++ ) + if( target <= 1 ) { - CG_DrawPic( 0, 0, 640, 480, cgs.media.brightenShader ); + return; + } + +repeat: + for( i = 0; i < NUM_BRIGHTEN_SHADERS; i++ ) + { + float factor; + + factor = 1.0 + pow( 2, -i ); + + if( target >= factor ) + { + CG_DrawPic( 0, 0, 640, 480, cgs.media.brightenShaders[ i ] ); + target /= factor; + goto repeat; + } } } @@ -4192,11 +4207,6 @@ static void CG_DrawWarpOverlay( void ) { trap_R_SetColor( NULL ); - if( cg_brighten.integer < 2 ) - { - CG_Brighten( MIN( 2 - cg_brighten.integer, 2 ) ); - } - CG_DrawPic( 0, 0, 640, 480, cgs.media.warpOverlay ); if( cg.warpExitBlocked ) @@ -4232,7 +4242,14 @@ static void CG_Draw2D( void ) // (only 2D that can't be disabled) CG_DrawLighting( ); - CG_Brighten( cg_brighten.integer ); + if( cg.warping && cg_brightenWraith.value >= cg_brighten.value ) + { + CG_Brighten( cg_brightenWraith.value ); + } + else + { + CG_Brighten( cg_brighten.value ); + } CG_DrawWarpOverlay( ); diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 8f0586e..27e9baf 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1166,6 +1166,7 @@ typedef struct qboolean warpExitBlocked; } cg_t; +#define NUM_BRIGHTEN_SHADERS 5 // all of the model, shader, and sound references that are // loaded at gamestate time are stored in cgMedia_t @@ -1366,7 +1367,7 @@ typedef struct qhandle_t warpingEnvironmentShader; qhandle_t warpParticle; - qhandle_t brightenShader; + qhandle_t brightenShaders[ NUM_BRIGHTEN_SHADERS ]; } cgMedia_t; typedef struct @@ -1634,6 +1635,7 @@ extern vmCvar_t cg_hitSounds; extern vmCvar_t cg_hitStats; extern vmCvar_t cg_brighten; +extern vmCvar_t cg_brightenWraith; // // cg_main.c diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 91187fe..e17965c 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -242,6 +242,7 @@ vmCvar_t cg_hitSounds; vmCvar_t cg_hitStats; vmCvar_t cg_brighten; +vmCvar_t cg_brightenWraith; typedef struct { @@ -401,7 +402,8 @@ static cvarTable_t cvarTable[ ] = { &cg_hitSounds, "cg_hitSounds", "1", CVAR_ARCHIVE }, { &cg_hitStats, "cg_hitStats", "0", CVAR_ARCHIVE }, - { &cg_brighten, "cg_brighten", "0", CVAR_ARCHIVE } + { &cg_brighten, "cg_brighten", "0", CVAR_ARCHIVE }, + { &cg_brightenWraith, "cg_brightenWraith", "4", CVAR_ARCHIVE } }; static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); @@ -946,7 +948,10 @@ static void CG_RegisterGraphics( void ) cgs.media.warpingEnvironmentShader = trap_R_RegisterShader( "gfx/level1/warpingEnvironment" ); cgs.media.warpParticle = trap_R_RegisterShader( "gfx/level1/warpParticle1" ); - cgs.media.brightenShader = trap_R_RegisterShader( "gfx/brighten" ); + for( i = 0; i < NUM_BRIGHTEN_SHADERS; i++ ) + { + cgs.media.brightenShaders[ i ] = trap_R_RegisterShader( va( "gfx/brighten%d", i ) ); + } CG_BuildableStatusParse( "ui/assets/human/buildstat.cfg", &cgs.humanBuildStat ); CG_BuildableStatusParse( "ui/assets/alien/buildstat.cfg", &cgs.alienBuildStat ); -- cgit