it also had me stumped for a while but thinking about it and if you notice the code above the piece where it should give players a minimum amount of light you might notice that the amount is allready clamped before checking for the player model any subseeding code with a value less than what its allready clamped at will just do nothing
.
heres the entire funtion i use in realm atm. you might notice some strange flags like EF_MINLIGHT well i moved the minlight check clientside.
Code: Select all
void R_SetupAliasModelsLight (entity_t *ent)
{
int i;
float ang_ceil, ang_floor;
// set to NULL initially - if R_LightColor fails then we can do a test
ent->lightplane = NULL;
lightplane = NULL;
// always do this cos we need lightspot for shadows
R_LightColor (ent->origin, shadelight);
// save out lightspot and lightplane for shadows
ent->lightspot[0] = lightspot[0];
ent->lightspot[1] = lightspot[1];
ent->lightspot[2] = lightspot[2];
ent->lightplane = lightplane;
// always give some light (btw all the other crap is not nessesary trust me)
// the EF_MINLIGHT i based on an idea from tochris.
if (ent->flags & EF_MINLIGHT)
{
if (shadelight[0] < 24) shadelight[0] = 24;
if (shadelight[1] < 24) shadelight[1] = 24;
if (shadelight[2] < 24) shadelight[2] = 24;
}
// rotating objects (i.e. pick-ups) will always have some constant light in order to
// make them noticeable... (added from the last mhquake with opengl support)
if (ent->flags & EF_ROTATE)
{
// set rotating objects to the largest of r/g/b
float largest = shadelight[0];
if (shadelight[1] > largest) largest = shadelight[1];
if (shadelight[2] > largest) largest = shadelight[2];
shadelight[0] = shadelight[1] = shadelight[2] = largest;
}
// clamp lighting so it doesn't overbright as much
if (shadelight[0] > 192) shadelight[0] = 192;
if (shadelight[1] > 192) shadelight[1] = 192;
if (shadelight[2] > 192) shadelight[2] = 192;
// light interpolation
lightLerpOffset = (ent->angles[1] + ent->angles[0]) * (SHADEDOT_QUANT / 360.0);
ang_ceil = ceil (lightLerpOffset);
ang_floor = floor (lightLerpOffset);
lightLerpOffset = ang_ceil - lightLerpOffset;
shadedots1 = r_avertexnormal_dots[(int) ang_ceil & (SHADEDOT_QUANT - 1)];
shadedots2 = r_avertexnormal_dots[(int) ang_floor & (SHADEDOT_QUANT - 1)];
// set to a 0 to 1 scale, and reduce a little
shadelight[0] = shadelight[0] / 224.0f;
shadelight[1] = shadelight[1] / 224.0f;
shadelight[2] = shadelight[2] / 224.0f;
// interpolate and store for the next frame
for (i = 0; i < 3; i++)
{
if (ent->lastShadeLight[i])
{
shadelight[i] = (shadelight[i] + ent->lastShadeLight[i]) / 2;
}
ent->lastShadeLight[i] = shadelight[i];
}
}
and the flag in CL_ParseUpdate just after
R_TranslatePlayerSkin (num - 1);
// do not allow players to go totally black
ent->flags |= EF_MINLIGHT;
btw theres two of these so i set it on both.
the idea is partially from tochris.