mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
Implement the sun lighting calculations.
The sun(s) won't work right now because the vectors aren't properly set up.
This commit is contained in:
parent
4d4bcaf3a3
commit
5950803462
1 changed files with 69 additions and 0 deletions
|
@ -446,6 +446,71 @@ SingleLightFace (entity_t *light, lightinfo_t *l)
|
|||
l->lightstyles[mapnum] = light->style;
|
||||
}
|
||||
|
||||
static void
|
||||
SkyLightFace (entity_t *ent, int sun, lightinfo_t *l)
|
||||
{
|
||||
int sun_light = ent->sun_light[sun != 0];
|
||||
const vec_t *sun_color = ent->sun_color[sun != 0];
|
||||
const vec_t *sun_dir = ent->sun_dir[sun];
|
||||
float dist;
|
||||
int i;
|
||||
int mapnum;
|
||||
float angle;
|
||||
float add;
|
||||
vec3_t incoming;
|
||||
lightpoint_t *point;
|
||||
lightsample_t *sample;
|
||||
|
||||
if (sun_light <= 0)
|
||||
return;
|
||||
|
||||
dist = DotProduct (sun_dir, l->facenormal);
|
||||
|
||||
// don't bother with lights behind the surface
|
||||
if (dist <= -0.25)
|
||||
return;
|
||||
|
||||
// if sunlight is set, use a style 0 light map
|
||||
for (mapnum = 0; mapnum < MAXLIGHTMAPS; mapnum++) {
|
||||
if (l->lightstyles[mapnum] == 0)
|
||||
break;
|
||||
if (l->lightstyles[mapnum] == 255) {
|
||||
memset (l->sample[mapnum], 0,
|
||||
sizeof (lightsample_t) * l->numsamples);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mapnum == MAXLIGHTMAPS) {
|
||||
//printf ("WARNING: Too many light styles on a face\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check each point...
|
||||
VectorCopy (sun_dir, incoming);
|
||||
VectorNormalize (incoming);
|
||||
angle = DotProduct (incoming, l->facenormal);
|
||||
//anglesense = 0.5; //FIXME
|
||||
|
||||
// FIXME global
|
||||
|
||||
for (i = 0, point = l->point; i < l->numpoints; i++, point++) {
|
||||
|
||||
angle = DotProduct (incoming, l->facenormal);
|
||||
|
||||
if (!TestSky (l, point->v, sun_dir))
|
||||
continue;
|
||||
add = sun_light;
|
||||
continue;
|
||||
|
||||
add *= angle;
|
||||
|
||||
add *= options.extrascale;
|
||||
|
||||
sample = &l->sample[mapnum][point->samplepos];
|
||||
VectorMultAdd (sample->c, add, sun_color, sample->c);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
FixMinlight (lightinfo_t *l)
|
||||
|
@ -523,6 +588,10 @@ LightFace (lightinfo_t *l, int surfnum)
|
|||
for (i = 0; i < num_novislights; i++) {
|
||||
SingleLightFace (novislights[i], l);
|
||||
}
|
||||
if (world_entity && world_entity->num_suns) {
|
||||
for (i = 0; i < world_entity->num_suns; i++)
|
||||
SkyLightFace (world_entity, i, l);
|
||||
}
|
||||
|
||||
// FixMinlight (&l);
|
||||
|
||||
|
|
Loading…
Reference in a new issue