summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2015-06-28 00:42:21 +0200
committerPaweł Redman <pawel.redman@gmail.com>2015-06-28 00:42:21 +0200
commit5904b538d7fd639429a450b0ad7928cd311213fd (patch)
treee8a84511c944e157400927cf9ece1c5271b2fd12
parent1d91c18466031a320b70828d84541b8094a2b486 (diff)
Make cg_brighten more precise.
-rw-r--r--assets/gfx/gray_128.jpgbin0 -> 284 bytes
-rw-r--r--assets/gfx/gray_16.jpgbin0 -> 283 bytes
-rw-r--r--assets/gfx/gray_32.jpgbin0 -> 283 bytes
-rw-r--r--assets/gfx/gray_64.jpgbin0 -> 283 bytes
-rw-r--r--assets/scripts/system_effects.shader35
-rw-r--r--src/cgame/cg_draw.c35
-rw-r--r--src/cgame/cg_local.h4
-rw-r--r--src/cgame/cg_main.c9
8 files changed, 70 insertions, 13 deletions
diff --git a/assets/gfx/gray_128.jpg b/assets/gfx/gray_128.jpg
new file mode 100644
index 0000000..272b6ce
--- /dev/null
+++ b/assets/gfx/gray_128.jpg
Binary files differ
diff --git a/assets/gfx/gray_16.jpg b/assets/gfx/gray_16.jpg
new file mode 100644
index 0000000..8725021
--- /dev/null
+++ b/assets/gfx/gray_16.jpg
Binary files differ
diff --git a/assets/gfx/gray_32.jpg b/assets/gfx/gray_32.jpg
new file mode 100644
index 0000000..7f18e70
--- /dev/null
+++ b/assets/gfx/gray_32.jpg
Binary files differ
diff --git a/assets/gfx/gray_64.jpg b/assets/gfx/gray_64.jpg
new file mode 100644
index 0000000..a419769
--- /dev/null
+++ b/assets/gfx/gray_64.jpg
Binary files differ
diff --git a/assets/scripts/system_effects.shader b/assets/scripts/system_effects.shader
index b5366a9..db153d8 100644
--- a/assets/scripts/system_effects.shader
+++ b/assets/scripts/system_effects.shader
@@ -689,10 +689,43 @@ gfx/misc/nopower
}
-gfx/brighten
+gfx/brighten0 // x2
{
{
map *white
blendFunc GL_DST_COLOR GL_ONE
}
}
+
+gfx/brighten1 // x1.5
+{
+ {
+ map gfx/gray_128
+ blendFunc GL_DST_COLOR GL_ONE
+ }
+}
+
+gfx/brighten2 // x1.25
+{
+ {
+ map gfx/gray_64
+ blendFunc GL_DST_COLOR GL_ONE
+ }
+}
+
+gfx/brighten3 // x1.125
+{
+ {
+ map gfx/gray_32
+ blendFunc GL_DST_COLOR GL_ONE
+ }
+}
+
+gfx/brighten4 // x1.0625
+{
+ {
+ map gfx/gray_16
+ blendFunc GL_DST_COLOR GL_ONE
+ }
+}
+
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 );