diff --git a/include/light/light.h b/include/light/light.h index ea46d569..53c17b23 100644 --- a/include/light/light.h +++ b/include/light/light.h @@ -55,7 +55,8 @@ typedef struct { typedef struct { const dmodel_t *model; - qboolean shadowself; + qboolean shadowself; /* is it shadow casting only on itself? */ + qboolean shadow; /* is it shadow casting? */ lightsample_t minlight; char minlight_exclude[16]; /* texture name to exclude from minlight */ float lightmapscale; diff --git a/light/light.cc b/light/light.cc index 9c5cf538..bec8572b 100644 --- a/light/light.cc +++ b/light/light.cc @@ -295,6 +295,7 @@ FindModelInfo(const bsp2_t *bsp, const char *lmscaleoverride) if (i != lightmapscale) logprint("WARNING: lightmap scale is not a power of 2\n"); modelinfo[0].lightmapscale = lightmapscale; + modelinfo[0].shadow = true; /* world always casts shadows */ for (i = 1, info = modelinfo + 1; i < bsp->nummodels; i++, info++) { info->model = &bsp->dmodels[i]; @@ -311,6 +312,7 @@ FindModelInfo(const bsp2_t *bsp, const char *lmscaleoverride) shadow = atoi(ValueForKey(entity, "_shadow")); if (shadow) { shadowmodels[numshadowmodels++] = info; + info->shadow = true; } else { shadow = atoi(ValueForKey(entity, "_shadowself")); if (shadow) { diff --git a/light/ltface.c b/light/ltface.c index 9caae2bb..7f90161d 100644 --- a/light/ltface.c +++ b/light/ltface.c @@ -2162,22 +2162,24 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, } VectorScale(lightsurf->texturecolor, 1.0f/lightsurf->numpoints, lightsurf->texturecolor); - // make bounce light if (bounce) { - vec3_t gray = {127, 127, 127}; - - // lerp between gray and the texture color according to `bouncecolorscale` - vec3_t blendedcolor = {0, 0, 0}; - VectorMA(blendedcolor, bouncecolorscale, lightsurf->texturecolor, blendedcolor); - VectorMA(blendedcolor, 1-bouncecolorscale, gray, blendedcolor); - - vec3_t emitcolor; - for (int k=0; k<3; k++) { - emitcolor[k] = (lightsurf->radiosity[k] / 255.0f) * (blendedcolor[k] / 255.0f); + // make bounce light, only if this face is shadow casting + if (modelinfo->shadow) { + vec3_t gray = {127, 127, 127}; + + // lerp between gray and the texture color according to `bouncecolorscale` + vec3_t blendedcolor = {0, 0, 0}; + VectorMA(blendedcolor, bouncecolorscale, lightsurf->texturecolor, blendedcolor); + VectorMA(blendedcolor, 1-bouncecolorscale, gray, blendedcolor); + + vec3_t emitcolor; + for (int k=0; k<3; k++) { + emitcolor[k] = (lightsurf->radiosity[k] / 255.0f) * (blendedcolor[k] / 255.0f); + } + winding_t *w = WindingFromFace(bsp, face); + AddBounceLight(lightsurf->midpoint, emitcolor, lightsurf->plane.normal, WindingArea(w), bsp); + free(w); } - winding_t *w = WindingFromFace(bsp, face); - AddBounceLight(lightsurf->midpoint, emitcolor, lightsurf->plane.normal, WindingArea(w), bsp); - free(w); } else { WriteLightmaps(face, facesup, lightsurf, lightmaps); }