Minshade and maxshade parameters for dynamic lighthacks.

git-svn-id: https://svn.eduke32.com/eduke32@1302 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2009-04-12 12:32:50 +00:00
parent 35691be969
commit 6477b236b2
3 changed files with 41 additions and 7 deletions

View file

@ -153,6 +153,7 @@ typedef struct s_prlight {
int32_t x, y, z, horiz, range;
int16_t angle, faderadius, radius, sector;
char color[3];
int8_t minshade, maxshade;
GLfloat proj[16];
GLfloat transform[16];
float frustum[5 * 4];
@ -317,6 +318,7 @@ static void polymer_compileprogram(int32_t programbits);
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);
// 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
case T_LIGHT: // light sector x y z range r g b radius faderadius angle horiz minshade maxshade
{
int32_t value;
@ -7554,6 +7554,10 @@ int32_t loadmaphack(char *filename)
staticlights[staticlightcount].angle = value;
scriptfile_getnumber(script, &value);
staticlights[staticlightcount].horiz = value;
scriptfile_getnumber(script, &value);
staticlights[staticlightcount].minshade = value;
scriptfile_getnumber(script, &value);
staticlights[staticlightcount].maxshade = value;
staticlightcount++;
break;

View file

@ -697,12 +697,7 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da
pos[1] = -(float)(daposz) / 16.0f;
pos[2] = -daposx;
i = 0;
while (i < staticlightcount)
{
polymer_addlight(staticlights[i]);
i++;
}
polymer_dostaticlights();
depth = 0;
polymer_prepareshadows();
@ -3980,6 +3975,39 @@ static void polymer_prepareshadows(void)
sinviewingrangeglobalang = osinviewingrangeglobalang;
}
static void polymer_dostaticlights(void)
{
int32_t i;
_prlight light;
float fade;
i = 0;
while (i < staticlightcount)
{
if (staticlights[i].minshade == staticlights[i].maxshade)
polymer_addlight(staticlights[i]);
else {
light = staticlights[i];
fade = sector[light.sector].floorshade;
fade -= light.minshade;
fade /= light.maxshade - light.minshade;
if (fade < 0.0f)
fade = 0.0f;
if (fade > 1.0f)
fade = 1.0f;
light.color[0] *= fade;
light.color[1] *= fade;
light.color[2] *= fade;
polymer_addlight(light);
}
i++;
}
}
// RENDER TARGETS
static void polymer_initrendertargets(int32_t count)
{