From 6eae7acd34e595f812dfbe0fa9f97be47d3b5054 Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 27 Mar 2019 21:34:37 +0700 Subject: [PATCH] ref_soft: lightstyle support --- r_context.c | 2 +- r_surf.c | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/r_context.c b/r_context.c index 6291680b..1df68953 100644 --- a/r_context.c +++ b/r_context.c @@ -495,7 +495,7 @@ void CL_DrawParticlesExternal(const ref_viewpass_t *rvp, qboolean trans_pass, fl void GL_BuildLightmaps() { - + CL_RunLightStyles(); } void Mod_SetOrthoBounds(const float *mins, const float *maxs) diff --git a/r_surf.c b/r_surf.c index b3aa4748..784ca161 100644 --- a/r_surf.c +++ b/r_surf.c @@ -198,9 +198,9 @@ static void R_BuildLightMap( ) for( i = 0, bl = blocklights; i < size; i++, bl += 1, lm++ ) { - bl[0] += lm->r * 2.5; - bl[0] += lm->g * 2.5; - bl[0] += lm->b * 2.5; + bl[0] += lm->r * scale * 2.5; + bl[0] += lm->g * scale * 2.5; + bl[0] += lm->b * scale * 2.5; //printf("test\n"); //bl[1] += gEngfuncs.LightToTexGamma( lm->g ) * scale; @@ -235,9 +235,9 @@ static void R_BuildLightMap( ) t = (int)blocklights[i]; if (t < 0) t = 0; - if( t > 767 ) - t = 767; - t = t * 31 / 256 / 3;//(255*256 - t) >> (8 - VID_CBITS); + if( t > 65535 * 3 ) + t = 65535 * 3; + t = t * 31 / 65535 / 3;//(255*256 - t) >> (8 - VID_CBITS); //if (t < (1 << 6)) //t = (1 << 6); @@ -970,6 +970,7 @@ D_CacheSurface surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel) { surfcache_t *cache; + int maps; // // if the surface is animating or flashing, flush the cache // @@ -986,6 +987,15 @@ surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel) // cache = CACHESPOT(surface)[miplevel]; + // check for lightmap modification + for( maps = 0; maps < MAXLIGHTMAPS && surface->styles[maps] != 255; maps++ ) + { + if( tr.lightstylevalue[surface->styles[maps]] != surface->cached_light[maps] ) + { + surface->dlightframe = r_framecount; + } + } + if (cache && !cache->dlight && surface->dlightframe != r_framecount && cache->image == r_drawsurf.image @@ -1028,7 +1038,10 @@ surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel) cache->lightadj[1] = r_drawsurf.lightadj[1]; cache->lightadj[2] = r_drawsurf.lightadj[2]; cache->lightadj[3] = r_drawsurf.lightadj[3]; - + for( maps = 0; maps < MAXLIGHTMAPS && surface->styles[maps] != 255; maps++ ) + { + surface->cached_light[maps] = tr.lightstylevalue[surface->styles[maps]]; + } // // draw and light the surface texture //