diff --git a/polymer/eduke32/build/include/prlights.h b/polymer/eduke32/build/include/prlights.h index 03a7c52d0..94fb00900 100644 --- a/polymer/eduke32/build/include/prlights.h +++ b/polymer/eduke32/build/include/prlights.h @@ -18,6 +18,9 @@ typedef struct s_prlight { uint8_t color[3], priority; int8_t minshade, maxshade; int16_t tilenum; + struct { + int32_t emitshadow : 1; + } publicflags; // internal members float proj[16]; float transform[16]; diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 10932f1bd..7bbbb778e 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -1479,7 +1479,7 @@ int16_t polymer_addlight(_prlight* light) Bmemcpy(&prlights[lighti], light, sizeof(_prlight)); - if (light->radius) { + if (light->radius && light->publicflags.emitshadow) { polymer_processspotlight(&prlights[lighti]); // get the texture handle for the lightmap @@ -4600,15 +4600,18 @@ static int32_t polymer_bindmaterial(_prmaterial material, int16_t* lights, // PR_BIT_SPOT_LIGHT if (prlights[lights[curlight]].radius) { programbits |= prprogrambits[PR_BIT_SPOT_LIGHT].bit; - // PR_BIT_SHADOW_MAP - if (prlights[lights[curlight]].rtindex != -1) { - programbits |= prprogrambits[PR_BIT_SHADOW_MAP].bit; - programbits |= prprogrambits[PR_BIT_PROJECTION_MAP].bit; - } - // PR_BIT_LIGHT_MAP - if (prlights[lights[curlight]].lightmap) { - programbits |= prprogrambits[PR_BIT_LIGHT_MAP].bit; - programbits |= prprogrambits[PR_BIT_PROJECTION_MAP].bit; + + if (prlights[lights[curlight]].publicflags.emitshadow) { + // PR_BIT_SHADOW_MAP + if (prlights[lights[curlight]].rtindex != -1) { + programbits |= prprogrambits[PR_BIT_SHADOW_MAP].bit; + programbits |= prprogrambits[PR_BIT_PROJECTION_MAP].bit; + } + // PR_BIT_LIGHT_MAP + if (prlights[lights[curlight]].lightmap) { + programbits |= prprogrambits[PR_BIT_LIGHT_MAP].bit; + programbits |= prprogrambits[PR_BIT_PROJECTION_MAP].bit; + } } } } @@ -5144,7 +5147,7 @@ static void polymer_updatelights(void) // highly suboptimal polymer_removelight(i); - if (light->radius) + if (light->radius && light->publicflags.emitshadow) polymer_processspotlight(light); polymer_culllight(i); @@ -5328,7 +5331,7 @@ static void polymer_processspotlight(_prlight* light) lightpos[1] = -(float)light->z / 16.0f; lightpos[2] = -(float)light->x; - // calculate the spot light transformations and matrices + // calculate the spot light transformations and matrices radius = (float)(light->radius) / (2048.0f / 360.0f); ang = (float)(light->angle) / (2048.0f / 360.0f); horizang = (float)(-getangle(128, light->horiz-100)) / (2048.0f / 360.0f); @@ -5536,7 +5539,8 @@ static void polymer_prepareshadows(void) while (!prlights[i].flags.active) i++; - if (prlights[i].radius && prlights[i].flags.isinview) + if (prlights[i].radius && prlights[i].publicflags.emitshadow && + prlights[i].flags.isinview) { prlights[i].flags.isinview = 0; prlights[i].rtindex = j + 1; diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 3003e7c7e..0e1239af0 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -7751,6 +7751,7 @@ static void G_DoEffectorLights(void) // STATNUM 14 mylight.minshade = sprite[i].xoffset; mylight.maxshade = sprite[i].yoffset; mylight.tilenum = 0; + mylight.publicflags.emitshadow = 0; if (CS & 2) { @@ -7814,6 +7815,7 @@ static void G_DoEffectorLights(void) // STATNUM 14 mylight.minshade = sprite[i].xoffset; mylight.maxshade = sprite[i].yoffset; mylight.tilenum = actor[i].picnum; + mylight.publicflags.emitshadow = !(CS & 64); if (CS & 2) { @@ -7872,6 +7874,9 @@ static void G_DoEffectorLights(void) // STATNUM 14 actor[i].lightptr->horiz = SH; actor[i].lightptr->flags.invalidate = 1; } + if (!(CS & 64) != actor[i].lightptr->publicflags.emitshadow) { + actor[i].lightptr->publicflags.emitshadow = !(CS & 64); + } actor[i].lightptr->tilenum = actor[i].picnum; } diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 351b4a415..a0c399b97 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -10712,6 +10712,7 @@ void ExtPreCheckKeys(void) // just before drawrooms mylight.radius = (256-(SS+128))<<1; mylight.faderadius = (int16_t)(mylight.radius * 0.75f); mylight.tilenum = OW; + mylight.publicflags.emitshadow = !(CS & 64); addprlight_common1(&mylight, i); } @@ -10746,6 +10747,10 @@ void ExtPreCheckKeys(void) // just before drawrooms spritelightptr[i]->horiz = SH; spritelightptr[i]->flags.invalidate = 1; } + if (!(CS & 64) != spritelightptr[i]->publicflags.emitshadow) + { + spritelightptr[i]->publicflags.emitshadow = !(CS & 64); + } spritelightptr[i]->tilenum = OW; } }