Support "_dirt" "-1" on bmodels to disable dirtmapping

This commit is contained in:
Eric Wasylishen 2015-03-05 20:07:10 -07:00
parent be8c42460c
commit ef471ee44f
4 changed files with 25 additions and 11 deletions

View File

@ -82,6 +82,7 @@ typedef struct {
qboolean shadowself;
lightsample_t minlight;
vec3_t offset;
qboolean nodirt;
} modelinfo_t;
typedef struct sun_s {

View File

@ -178,6 +178,11 @@ FindModelInfo(const bsp2_t *bsp)
} else {
VectorCopy(vec3_white, info->minlight.color);
}
/* Check for disabled dirtmapping on this bmodel */
if (atoi(ValueForKey(entity, "_dirt")) == -1) {
info->nodirt = true;
}
}
tracelist = shadowmodels;

View File

@ -719,7 +719,7 @@ Light_ClampMin(lightsample_t *sample, const vec_t light, const vec3_t color)
* ============
*/
static inline vec_t
Dirt_GetScaleFactor(vec_t occlusion, const entity_t *entity)
Dirt_GetScaleFactor(vec_t occlusion, const entity_t *entity, const modelinfo_t *modelinfo)
{
vec_t light_dirtgain = dirtGain;
vec_t light_dirtscale = dirtScale;
@ -729,6 +729,8 @@ Dirt_GetScaleFactor(vec_t occlusion, const entity_t *entity)
/* is dirt processing disabled entirely? */
if (!dirty)
return 1.0f;
if (modelinfo != NULL && modelinfo->nodirt)
return 1.0f;
/* should this light be affected by dirt? */
if (entity) {
@ -847,7 +849,7 @@ LightFace_Entity(const entity_t *entity, const lightsample_t *light,
angle = (1.0 - entity->anglescale) + entity->anglescale * angle;
add = GetLightValue(light, entity, dist) * angle * spotscale;
add *= Dirt_GetScaleFactor(lightsurf->occlusion[i], entity);
add *= Dirt_GetScaleFactor(lightsurf->occlusion[i], entity, modelinfo);
Light_Add(sample, add, light->color);
@ -904,7 +906,7 @@ LightFace_Sky(const sun_t *sun, const lightsurf_t *lightsurf, lightmap_t *lightm
continue;
value = angle * sun->sunlight.light;
if (sun->dirt)
value *= Dirt_GetScaleFactor(lightsurf->occlusion[i], NULL);
value *= Dirt_GetScaleFactor(lightsurf->occlusion[i], NULL, modelinfo);
Light_Add(sample, value, sun->sunlight.color);
if (!hit/* && (sample->light >= 1)*/)
hit = true;
@ -940,7 +942,7 @@ LightFace_Min(const lightsample_t *light,
for (i = 0; i < lightsurf->numpoints; i++, sample++) {
vec_t value = light->light;
if (minlightDirt)
value *= Dirt_GetScaleFactor(lightsurf->occlusion[i], NULL);
value *= Dirt_GetScaleFactor(lightsurf->occlusion[i], NULL, modelinfo);
if (addminlight)
Light_Add(sample, value, light->color);
else
@ -963,7 +965,7 @@ LightFace_Min(const lightsample_t *light,
trace = TestLight(entity->origin, surfpoint, shadowself);
if (!trace)
continue;
value *= Dirt_GetScaleFactor(lightsurf->occlusion[j], entity);
value *= Dirt_GetScaleFactor(lightsurf->occlusion[j], entity, modelinfo);
if (addminlight)
Light_Add(sample, value, entity->light.color);
else
@ -996,7 +998,7 @@ LightFace_DirtDebug(const lightsurf_t *lightsurf, lightmap_t *lightmaps)
/* Overwrite each point with the dirt value for that sample... */
sample = lightmap->samples;
for (i = 0; i < lightsurf->numpoints; i++, sample++) {
sample->light = 255 * Dirt_GetScaleFactor(lightsurf->occlusion[i], NULL);
sample->light = 255 * Dirt_GetScaleFactor(lightsurf->occlusion[i], NULL, NULL);
VectorSet(sample->color, sample->light, sample->light, sample->light);
}

View File

@ -124,9 +124,9 @@ Default is no dirtmapping (-1).
.IP "\fB""_sunlight_dirt"" ""n""\fP"
1 enables dirtmapping (ambient occlusion) on sunlight, -1 to disable (making it illuminate the dirtmapping shadows). Default is to use the value of "_dirt".
.IP "\fB""_sunlight2_dirt"" ""n""\fP"
1 enables dirtmapping (ambient occlusion) on sunlight2, -1 to disable. Default is to use the value of "_dirt".
.IP "\fB""_sunlight2_dirt"" ""n""\fP"
1 enables dirtmapping (ambient occlusion) on sunlight2, -1 to disable. Default is to use the value of "_dirt".
.IP "\fB""_minlight_dirt"" ""n""\fP"
1 enables dirtmapping (ambient occlusion) on minlight, -1 to disable. Default is to use the value of "_dirt".
@ -171,6 +171,12 @@ If n is 1, this model will cast shadows on itself if one part of the model
blocks the light from another model surface. This can be a better compromise
for moving models than full shadowing. Default 0.
.IP "\fB""_dirt"" ""n""\fP"
For brush models, -1 prevents dirtmapping on the brush model. Useful it the
bmodel touches or sticks into the world, and you want to those ares from
turning black. Default 0.
.SH "LIGHT ENTITY KEYS"
.PP
@ -255,8 +261,8 @@ Convert the light into a sphere of randomly positioned lights with radius "n" (i
.IP "\fB""_samples"" ""n""\fP"
Number of lights to use for "_deviance". Use 16 as a starting point, more for higher quality. Default 1.
.SH AUTHOR
Written by Kevin Shanahan (aka Tyrann)
.SH AUTHOR
Written by Kevin Shanahan (aka Tyrann)
.br
Based on source provided by id Software
.br