Light priority system.

git-svn-id: https://svn.eduke32.com/eduke32@1305 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2009-04-12 16:28:20 +00:00
parent 567c0bdd86
commit b7449a87b9
5 changed files with 76 additions and 38 deletions

View File

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

View File

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

View File

@ -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,15 +3983,25 @@ 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;
curpriority = 0;
while (curpriority < PR_MAXLIGHTPRIORITY)
{
i = 0;
while (i < staticlightcount)
{
if ((staticlights[i].priority != curpriority) ||
(staticlights[i].priority > pr_maxlightpriority))
{
i++;
continue;
}
if (staticlights[i].minshade == staticlights[i].maxshade)
polymer_addlight(staticlights[i]);
else {
@ -4027,6 +4024,36 @@ static void polymer_dostaticlights(void)
}
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++;
}
}
// RENDER TARGETS

View File

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

View File

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