From eb842ba165d4034ab93ebc1bcf0435bdcb2acdc9 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Tue, 29 Dec 2020 13:43:06 -0700 Subject: [PATCH] light: arghrad compat: preliminary sky_surface implementation --- include/light/light.hh | 7 +++++-- light/surflight.cc | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/light/light.hh b/include/light/light.hh index d2c6bddb..5d74376d 100644 --- a/include/light/light.hh +++ b/include/light/light.hh @@ -307,6 +307,7 @@ public: lockable_vec3_t sunvec; lockable_vec3_t sun2vec; lockable_vec_t sun_deviance; + lockable_vec3_t sky_surface; globalconfig_t() : scaledist {"dist", 1.0, 0.0f, 100.0f}, @@ -358,7 +359,8 @@ public: sunlight2_dirt { "sunlight2_dirt", 0.0f }, sunvec { strings{"sunlight_mangle", "sun_mangle", "sun_angle"}, 0.0f, -90.0f, 0.0f, vec3_transformer_t::MANGLE_TO_VEC }, /* defaults to straight down */ sun2vec { "sun2_mangle", 0.0f, -90.0f, 0.0f, vec3_transformer_t::MANGLE_TO_VEC }, /* defaults to straight down */ - sun_deviance { "sunlight_penumbra", 0.0f, 0.0f, 180.0f } + sun_deviance { "sunlight_penumbra", 0.0f, 0.0f, 180.0f }, + sky_surface { strings{"sky_surface", "sun_surface"}, 0, 0, 0} /* arghrad surface lights on sky faces */ {} settingsdict_t settings() { @@ -387,7 +389,8 @@ public: &sunlight2_dirt, &sunvec, &sun2vec, - &sun_deviance + &sun_deviance, + &sky_surface }}; } }; diff --git a/light/surflight.cc b/light/surflight.cc index f222d199..ca5dba6d 100644 --- a/light/surflight.cc +++ b/light/surflight.cc @@ -126,6 +126,14 @@ MakeSurfaceLightsThread(void *arg) VectorScale(texturecolor, 1.0f / 255.0f, texturecolor); // Convert to 0..1 range... VectorScale(texturecolor, info->value, texturecolor); // Scale by light value + // Handle arghrad sky light settings http://www.bspquakeeditor.com/arghrad/sunlight.html#sky + if (info->flags & Q2_SURF_SKY) { + // FIXME: this only handles the "_sky_surface" "red green blue" format. + // There are other more complex variants we could handle documented in the link above. + // FIXME: we require value to be nonzero, see the check above - not sure if this matches arghrad + VectorCopy(*cfg.sky_surface.vec3Value(), texturecolor); + } + // Calculate intensity... float intensity = 0.0f; for (float c : texturecolor)