Added "_falloff" light property. Allows to set light falloff in map units.

This commit is contained in:
MaxED 2017-08-09 13:52:10 +03:00 committed by Eric Wasylishen
parent 13ca8bfe68
commit fe1e040cd1
5 changed files with 195 additions and 0 deletions

View File

@ -76,6 +76,7 @@ public:
lockable_vec_t dirtscale, dirtgain, dirt, deviance, samples, projfov, bouncescale; lockable_vec_t dirtscale, dirtgain, dirt, deviance, samples, projfov, bouncescale;
lockable_vec_t dirt_off_radius, dirt_on_radius; lockable_vec_t dirt_off_radius, dirt_on_radius;
lockable_vec_t sun; //mxd lockable_vec_t sun; //mxd
lockable_vec_t falloff; //mxd
lockable_bool_t bleed; lockable_bool_t bleed;
lockable_vec3_t origin, color, mangle, projangle; lockable_vec3_t origin, color, mangle, projangle;
lockable_string_t project_texture; lockable_string_t project_texture;
@ -113,6 +114,7 @@ public:
dirt_off_radius { "dirt_off_radius", 0.0f }, dirt_off_radius { "dirt_off_radius", 0.0f },
dirt_on_radius { "dirt_on_radius", 0.0f }, dirt_on_radius { "dirt_on_radius", 0.0f },
sun { "sun", 0 }, //mxd sun { "sun", 0 }, //mxd
falloff{ "falloff", 0.0f }, //mxd
bleed { "bleed", false }, bleed { "bleed", false },
origin { "origin", 0, 0, 0 }, origin { "origin", 0, 0, 0 },
color { "color", 255.0f, 255.0f, 255.0f, vec3_transformer_t::NORMALIZE_COLOR_TO_255 }, color { "color", 255.0f, 255.0f, 255.0f, vec3_transformer_t::NORMALIZE_COLOR_TO_255 },
@ -133,6 +135,7 @@ public:
&dirtscale, &dirtgain, &dirt, &deviance, &samples, &projfov, &bouncescale, &dirtscale, &dirtgain, &dirt, &deviance, &samples, &projfov, &bouncescale,
&dirt_off_radius, &dirt_on_radius, &dirt_off_radius, &dirt_on_radius,
&sun, //mxd &sun, //mxd
&falloff, //mxd
&origin, &color, &mangle, &projangle, &project_texture &origin, &color, &mangle, &projangle, &project_texture
}}; }};
} }

View File

