diff --git a/Makefile b/Makefile index 8f71ba84..fad0ab63 100644 --- a/Makefile +++ b/Makefile @@ -228,19 +228,21 @@ define do_man2man @$(cmd_man2man); endef -# The sed magic is a little ugly, but I wanted something that would work -# across Linux/BSD/Msys/Darwin +# The sed/awk magic is a little ugly, but I wanted something that +# would work across Linux/BSD/Msys/Darwin quiet_cmd_man2txt = ' MAN2TXT $@' cmd_man2txt = \ $(GROFF) -man -Tascii $< | cat -v | \ sed -e 's/\^\[\[\([0-9]\)\{1,2\}[a-z]//g' \ - -e 's/.\^H//g' \ - -e 's/$$/'`printf \\\r`'/' > $(@D)/.$(@F).tmp && \ + -e 's/.\^H//g' | \ + awk '{ gsub("$$", "\r"); print $$0;}' - > $(@D)/.$(@F).tmp && \ mv $(@D)/.$(@F).tmp $@ + loud_cmd_man2txt = \ + $(subst ",\",$(subst $$,\$$,$(subst "\r","\\r",$(cmd_man2txt)))) define do_man2txt @$(do_mkdir) - @echo $(if $(quiet),$(quiet_cmd_man2txt),"$(cmd_man2txt)"); + @echo $(if $(quiet),$(quiet_cmd_man2txt),"$(loud_cmd_man2txt)"); @$(cmd_man2txt); endef diff --git a/changelog.txt b/changelog.txt index 39081da4..b728fbe7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -9,10 +9,12 @@ 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) * light: removed the "-compress" option (a bad idea from long ago) +* light: make -gate command line affect linear falloff lights as well * vis: changed the default testlevel to 4 * vis: added the '-noambient*' options to disable auto ambient sounds. diff --git a/include/light/light.h b/include/light/light.h index fba01641..156c4573 100644 --- a/include/light/light.h +++ b/include/light/light.h @@ -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; diff --git a/light/entities.c b/light/entities.c index 1cd0e9d4..1e6bd33e 100644 --- a/light/entities.c +++ b/light/entities.c @@ -198,7 +198,8 @@ CheckEntityFields(entity_t *entity) if (entity->formula == LF_LINEAR) { /* Linear formula always has a falloff point */ - entity->fadedist = fabs(entity->light.light / entity->atten / scaledist); + entity->fadedist = fabs(entity->light.light) - fadegate; + entity->fadedist = entity->fadedist / entity->atten / scaledist; } else if (fadegate < EQUAL_EPSILON) { /* If fadegate is tiny, other lights have effectively infinite reach */ entity->fadedist = VECT_MAX; diff --git a/light/light.c b/light/light.c index 9abee52b..a05270e2 100644 --- a/light/light.c +++ b/light/light.c @@ -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")) { @@ -253,7 +256,7 @@ main(int argc, const char **argv) softsamples = -1; /* auto, based on oversampling */ } else if (!strcmp(argv[i], "-anglescale") || !strcmp(argv[i], "-anglesense")) { if (i < argc - 2 && isdigit(argv[i + 1][0])) - anglescale = atoi(argv[++i]); + anglescale = sun_anglescale = atoi(argv[++i]); else Error("-anglesense requires a numeric argument (0.0 - 1.0)"); } else if (argv[i][0] == '-') @@ -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); diff --git a/light/ltface.c b/light/ltface.c index 7f772a2a..8a40f78e 100644 --- a/light/ltface.c +++ b/light/ltface.c @@ -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]; } } } diff --git a/man/light.1 b/man/light.1 index 4868577e..0f2993ec 100644 --- a/man/light.1 +++ b/man/light.1 @@ -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