mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2025-01-01 05:35:49 +01:00
ref: gl: support overbrights, change the gamma applying order closer to the original renderer
This commit is contained in:
parent
8298053e6a
commit
18436a70eb
@ -767,6 +767,7 @@ extern convar_t gl_nosort;
|
||||
extern convar_t gl_test; // cvar to testify new effects
|
||||
extern convar_t gl_msaa;
|
||||
extern convar_t gl_stencilbits;
|
||||
extern convar_t gl_overbright;
|
||||
|
||||
extern convar_t r_lighting_extended;
|
||||
extern convar_t r_lighting_ambient;
|
||||
|
@ -19,6 +19,7 @@ CVAR_DEFINE_AUTO( gl_nosort, "0", FCVAR_GLCONFIG, "disable sorting of translucen
|
||||
CVAR_DEFINE_AUTO( gl_test, "0", 0, "engine developer cvar for quick testing new features" );
|
||||
CVAR_DEFINE_AUTO( gl_msaa, "1", FCVAR_GLCONFIG, "enable or disable multisample anti-aliasing" );
|
||||
CVAR_DEFINE_AUTO( gl_stencilbits, "8", FCVAR_GLCONFIG|FCVAR_READ_ONLY, "pixelformat stencil bits (0 - auto)" );
|
||||
CVAR_DEFINE_AUTO( gl_overbright, "1", FCVAR_GLCONFIG, "overbrights" );
|
||||
CVAR_DEFINE_AUTO( r_lighting_extended, "1", FCVAR_GLCONFIG, "allow to get lighting from world and bmodels" );
|
||||
CVAR_DEFINE_AUTO( r_lighting_ambient, "0.3", FCVAR_GLCONFIG, "map ambient lighting scale" );
|
||||
CVAR_DEFINE_AUTO( r_detailtextures, "1", FCVAR_ARCHIVE, "enable detail textures support" );
|
||||
@ -1203,6 +1204,7 @@ void GL_InitCommands( void )
|
||||
gEngfuncs.Cvar_RegisterVariable( &gl_msaa );
|
||||
gEngfuncs.Cvar_RegisterVariable( &gl_stencilbits );
|
||||
gEngfuncs.Cvar_RegisterVariable( &gl_round_down );
|
||||
gEngfuncs.Cvar_RegisterVariable( &gl_overbright );
|
||||
|
||||
// these cvar not used by engine but some mods requires this
|
||||
gEngfuncs.Cvar_RegisterVariable( &gl_polyoffset );
|
||||
|
@ -1001,6 +1001,15 @@ void R_GammaChanged( qboolean do_reset_gamma )
|
||||
}
|
||||
}
|
||||
|
||||
static void R_CheckGamma( void )
|
||||
{
|
||||
if( FBitSet( gl_overbright.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
R_GammaChanged( false );
|
||||
ClearBits( gl_overbright.flags, FCVAR_CHANGED );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
R_BeginFrame
|
||||
@ -1016,6 +1025,8 @@ void R_BeginFrame( qboolean clearScene )
|
||||
pglClear( GL_COLOR_BUFFER_BIT );
|
||||
}
|
||||
|
||||
R_CheckGamma();
|
||||
|
||||
R_Set2DMode( true );
|
||||
|
||||
// draw buffer stuff
|
||||
|
@ -600,9 +600,9 @@ void R_AddDynamicLights( msurface_t *surf )
|
||||
|
||||
if( dist < minlight )
|
||||
{
|
||||
bl[0] += ((int)((rad - dist) * 256) * gEngfuncs.LightToTexGamma( dl->color.r )) / 256;
|
||||
bl[1] += ((int)((rad - dist) * 256) * gEngfuncs.LightToTexGamma( dl->color.g )) / 256;
|
||||
bl[2] += ((int)((rad - dist) * 256) * gEngfuncs.LightToTexGamma( dl->color.b )) / 256;
|
||||
bl[0] += ((int)((rad - dist) * 256) * dl->color.r ) / 256;
|
||||
bl[1] += ((int)((rad - dist) * 256) * dl->color.g ) / 256;
|
||||
bl[2] += ((int)((rad - dist) * 256) * dl->color.b ) / 256;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -742,11 +742,15 @@ static void R_BuildLightMap( msurface_t *surf, byte *dest, int stride, qboolean
|
||||
int sample_size;
|
||||
mextrasurf_t *info = surf->info;
|
||||
color24 *lm;
|
||||
int lightscale;
|
||||
|
||||
sample_size = gEngfuncs.Mod_SampleSizeForFace( surf );
|
||||
smax = ( info->lightextents[0] / sample_size ) + 1;
|
||||
tmax = ( info->lightextents[1] / sample_size ) + 1;
|
||||
size = smax * tmax;
|
||||
if( gl_overbright.value )
|
||||
lightscale = 256;
|
||||
else lightscale = ( pow( 2.0f, 1.0f / v_lightgamma->value ) * 256 ) + 0.5;
|
||||
|
||||
lm = surf->samples;
|
||||
|
||||
@ -759,9 +763,9 @@ static void R_BuildLightMap( msurface_t *surf, byte *dest, int stride, qboolean
|
||||
|
||||
for( i = 0, bl = r_blocklights; i < size; i++, bl += 3, lm++ )
|
||||
{
|
||||
bl[0] += gEngfuncs.LightToTexGamma( lm->r ) * scale;
|
||||
bl[1] += gEngfuncs.LightToTexGamma( lm->g ) * scale;
|
||||
bl[2] += gEngfuncs.LightToTexGamma( lm->b ) * scale;
|
||||
bl[0] += lm->r * scale;
|
||||
bl[1] += lm->g * scale;
|
||||
bl[2] += lm->b * scale;
|
||||
}
|
||||
}
|
||||
|
||||
@ -777,9 +781,16 @@ static void R_BuildLightMap( msurface_t *surf, byte *dest, int stride, qboolean
|
||||
{
|
||||
for( s = 0; s < smax; s++ )
|
||||
{
|
||||
dest[0] = Q_min((bl[0] >> 7), 255 );
|
||||
dest[1] = Q_min((bl[1] >> 7), 255 );
|
||||
dest[2] = Q_min((bl[2] >> 7), 255 );
|
||||
int i;
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
int t = bl[i] * lightscale >> 14;
|
||||
|
||||
if( t > 1023 )
|
||||
t = 1023;
|
||||
|
||||
dest[i] = gEngfuncs.LightToTexGammaEx( t ) >> 2;
|
||||
}
|
||||
dest[3] = 255;
|
||||
|
||||
bl += 3;
|
||||
@ -944,7 +955,15 @@ void R_BlendLightmaps( void )
|
||||
pglDepthFunc( GL_EQUAL );
|
||||
|
||||
pglDisable( GL_ALPHA_TEST );
|
||||
pglBlendFunc( GL_ZERO, GL_SRC_COLOR );
|
||||
if( gl_overbright.value )
|
||||
{
|
||||
pglBlendFunc( GL_DST_COLOR, GL_SRC_COLOR );
|
||||
pglColor4f( 128.0f / 192.0f, 128.0f / 192.0f, 128.0f / 192.0f, 1.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
pglBlendFunc( GL_ZERO, GL_SRC_COLOR );
|
||||
}
|
||||
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
|
||||
// render static lightmaps first
|
||||
|
Loading…
Reference in New Issue
Block a user