Skip to content

Commit

Permalink
Try light trace from entity origin first
Browse files Browse the repository at this point in the history
Merged from QuakeSpasm
  • Loading branch information
j0zzz committed Nov 7, 2022
1 parent fb341f6 commit fdd634b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion trunk/gl_rlight.c
Expand Up @@ -476,7 +476,7 @@ int R_LightPoint (vec3_t p)
VectorClear (lightcolor);
RecursiveLightPoint(lightcolor, cl.worldmodel->nodes, p, p, end, &maxdist);

return (lightcolor[0] + lightcolor[1] + lightcolor[2]) / 3.0;
return ((lightcolor[0] + lightcolor[1] + lightcolor[2]) * (1.0f / 3.0f));
}

/*
Expand Down
21 changes: 13 additions & 8 deletions trunk/gl_rmain.c
Expand Up @@ -1356,7 +1356,7 @@ void R_SetupLighting (entity_t *ent)
{
int i, lnum;
float add;
vec3_t dist, dlight_color, lpos;
vec3_t dist, dlight_color;
model_t *clmodel = ent->model;

// make thunderbolt and torches full light
Expand All @@ -1383,13 +1383,18 @@ void R_SetupLighting (entity_t *ent)
}

// normal lighting
VectorCopy(ent->origin, lpos);
// start the light trace from slightly above the origin
// this helps with models whose origin is below ground level, but are otherwise visible
// (e.g. some of the candles in the DOTM start map, which would otherwise appear black)
lpos[2] += ent->model->maxs[2] * 0.5f;
ambientlight = shadelight = R_LightPoint(lpos);
full_light = false;
// if the initial trace is completely black, try again from above
// this helps with models whose origin is slightly below ground level
// (e.g. some of the candles in the DOTM start map)
if (!R_LightPoint(ent->origin))
{
vec3_t lpos;
VectorCopy(ent->origin, lpos);
lpos[2] += ent->model->maxs[2] * 0.5f;
ambientlight = shadelight = R_LightPoint(lpos);
}

full_light = false;
ent->noshadow = (clmodel->flags & EF_NOSHADOW);

for (lnum = 0 ; lnum < MAX_DLIGHTS ; lnum++)
Expand Down

0 comments on commit fdd634b

Please sign in to comment.