From c5bfadcf1ad79d155d89f95b56405548f834a559 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 28 Aug 2021 13:44:15 +0200 Subject: [PATCH] vmap: Added vmap_lightLinear, added vmap_lightLinearFade, plus light_surface can now check for spawnflags 1 and has a valid 'fade' key value. --- tools/vmap/light.c | 27 ++++++++++++++++++++++++--- tools/vmap/shaders.c | 11 +++++++++++ tools/vmap/vmap.h | 2 ++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/tools/vmap/light.c b/tools/vmap/light.c index bb3d1e4..0c5c2de 100644 --- a/tools/vmap/light.c +++ b/tools/vmap/light.c @@ -400,9 +400,11 @@ void CreateEntityLights( void ){ si = info->si; float lb; + float llfade; int subd; int style; float bscale, bsfrac, bsdist; + int sflags; if (!stristr(si->shader, surfacename)) continue; @@ -413,13 +415,15 @@ void CreateEntityLights( void ){ * the rest is always dummy values which are meaningless. */ sscanf( _light_brightness, "%*f %*f %*f %f", &lb ); - } - else { + } else { lb = FloatForKey( e, "light" ); } + + sflags = IntForKey( e, "spawnflags" ); subd = IntForKey( e, "subdivisions" ); style = IntForKey( e, "style" ); bscale = FloatForKey( e, "bouncescale" ); + llfade = FloatForKey( e, "fade" ); /* 0.05 is a default */ bsfrac = FloatForKey( e, "backsplash_fraction" ) * 0.01f; @@ -430,6 +434,10 @@ void CreateEntityLights( void ){ /* only apply when things are set. */ if (lb) si->value = lb; + if (sflags & 1) + si->lightLinear = qtrue; + if (llfade) + si->lightLinearFade = llfade; if (subd) si->lightSubdivide = subd; if (style) @@ -859,9 +867,22 @@ void CreateSurfaceLights( void ){ /* set it up */ light->flags = LIGHT_Q3A_DEFAULT; + + /* vmap_lightLinear */ + if (si->lightLinear == qtrue) { + light->flags &= ~LIGHT_ATTEN_ANGLE; + light->flags |= LIGHT_ATTEN_LINEAR; + } + light->type = EMIT_POINT; light->photons = si->value * pointScale; - light->fade = 1.0f; + + /* vmap_lightLinearFade */ + light->fade = si->lightLinearFade; + + if (light->fade == 0.0f) + light->fade = 1.0f; + light->si = si; VectorCopy( origin, light->origin ); VectorCopy( si->color, light->color ); diff --git a/tools/vmap/shaders.c b/tools/vmap/shaders.c index c0367ff..90cd8cc 100644 --- a/tools/vmap/shaders.c +++ b/tools/vmap/shaders.c @@ -1406,6 +1406,17 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ){ si->lightSubdivide = atoi( mattoken ); } + /* vmap_lightLinear */ + else if ( !Q_stricmp( mattoken, "vmap_lightLinear" ) ) { + si->lightLinear = qtrue; + } + + /* vmap_lightLinearFade multiplier */ + else if ( !Q_stricmp( mattoken, "vmap_lightLinearFade" ) ) { + GetMatTokenAppend( shaderText, qfalse ); + si->lightLinearFade = atof( mattoken ); + } + /* q3map_backsplash */ else if ( !Q_stricmp( mattoken, "q3map_backsplash" ) || !Q_stricmp( mattoken, "vmap_backsplash" ) ) { GetMatTokenAppend( shaderText, qfalse ); diff --git a/tools/vmap/vmap.h b/tools/vmap/vmap.h index bb87ccb..507d4fd 100644 --- a/tools/vmap/vmap.h +++ b/tools/vmap/vmap.h @@ -693,6 +693,8 @@ typedef struct shaderInfo_s float backsplashDistance; /* default 16 */ float lightSubdivide; /* default 999 */ float lightFilterRadius; /* ydnar: lightmap filtering/blurring radius for lights created by this shader (default: 0) */ + qb_t lightLinear; /* vmap addition */ + float lightLinearFade; /* vmap addition */ int lightmapSampleSize; /* lightmap sample size */ float lightmapSampleOffset; /* ydnar: lightmap sample offset (default: 1.0) */