polymer: add a prlight flag to make shadow-less spotlights

And hook it up to SE cstat 64 ('1' in mapster32). This disables both lightmaps
and shadow maps for the spotlight; please let me know if you have a usecase
where you want lightmaps but no shadow maps for specific lights.

git-svn-id: https://svn.eduke32.com/eduke32@3091 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
Plagman 2012-10-21 03:41:13 +00:00
parent fdef8a6b8c
commit 9d10b0b087
4 changed files with 30 additions and 13 deletions

View file

@ -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];

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}
}