mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[scene] Support ambient lighting in worldspawn
Abyss of Pandemonium uses global ambient light a lot, but doesn't specify it in every map (nothing extracting entities and adding a reasonable value can't fix). I imagine some further tweaking will be needed.
This commit is contained in:
parent
c26c3b2739
commit
df5b471342
3 changed files with 20 additions and 4 deletions
|
@ -38,7 +38,6 @@
|
|||
struct mod_brush_s;
|
||||
|
||||
#define NumStyles 64
|
||||
#define NoStyle -1
|
||||
|
||||
#define LM_LINEAR 0 // light - dist (or radius + dist if -ve)
|
||||
#define LM_INVERSE 1 // distFactor1 * light / dist
|
||||
|
|
|
@ -232,8 +232,16 @@ locate_lights (model_t *model, lightingdata_t *ldata)
|
|||
light_t *lights = ldata->lights.a;
|
||||
DARRAY_RESIZE (&ldata->lightleafs, ldata->lights.size);
|
||||
for (size_t i = 0; i < ldata->lights.size; i++) {
|
||||
mleaf_t *leaf = Mod_PointInLeaf (&lights[i].position[0], model);
|
||||
ldata->lightleafs.a[i] = leaf - model->brush.leafs - 1;
|
||||
if (1 || lights[i].position[3]) {
|
||||
mleaf_t *leaf = Mod_PointInLeaf (&lights[i].position[0], model);
|
||||
ldata->lightleafs.a[i] = leaf - model->brush.leafs - 1;
|
||||
} else {
|
||||
if (DotProduct (lights[i].direction, lights[i].direction)) {
|
||||
ldata->lightleafs.a[i] = -1;
|
||||
} else {
|
||||
ldata->lightleafs.a[i] = -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,6 +279,15 @@ CL_LoadLights (plitem_t *entities, scene_t *scene)
|
|||
if (!strcmp (classname, "worldspawn")) {
|
||||
// parse_sun can add many lights
|
||||
parse_sun (ldata, entity);
|
||||
const char *str;
|
||||
if ((str = PL_String (PL_ObjectForKey (entity, "light_lev")))) {
|
||||
light_t light = {};
|
||||
light.color = (vec4f_t) { 1, 1, 1, atof (str) };
|
||||
light.attenuation = (vec4f_t) { 0, 0, 1, 0 };
|
||||
light.direction = (vec4f_t) { 0, 0, 0, 1 };
|
||||
DARRAY_APPEND (&ldata->lights, light);
|
||||
DARRAY_APPEND (&ldata->lightstyles, 0);
|
||||
}
|
||||
} else if (!strncmp (classname, "light", 5)) {
|
||||
light_t light = {};
|
||||
int style = 0;
|
||||
|
|
|
@ -128,7 +128,7 @@ Light_FindVisibleLights (lightingdata_t *ldata)
|
|||
memset (ldata->lightvis.a, 0, ldata->lightvis.size * sizeof (byte));
|
||||
for (size_t i = 0; i < ldata->lightleafs.size; i++) {
|
||||
int l = ldata->lightleafs.a[i];
|
||||
if ((l == -1 && (flags & SURF_DRAWSKY))
|
||||
if ((l == -2) || (l == -1 && (flags & SURF_DRAWSKY))
|
||||
|| set_is_member (ldata->pvs, l)) {
|
||||
ldata->lightvis.a[i] = 1;
|
||||
visible++;
|
||||
|
|
Loading…
Reference in a new issue