From 8298053e6a21aadfa040dbbb2daed1fcb572e7a6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 6 Jan 2024 19:23:05 +0300 Subject: [PATCH] ref: gl: don't depend on lightgamma in recursive light point --- ref/gl/gl_local.h | 2 -- ref/gl/gl_rlight.c | 23 ++++++++--------------- ref/gl/gl_studio.c | 2 -- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/ref/gl/gl_local.h b/ref/gl/gl_local.h index 9181adc5..311838c0 100644 --- a/ref/gl/gl_local.h +++ b/ref/gl/gl_local.h @@ -238,7 +238,6 @@ typedef struct int realframecount; // not including viewpasses int framecount; - qboolean ignore_lightgamma; qboolean fCustomRendering; qboolean fResetVis; qboolean fFlipViewModel; @@ -528,7 +527,6 @@ void GL_SetupAttributes( int safegl ); void GL_OnContextCreated( void ); void GL_InitExtensions( void ); void GL_ClearExtensions( void ); -void VID_CheckChanges( void ); int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags ); void GL_FreeImage( const char *name ); qboolean VID_ScreenShot( const char *filename, int shot_type ); diff --git a/ref/gl/gl_rlight.c b/ref/gl/gl_rlight.c index d97439ad..c2f208ae 100644 --- a/ref/gl/gl_rlight.c +++ b/ref/gl/gl_rlight.c @@ -320,18 +320,10 @@ static qboolean R_RecursiveLightPoint( model_t *model, mnode_t *node, float p1f, { uint scale = tr.lightstylevalue[surf->styles[map]]; - if( tr.ignore_lightgamma ) - { - cv->r += lm->r * scale; - cv->g += lm->g * scale; - cv->b += lm->b * scale; - } - else - { - cv->r += gEngfuncs.LightToTexGamma( lm->r ) * scale; - cv->g += gEngfuncs.LightToTexGamma( lm->g ) * scale; - cv->b += gEngfuncs.LightToTexGamma( lm->b ) * scale; - } + cv->r += lm->r * scale; + cv->g += lm->g * scale; + cv->b += lm->b * scale; + lm += size; // skip to next lightmap if( dm != NULL ) @@ -418,9 +410,10 @@ colorVec R_LightVecInternal( const vec3_t start, const vec3_t end, vec3_t lspot, { if( lspot ) VectorCopy( g_trace_lightspot, lspot ); if( lvec ) VectorNormalize2( g_trace_lightvec, lvec ); - light.r = Q_min(( cv.r >> 7 ), 255 ); - light.g = Q_min(( cv.g >> 7 ), 255 ); - light.b = Q_min(( cv.b >> 7 ), 255 ); + + light.r = Q_min(( cv.r >> 8 ), 255 ); + light.g = Q_min(( cv.g >> 8 ), 255 ); + light.b = Q_min(( cv.b >> 8 ), 255 ); last_fraction = g_trace_fraction; if(( light.r + light.g + light.b ) != 0 ) diff --git a/ref/gl/gl_studio.c b/ref/gl/gl_studio.c index 2b3de57b..d2d30b84 100644 --- a/ref/gl/gl_studio.c +++ b/ref/gl/gl_studio.c @@ -3661,9 +3661,7 @@ void R_GatherPlayerLight( void ) cl_entity_t *view = tr.viewent; colorVec c; - tr.ignore_lightgamma = true; c = R_LightPoint( view->origin ); - tr.ignore_lightgamma = false; gEngfuncs.SetLocalLightLevel( ( c.r + c.g + c.b ) / 3 ); }