From 359ddfa41e5464ea0a221f48413d3a1c24326046 Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Sun, 10 Mar 2013 20:21:26 +1030 Subject: [PATCH] light: remove nominlimit option and negative color value support "nominlimit" is a more sensible default - people expect negative lights to be able to subtract from minlight. The negative colors never really worked properly and there's not really any worthwhile use for the (that I know of). Hopefully nobody will be too upset by these two changes to the old behaviour. Signed-off-by: Kevin Shanahan --- changelog.txt | 2 + include/light/light.h | 3 - light.txt | 14 ++-- light/light.c | 5 +- light/ltface.c | 154 ++++++++++-------------------------------- 5 files changed, 42 insertions(+), 136 deletions(-) diff --git a/changelog.txt b/changelog.txt index 37271139..61c7f017 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,8 @@ Unreleased * light: implemented self shadowing and full shadows for brush models +* light: removed the "-nominlimit" option (now the default behaviour) +* light: remove support for negative color components (never worked properly) 2013-03-07 TyrUtils v0.6 diff --git a/include/light/light.h b/include/light/light.h index 67cdc70f..ea92aa9f 100644 --- a/include/light/light.h +++ b/include/light/light.h @@ -75,10 +75,7 @@ extern byte *lit_filebase; extern int oversample; extern qboolean compress_ents; -extern qboolean facecounter; extern qboolean colored; -extern qboolean bsp30; extern qboolean litfile; -extern qboolean nominlimit; #endif /* __LIGHT_LIGHT_H__ */ diff --git a/light.txt b/light.txt index 067a7bfd..dae76287 100644 --- a/light.txt +++ b/light.txt @@ -23,9 +23,6 @@ OPTIONS -light n Set a global minimum light level. Overrides default light level set in worldspawn. - -nominlimit Allow negative lights to reduce surface lighting below - the global minumum light level. - -dist n Scales the fade distance of all lights by a factor of n. If n > 1 lights fade more quickly with distance and if n < 1, lights fade more slowly with distance and light @@ -61,7 +58,7 @@ ENTITY PARAMETERS Set a global minimum light level of "n" across the whole map. This is an easy way to eliminate completely dark areas of the level, however - you may lose some contrast as a result, so use with care. + you may lose some contrast as a result, so use with care. Default 0. "_sunlight" "n" @@ -81,9 +78,8 @@ ENTITY PARAMETERS "_sunlight_color" "r g b" Specify red(r), green(g) and blue(b) components for the colour of the - sunlight. RGB component values are between -255 and 255. Negative - values will cause colour subtraction from light cast by other entities. - Default is white light ("255 255 255"). + sunlight. RGB component values are between 0 and 255. Default is white + light ("255 255 255"). MODEL PARAMETERS @@ -147,8 +143,8 @@ ENTITY PARAMETERS "_color" "r g b" Specify red(r), green(g) and blue(b) components for the colour of the - light. RGB component values are between -255 and 255. Negative values - will cause colour subtraction from light cast by other entities. + light. RGB component values are between 0 and 255. Default is white + light ("255 255 255"). "target" "name" diff --git a/light/light.c b/light/light.c index 968adcb3..54abcd6b 100644 --- a/light/light.c +++ b/light/light.c @@ -45,7 +45,6 @@ const dmodel_t *const *tracelist; int oversample = 1; qboolean compress_ents; qboolean colored; -qboolean nominlimit; void GetFileSpace(byte **lightdata, byte **colordata, int size) @@ -253,8 +252,6 @@ main(int argc, const char **argv) logprint("light entity compression enabled\n"); } else if (!strcmp(argv[i], "-lit")) { colored = true; - } else if (!strcmp(argv[i], "-nominlimit")) { - nominlimit = true; } else if (argv[i][0] == '-') Error("Unknown option \"%s\"", argv[i]); else @@ -264,7 +261,7 @@ main(int argc, const char **argv) if (i != argc - 1) { printf("usage: light [-threads num] [-light num] [-extra|-extra4]\n" " [-dist n] [-range n] [-gate n] [-lit] " - " [-compress] [-nominlimit] bspfile\n"); + " [-compress] bspfile\n"); exit(1); } diff --git a/light/ltface.c b/light/ltface.c index b63527a9..1a04e1e6 100644 --- a/light/ltface.c +++ b/light/ltface.c @@ -740,67 +740,6 @@ FixMinlight(const lightsample_t *minlight, const lightsurf_t *lightsurf, } } - -/* - * PositiveLight zeros negative light components. - * NegativeLight zeros positive light components. - */ -static qboolean -PositiveLight(int light, const vec3_t color, lightsample_t *out) -{ - int i; - qboolean positive = false; - - if (light > 0) { - out->light = light; - positive = true; - for (i = 0; i < 3; i++) - if (color[i] > 0) - out->color[i] = color[i]; - else - out->color[i] = 0; - } else if (light < 0) { - out->light = -light; - for (i = 0; i < 3; i++) - if (color[i] < 0) { - out->color[i] = -color[i]; - positive = true; - } else { - out->color[i] = 0; - } - } - - return positive; -} - -static qboolean -NegativeLight(int light, const vec3_t color, lightsample_t *out) -{ - int i; - qboolean negative = false; - - if (light < 0) { - out->light = light; - negative = true; - for (i = 0; i < 3; i++) - if (color[i] > 0) - out->color[i] = color[i]; - else - out->color[i] = 0; - } else if (light > 0) { - out->light = -light; - for (i = 0; i < 3; i++) - if (color[i] < 0) { - out->color[i] = -color[i]; - negative = true; - } else { - out->color[i] = 0; - } - } - - return negative; -} - static void WriteLightmaps(dface_t *face, const lightsurf_t *lightsurf, const lightmap_t *lightmaps) @@ -886,7 +825,6 @@ void LightFace(dface_t *face, const modelinfo_t *modelinfo) { int i, j, k; - lightsample_t light; const entity_t *entity; lightsample_t *sample; lightsurf_t lightsurf; @@ -902,74 +840,50 @@ LightFace(dface_t *face, const modelinfo_t *modelinfo) Lightsurf_Init(modelinfo, face, &lightsurf); Lightmaps_Init(lightmaps); - /* Under normal circumstances, the lighting procedure is: - * - cast all light entities - * - cast sky lighting - * - do minlighting. - * - * However, if nominlimit is enabled then we need to do the following: - * - cast _positive_ lights - * - cast _positive_ skylight (if any) - * - do minlighting - * - cast _negative_ lights - * - cast _negative_ sky light (if any) + /* + * The lighting procedure is: cast all positive lights, fix + * minlight levels, then cast all negative lights. Finally, we + * clamp any values that may have gone negative. */ - if (nominlimit) { - /* cast only positive lights */ - for (i = 0, entity = entities; i < num_entities; i++, entity++) { - if (entity->formula == LF_LOCALMIN) - continue; - if (PositiveLight(entity->light.light, entity->light.color, &light)) - SingleLightFace(entity, &light, &lightsurf, lightmaps); - } - /* cast positive sky light */ - if (PositiveLight(sunlight.light, sunlight.color, &light)) - SkyLightFace(&light, &lightsurf, lightmaps); - } else { - /* (!nominlimit) => cast all lights */ - for (i = 0, entity = entities; i < num_entities; i++, entity++) { - if (entity->formula == LF_LOCALMIN) - continue; - if (entity->light.light) - SingleLightFace(entity, &entity->light, &lightsurf, lightmaps); - } - /* cast sky light */ - if (sunlight.light) - SkyLightFace(&sunlight, &lightsurf, lightmaps); + /* positive lights */ + for (i = 0, entity = entities; i < num_entities; i++, entity++) { + if (entity->formula == LF_LOCALMIN) + continue; + if (entity->light.light > 0) + SingleLightFace(entity, &entity->light, &lightsurf, lightmaps); } + if (sunlight.light > 0) + SkyLightFace(&sunlight, &lightsurf, lightmaps); - /* Minimum lighting - Use the greater of global or model minlight. */ + /* minlight - Use the greater of global or model minlight. */ if (modelinfo->minlight.light > minlight.light) FixMinlight(&modelinfo->minlight, &lightsurf, lightmaps); else FixMinlight(&minlight, &lightsurf, lightmaps); - if (nominlimit) { - /* cast only negative lights */ - for (i = 0, entity = entities; i < num_entities; i++, entity++) { - if (entity->formula == LF_LOCALMIN) - continue; - if (NegativeLight(entity->light.light, entity->light.color, &light)) - SingleLightFace(entity, &light, &lightsurf, lightmaps); - } - /* cast negative sky light */ - if (NegativeLight(sunlight.light, sunlight.color, &light)) - SkyLightFace(&light, &lightsurf, lightmaps); + /* negative lights */ + for (i = 0, entity = entities; i < num_entities; i++, entity++) { + if (entity->formula == LF_LOCALMIN) + continue; + if (entity->light.light < 0) + SingleLightFace(entity, &entity->light, &lightsurf, lightmaps); + } + if (sunlight.light < 0) + SkyLightFace(&sunlight, &lightsurf, lightmaps); - /* Fix any negative values */ - for (i = 0; i < MAXLIGHTMAPS; i++) { - if (lightmaps[i].style == 255) - break; - sample = lightmaps[i].samples; - for (j = 0; j < lightsurf.numpoints; j++, sample++) { - if (sample->light < 0) - sample->light = 0; - if (colored) { - for (k = 0; k < 3; k++) { - if (sample->color[k] < 0) { - sample->color[k] = 0; - } + /* Fix any negative values */ + for (i = 0; i < MAXLIGHTMAPS; i++) { + if (lightmaps[i].style == 255) + break; + sample = lightmaps[i].samples; + for (j = 0; j < lightsurf.numpoints; j++, sample++) { + if (sample->light < 0) + sample->light = 0; + if (colored) { + for (k = 0; k < 3; k++) { + if (sample->color[k] < 0) { + sample->color[k] = 0; } } }