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 <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-03-10 20:21:26 +10:30
parent e8d640f88f
commit 359ddfa41e
5 changed files with 42 additions and 136 deletions

View File

@ -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

View File

@ -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__ */

View File

@ -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"

View File

@ -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);
}

View File

@ -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;
}
}
}