light: implement the -addmin command line parameter

Makes minlight additive rather than just bringing low levels up to the
minimum.  Not entirely identical to the bjp implementation as it seems to
treat local minlights in some strange ways, but in most cases the
behaviour should be identical.

Added missing help text for -anglescale|-anglesense parameters too.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-04-04 15:51:18 +10:30
parent 4021c06852
commit 4625245b09
5 changed files with 30 additions and 9 deletions

View File

@ -9,6 +9,7 @@ Unreleased
* qbsp: added hintskip texture support
* light: implemented self shadowing and full shadows for brush models
* light: implemented the "-soft" command line option
* light: implemented the "-addmin" command line option
* light: implemented the "_anglescale" (aka "_anglesense") key and cmdline
* light: remove support for negative color components (never worked properly)
* light: removed the "-nominlimit" option (now the default behaviour)

View File

@ -101,6 +101,7 @@ extern float fadegate;
extern int softsamples;
extern const vec3_t vec3_white;
extern qboolean addminlight;
extern lightsample_t minlight;
extern lightsample_t sunlight;
extern vec3_t sunvec;

View File

@ -30,6 +30,7 @@ float fadegate = EQUAL_EPSILON;
int softsamples = 0;
const vec3_t vec3_white = { 255, 255, 255 };
qboolean addminlight = false;
lightsample_t minlight = { 0, { 255, 255, 255 } };
lightsample_t sunlight = { 0, { 255, 255, 255 } };
vec3_t sunvec = { 0, 0, 16384 }; /* defaults to straight down */
@ -244,6 +245,8 @@ main(int argc, const char **argv)
fadegate = atof(argv[++i]);
} else if (!strcmp(argv[i], "-light")) {
minlight.light = atof(argv[++i]);
} else if (!strcmp(argv[i], "-addmin")) {
addminlight = true;
} else if (!strcmp(argv[i], "-lit")) {
colored = true;
} else if (!strcmp(argv[i], "-soft")) {
@ -263,7 +266,8 @@ main(int argc, const char **argv)
}
if (i != argc - 1) {
printf("usage: light [-threads num] [-light num] [-extra|-extra4]\n"
printf("usage: light [-threads num] [-extra|-extra4]\n"
" [-light num] [-addmin] [-anglescale|-anglesense]\n"
" [-dist n] [-range n] [-gate n] [-lit]\n"
" [-soft [n]] bspfile\n");
exit(1);

View File

@ -748,12 +748,16 @@ FixMinlight(const lightsample_t *minlight, const lightsurf_t *lightsurf,
sample = lightmaps[mapnum].samples;
for (i = 0; i < lightsurf->numpoints; i++, sample++) {
if (sample->light < minlight->light)
if (addminlight)
sample->light += minlight->light;
else if (sample->light < minlight->light)
sample->light = minlight->light;
if (colored) {
for (j = 0; j < 3; j++) {
vec_t lightval = minlight->light * minlight->color[j] / 255.0f;
if (sample->color[j] < lightval)
if (addminlight)
sample->color[j] += lightval;
else if (sample->color[j] < lightval)
sample->color[j] = lightval;
}
}
@ -769,22 +773,28 @@ FixMinlight(const lightsample_t *minlight, const lightsurf_t *lightsurf,
surfpoint = lightsurf->points[0];
for (j = 0; j < lightsurf->numpoints; j++, sample++, surfpoint += 3) {
qboolean trace = false;
if (sample->light < entity->light.light) {
if (addminlight || sample->light < entity->light.light) {
trace = TestLight(entity->origin, surfpoint, shadowself);
if (!trace)
continue;
sample->light = entity->light.light;
if (addminlight)
sample->light += entity->light.light;
else
sample->light = entity->light.light;
}
if (!colored)
continue;
for (k = 0; k < 3; k++) {
if (sample->color[k] < entity->light.color[k]) {
if (addminlight || sample->color[k] < entity->light.color[k]) {
if (!trace) {
trace = TestLight(entity->origin, surfpoint, shadowself);
if (!trace)
break;
}
sample->color[k] = entity->light.color[k];
if (addminlight)
sample->color[k] += entity->light.color[k];
else
sample->color[k] = entity->light.color[k];
}
}
}

View File

@ -25,8 +25,13 @@ Calculate extra samples (2x2) and average the results for smoother shadows.
Calculate even more samples (4x4) and average the results for smoother
shadows.
.IP "\fB\-light n\fP"
Set a global minimum light level. Overrides default light level set in
worldspawn.
Set a global minimum light level for style 0 (default)
lightmaps. Overrides default light level set in worldspawn.
.IP "\fB\-addmin\fP"
Changes the behaviour of \fIminlight\fP. Instead of increasing low
light levels to the global minimum, add the global minimum light level
to all style 0 lightmaps. This may help reducing the sometimes
uniform minlight effect.
.IP "\fB\-dist n\fP"
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