@ -329,6 +329,10 @@ CheckEntityFields(const globalconfig_t &cfg, light_t *entity)
if (entity->anglescale.floatValue() < 0 || entity->anglescale.floatValue() > 1.0) if (entity->anglescale.floatValue() < 0 || entity->anglescale.floatValue() > 1.0)
entity->anglescale.setFloatValue(cfg.global_anglescale.floatValue()); entity->anglescale.setFloatValue(cfg.global_anglescale.floatValue());
//mxd. No negative falloffs pls.
if(entity->falloff.floatValue() < 0.0f)
entity->falloff.setFloatValue(0.0f);
if (entity->getFormula() < LF_LINEAR || entity->getFormula() >= LF_COUNT) { if (entity->getFormula() < LF_LINEAR || entity->getFormula() >= LF_COUNT) {
static qboolean warned_once = true; static qboolean warned_once = true;
if (!warned_once) { if (!warned_once) {

View File

@ -865,10 +865,29 @@ GetLightValue(const globalconfig_t &cfg, const light_t *entity, vec_t dist)
const float light = entity->light.floatValue(); const float light = entity->light.floatValue();
vec_t value; vec_t value;
//mxd. Apply falloff?
const float lightdistance = entity->falloff.floatValue();
if (lightdistance > 0.0f) {
if (entity->getFormula() != LF_LINEAR) {
logprint("WARNING: _falloff is currently only supported on linear (delay 0): light at (%f %f %f)\n",
(*entity->origin.vec3Value())[0],
(*entity->origin.vec3Value())[1],
(*entity->origin.vec3Value())[2]);
// ignore _falloff key
} else {
// Light can affect surface?
if (lightdistance > dist)
return light * (1.0f - (dist / lightdistance));
else
return 0.0f; // Surface is unaffected
}
}
if (entity->getFormula() == LF_INFINITE || entity->getFormula() == LF_LOCALMIN) if (entity->getFormula() == LF_INFINITE || entity->getFormula() == LF_LOCALMIN)
return light; return light;
value = cfg.scaledist.floatValue() * entity->atten.floatValue() * dist; value = cfg.scaledist.floatValue() * entity->atten.floatValue() * dist;
switch (entity->getFormula()) { switch (entity->getFormula()) {
case LF_INVERSE: case LF_INVERSE:
return light / (value / LF_SCALE); return light / (value / LF_SCALE);

View File

@ -296,6 +296,14 @@ Select an attenuation formaula for the light:
near the source. near the source.
.fi .fi
.IP "\fB""_falloff"" ""n""\fP"
Sets the distance at which the light drops to 0, in map units.
In this mode, "wait" is ignored and "light" only controls the brightness at the center
of the light, and no longer affects the falloff distance.
Only supported on linear attenuation (delay 0) lights currently.
.IP "\fB""_color"" ""r g b""\fP" .IP "\fB""_color"" ""r g b""\fP"
Specify red(r), green(g) and blue(b) components for the colour of the Specify red(r), green(g) and blue(b) components for the colour of the
light. RGB component values are between 0 and 255 (between 0 and 1 is also light. RGB component values are between 0 and 255 (between 0 and 1 is also

161
testmaps/falloff.map Normal file
View File

@ -0,0 +1,161 @@
// Game: Quake
// Format: Standard
// entity 0
{
"classname" "worldspawn"
"wad" "free_wad.wad"
"_sunlight" "100"
"_sun_mangle" "0 -45 0"
// brush 0
{
( -192 128 240 ) ( -192 129 240 ) ( -192 128 241 ) brownwirewall -0 64 -0 1 1
( 896 256 272 ) ( 896 256 273 ) ( 896 257 272 ) brownwirewall -0 64 -0 1 1
( -64 -192 240 ) ( -64 -192 241 ) ( -63 -192 240 ) brownwirewall -0 64 -0 1 1
( 64 992 272 ) ( 65 992 272 ) ( 64 992 273 ) brownwirewall -0 64 -0 1 1
( 64 256 288 ) ( 64 257 288 ) ( 65 256 288 ) brownwirewall -0 64 -0 1 1
( -64 128 240 ) ( -63 128 240 ) ( -64 129 240 ) brownwirewall -0 64 -0 1 1
}
// brush 1
{
( -192 96 208 ) ( -192 97 208 ) ( -192 96 209 ) brownwirewall -0 64 -0 1 1
( -160 224 240 ) ( -160 224 241 ) ( -160 225 240 ) brownwirewall -0 64 -0 1 1
( -64 -160 208 ) ( -64 -160 209 ) ( -63 -160 208 ) brownwirewall -0 64 -0 1 1
( 64 960 240 ) ( 65 960 240 ) ( 64 960 241 ) brownwirewall -0 64 -0 1 1
( 64 224 240 ) ( 64 225 240 ) ( 65 224 240 ) brownwirewall -0 64 -0 1 1
( -64 96 -480 ) ( -63 96 -480 ) ( -64 97 -480 ) brownwirewall -0 64 -0 1 1
}
// brush 2
{
( -192 128 208 ) ( -192 129 208 ) ( -192 128 209 ) brownwirewall -0 64 -0 1 1
( 896 256 240 ) ( 896 256 241 ) ( 896 257 240 ) brownwirewall -0 64 -0 1 1
( -64 960 208 ) ( -64 960 209 ) ( -63 960 208 ) brownwirewall -0 64 -0 1 1
( 64 992 240 ) ( 65 992 240 ) ( 64 992 241 ) brownwirewall -0 64 -0 1 1
( 64 256 240 ) ( 64 257 240 ) ( 65 256 240 ) brownwirewall -0 64 -0 1 1
( -64 128 -480 ) ( -63 128 -480 ) ( -64 129 -480 ) brownwirewall -0 64 -0 1 1
}
// brush 3
{
( -192 128 208 ) ( -192 129 208 ) ( -192 128 209 ) brownwirewall -0 64 -0 1 1
( 896 256 240 ) ( 896 256 241 ) ( 896 257 240 ) brownwirewall -0 64 -0 1 1
( -64 -192 208 ) ( -64 -192 209 ) ( -63 -192 208 ) brownwirewall -0 64 -0 1 1
( 64 -160 240 ) ( 65 -160 240 ) ( 64 -160 241 ) brownwirewall -0 64 -0 1 1
( 64 256 240 ) ( 64 257 240 ) ( 65 256 240 ) brownwirewall -0 64 -0 1 1
( -64 128 -480 ) ( -63 128 -480 ) ( -64 129 -480 ) brownwirewall -0 64 -0 1 1
}
// brush 4
{
( 864 96 208 ) ( 864 97 208 ) ( 864 96 209 ) brownwirewall -0 64 -0 1 1
( 896 224 240 ) ( 896 224 241 ) ( 896 225 240 ) brownwirewall -0 64 -0 1 1
( 992 -160 208 ) ( 992 -160 209 ) ( 993 -160 208 ) brownwirewall -0 64 -0 1 1
( 1120 960 240 ) ( 1121 960 240 ) ( 1120 960 241 ) brownwirewall -0 64 -0 1 1
( 1120 224 240 ) ( 1120 225 240 ) ( 1121 224 240 ) brownwirewall -0 64 -0 1 1
( 992 96 -480 ) ( 993 96 -480 ) ( 992 97 -480 ) brownwirewall -0 64 -0 1 1
}
// brush 5
{
( -192 128 -528 ) ( -192 129 -528 ) ( -192 128 -527 ) brownwirewall -192 -0 -0 1 1
( 896 256 -496 ) ( 896 256 -495 ) ( 896 257 -496 ) brownwirewall -192 -0 -0 1 1
( -64 -192 -528 ) ( -64 -192 -527 ) ( -63 -192 -528 ) brownwirewall -0 -0 -0 1 1
( 64 992 -496 ) ( 65 992 -496 ) ( 64 992 -495 ) brownwirewall -0 -0 -0 1 1
( 64 256 -480 ) ( 64 257 -480 ) ( 65 256 -480 ) brownwirewall -0 64 -0 1 1
( -64 128 -528 ) ( -63 128 -528 ) ( -64 129 -528 ) brownwirewall -0 64 -0 1 1
}
// brush 6
{
( 792 696 -480 ) ( 856 696 -448 ) ( 856 696 -480 ) brownwirewall -88 -0 -0 1 1
( 728 576 -480 ) ( 728 704 -448 ) ( 728 576 -448 ) brownwirewall -0 -0 -0 1 1
( 792 576 -480 ) ( 856 704 -480 ) ( 792 704 -480 ) brownwirewall -88 -0 -0 1 1
( 792 576 -320 ) ( 856 704 -320 ) ( 856 576 -320 ) brownwirewall -88 -0 -0 1 1
( 792 704 -480 ) ( 856 704 -448 ) ( 792 704 -448 ) brownwirewall -88 -0 -0 1 1
( 856 576 -480 ) ( 856 704 -448 ) ( 856 704 -480 ) brownwirewall -0 -0 -0 1 1
}
// brush 7
{
( 792 440 -480 ) ( 856 440 -448 ) ( 856 440 -480 ) brownwirewall -88 -0 -0 1 1
( 728 320 -480 ) ( 728 448 -448 ) ( 728 320 -448 ) brownwirewall -0 -0 -0 1 1
( 792 320 -480 ) ( 856 448 -480 ) ( 792 448 -480 ) brownwirewall -88 -0 -0 1 1
( 792 320 -320 ) ( 856 448 -320 ) ( 856 320 -320 ) brownwirewall -88 -0 -0 1 1
( 792 448 -480 ) ( 856 448 -448 ) ( 792 448 -448 ) brownwirewall -88 -0 -0 1 1
( 856 320 -480 ) ( 856 448 -448 ) ( 856 448 -480 ) brownwirewall -0 -0 -0 1 1
}
// brush 8
{
( 792 184 -480 ) ( 856 184 -448 ) ( 856 184 -480 ) brownwirewall -88 -0 -0 1 1
( 728 64 -480 ) ( 728 192 -448 ) ( 728 64 -448 ) brownwirewall -0 -0 -0 1 1
( 792 64 -480 ) ( 856 192 -480 ) ( 792 192 -480 ) brownwirewall -88 -0 -0 1 1
( 792 64 -320 ) ( 856 192 -320 ) ( 856 64 -320 ) brownwirewall -88 -0 -0 1 1
( 792 192 -480 ) ( 856 192 -448 ) ( 792 192 -448 ) brownwirewall -88 -0 -0 1 1
( 856 64 -480 ) ( 856 192 -448 ) ( 856 192 -480 ) brownwirewall -0 -0 -0 1 1
}
}
// entity 1
{
"classname" "info_player_start"
"origin" "144 560 -456"
"angle" "-0"
}
// entity 2
{
"classname" "light"
"origin" "792 832 -472"
"angle" "-0"
"_falloff" "128"
}
// entity 3
{
"classname" "light"
"origin" "792 576 -472"
"angle" "-0"
"_falloff" "128"
"light" "50"
}
// entity 4
{
"classname" "light"
"origin" "792 320 -472"
"angle" "-0"
"_falloff" "128"
"light" "1000"
}
// entity 5
{
"classname" "trigger_multiple"
"message" "falloff 128, default light"
// brush 0
{
( 704 736 -480 ) ( 736 736 -448 ) ( 736 736 -480 ) trigger 0 0 0 1 1
( 704 736 -480 ) ( 704 928 -448 ) ( 704 736 -448 ) trigger 0 0 0 1 1
( 704 736 -480 ) ( 736 928 -480 ) ( 704 928 -480 ) trigger 0 0 0 1 1
( 704 736 -448 ) ( 736 928 -448 ) ( 736 736 -448 ) trigger 0 0 0 1 1
( 704 928 -480 ) ( 736 928 -448 ) ( 704 928 -448 ) trigger 0 0 0 1 1
( 736 736 -480 ) ( 736 928 -448 ) ( 736 928 -480 ) trigger 0 0 0 1 1
}
}
// entity 6
{
"classname" "trigger_multiple"
"message" "falloff 128, light 50"
// brush 0
{
( 704 480 -480 ) ( 736 480 -448 ) ( 736 480 -480 ) trigger -0 -0 -0 1 1
( 704 480 -480 ) ( 704 672 -448 ) ( 704 480 -448 ) trigger -0 -0 -0 1 1
( 704 480 -480 ) ( 736 672 -480 ) ( 704 672 -480 ) trigger -0 -0 -0 1 1
( 704 480 -448 ) ( 736 672 -448 ) ( 736 480 -448 ) trigger -0 -0 -0 1 1
( 704 672 -480 ) ( 736 672 -448 ) ( 704 672 -448 ) trigger -0 -0 -0 1 1
( 736 480 -480 ) ( 736 672 -448 ) ( 736 672 -480 ) trigger -0 -0 -0 1 1
}
}
// entity 7
{
"classname" "trigger_multiple"
"message" "falloff 128, light 1000"
// brush 0
{
( 704 224 -480 ) ( 736 224 -448 ) ( 736 224 -480 ) trigger -0 -0 -0 1 1
( 704 224 -480 ) ( 704 416 -448 ) ( 704 224 -448 ) trigger -0 -0 -0 1 1
( 704 224 -480 ) ( 736 416 -480 ) ( 704 416 -480 ) trigger -0 -0 -0 1 1
( 704 224 -448 ) ( 736 416 -448 ) ( 736 224 -448 ) trigger -0 -0 -0 1 1
( 704 416 -480 ) ( 736 416 -448 ) ( 704 416 -448 ) trigger -0 -0 -0 1 1
( 736 224 -480 ) ( 736 416 -448 ) ( 736 416 -480 ) trigger -0 -0 -0 1 1
}
}