diff --git a/polymer/eduke32/build/include/polymer.h b/polymer/eduke32/build/include/polymer.h index 4c42265db..b4962c86c 100644 --- a/polymer/eduke32/build/include/polymer.h +++ b/polymer/eduke32/build/include/polymer.h @@ -148,11 +148,12 @@ typedef struct s_prprogrambit { // LIGHTS #define PR_MAXLIGHTS 128 #define SHADOW_DEPTH_OFFSET 30 +#define PR_MAXLIGHTPRIORITY 3 typedef struct s_prlight { int32_t x, y, z, horiz, range; int16_t angle, faderadius, radius, sector; - char color[3]; + char color[3], priority; int8_t minshade, maxshade; GLfloat proj[16]; GLfloat transform[16]; @@ -324,7 +325,7 @@ static void polymer_addlight(_prlight light); static int32_t polymer_planeinlight(_prplane* plane, _prlight* light); static void polymer_culllight(char lightindex); static void polymer_prepareshadows(void); -static void polymer_dostaticlights(void); +static void polymer_applylights(void); // RENDER TARGETS static void polymer_initrendertargets(int32_t count); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 8a0f3983c..e607ed0c2 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -7526,7 +7526,7 @@ int32_t loadmaphack(char *filename) } spriteext[whichsprite].flags |= SPREXT_AWAY2; break; - case T_LIGHT: // light sector x y z range r g b radius faderadius angle horiz minshade maxshade + case T_LIGHT: // light sector x y z range r g b radius faderadius angle horiz minshade maxshade priority { int32_t value; @@ -7558,6 +7558,8 @@ int32_t loadmaphack(char *filename) staticlights[staticlightcount].minshade = value; scriptfile_getnumber(script, &value); staticlights[staticlightcount].maxshade = value; + scriptfile_getnumber(script, &value); + staticlights[staticlightcount].priority = value; staticlightcount++; break; diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 8f94a79a4..e1aa48d01 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -7,6 +7,7 @@ // CVARS int32_t pr_maxlightpasses = 5; +int32_t pr_maxlightpriority = PR_MAXLIGHTPRIORITY; int32_t pr_fov = 426; // appears to be the classic setting. int32_t pr_billboardingmode = 1; int32_t pr_verbosity = 1; // 0: silent, 1: errors and one-times, 2: multiple-times, 3: flood @@ -704,21 +705,7 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da polymer_resetlights(); - polymer_dostaticlights(); - - i = 0; - while (i < gamelightcount) - { - polymer_addlight(gamelights[i]); - i++; - } - - i = 0; - while (i < framelightcount) - { - polymer_addlight(framelights[i]); - i++; - } + polymer_applylights(); depth = 0; polymer_prepareshadows(); @@ -3996,36 +3983,76 @@ static void polymer_prepareshadows(void) sinviewingrangeglobalang = osinviewingrangeglobalang; } -static void polymer_dostaticlights(void) +static void polymer_applylights(void) { - int32_t i; + int32_t i, curpriority; _prlight light; float fade; - i = 0; - while (i < staticlightcount) + curpriority = 0; + while (curpriority < PR_MAXLIGHTPRIORITY) { - if (staticlights[i].minshade == staticlights[i].maxshade) - polymer_addlight(staticlights[i]); - else { - light = staticlights[i]; + i = 0; + while (i < staticlightcount) + { + if ((staticlights[i].priority != curpriority) || + (staticlights[i].priority > pr_maxlightpriority)) + { + i++; + continue; + } - fade = sector[light.sector].floorshade; - fade -= light.minshade; - fade /= light.maxshade - light.minshade; + if (staticlights[i].minshade == staticlights[i].maxshade) + polymer_addlight(staticlights[i]); + else { + light = staticlights[i]; - if (fade < 0.0f) - fade = 0.0f; - if (fade > 1.0f) - fade = 1.0f; + fade = sector[light.sector].floorshade; + fade -= light.minshade; + fade /= light.maxshade - light.minshade; - light.color[0] *= fade; - light.color[1] *= fade; - light.color[2] *= fade; + if (fade < 0.0f) + fade = 0.0f; + if (fade > 1.0f) + fade = 1.0f; - polymer_addlight(light); + light.color[0] *= fade; + light.color[1] *= fade; + light.color[2] *= fade; + + polymer_addlight(light); + } + i++; } - i++; + + i = 0; + while (i < gamelightcount) + { + if ((gamelights[i].priority != curpriority) || + (gamelights[i].priority > pr_maxlightpriority)) + { + i++; + continue; + } + + polymer_addlight(gamelights[i]); + i++; + } + + i = 0; + while (i < framelightcount) + { + if ((framelights[i].priority != curpriority) || + (framelights[i].priority > pr_maxlightpriority)) + { + i++; + continue; + } + + polymer_addlight(framelights[i]); + i++; + } + curpriority++; } } diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 69a5bed4e..98acfe844 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -3583,6 +3583,8 @@ static void G_MoveActors(void) gamelights[gamelightcount].color[1] = 255; gamelights[gamelightcount].color[2] = 255; + gamelights[gamelightcount].priority = 0; + gamelightcount++; if (ud.multimode < 2) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 5f35bab14..8088bb4cc 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -7383,6 +7383,8 @@ PALONLY: framelights[framelightcount].color[1] = 80; framelights[framelightcount].color[2] = 0; + framelights[framelightcount].priority = 0; + if ((DynamicTileMap[s->picnum] == ATOMICHEALTH__STATIC) || (DynamicTileMap[s->picnum] == FREEZEBLAST__STATIC)) { @@ -7430,6 +7432,8 @@ PALONLY: framelights[framelightcount].color[1] = 80; framelights[framelightcount].color[2] = 0; + framelights[framelightcount].priority = 0; + framelightcount++; #endif break; @@ -7451,6 +7455,8 @@ PALONLY: framelights[framelightcount].color[1] = 0; framelights[framelightcount].color[2] = 255; + framelights[framelightcount].priority = 0; + framelightcount++; #endif break;