light: arghrad compat: preliminary sky_surface implementation

This commit is contained in:
Eric Wasylishen 2020-12-29 13:43:06 -07:00
parent bb4d6fdea9
commit eb842ba165
2 changed files with 13 additions and 2 deletions

View File

@ -307,6 +307,7 @@ public:
lockable_vec3_t sunvec; lockable_vec3_t sunvec;
lockable_vec3_t sun2vec; lockable_vec3_t sun2vec;
lockable_vec_t sun_deviance; lockable_vec_t sun_deviance;
lockable_vec3_t sky_surface;
globalconfig_t() : globalconfig_t() :
scaledist {"dist", 1.0, 0.0f, 100.0f}, scaledist {"dist", 1.0, 0.0f, 100.0f},
@ -358,7 +359,8 @@ public:
sunlight2_dirt { "sunlight2_dirt", 0.0f }, 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 */ 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 */ 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() { settingsdict_t settings() {
@ -387,7 +389,8 @@ public:
&sunlight2_dirt, &sunlight2_dirt,
&sunvec, &sunvec,
&sun2vec, &sun2vec,
&sun_deviance &sun_deviance,
&sky_surface
}}; }};
} }
}; };

View File

@ -126,6 +126,14 @@ MakeSurfaceLightsThread(void *arg)
VectorScale(texturecolor, 1.0f / 255.0f, texturecolor); // Convert to 0..1 range... VectorScale(texturecolor, 1.0f / 255.0f, texturecolor); // Convert to 0..1 range...
VectorScale(texturecolor, info->value, texturecolor); // Scale by light value 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... // Calculate intensity...
float intensity = 0.0f; float intensity = 0.0f;
for (float c : texturecolor) for (float c : texturecolor)