mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
grievre's patch to make entity minlight and fullbright fields work properly
This commit is contained in:
parent
cefc6df98c
commit
b36569eb9f
3 changed files with 37 additions and 14 deletions
|
@ -537,11 +537,26 @@ R_DrawAliasModel (entity_t *e)
|
|||
qfglColor4fv (e->colormod);
|
||||
|
||||
if (!is_fullbright) {
|
||||
float lightadj;
|
||||
|
||||
// get lighting information
|
||||
R_LightPoint (e->origin);
|
||||
|
||||
lightadj = (ambientcolor[0] + ambientcolor[1] + ambientcolor[2]) / 765.0;
|
||||
|
||||
// Do minlight stuff here since that's how software does it :)
|
||||
|
||||
if (lightadj > 0) {
|
||||
if (lightadj < minlight)
|
||||
lightadj = minlight / lightadj;
|
||||
else
|
||||
lightadj = 1.0;
|
||||
|
||||
// 256 is fullbright, NOT 200 (was 1 / 200 or 0.005) -Grievre
|
||||
VectorScale (ambientcolor, 1.0 / 256.0, ambientcolor);
|
||||
// 255 is fullbright
|
||||
VectorScale (ambientcolor, lightadj / 255.0, ambientcolor);
|
||||
} else {
|
||||
ambientcolor[0] = ambientcolor[1] = ambientcolor[2] = minlight;
|
||||
}
|
||||
|
||||
if (gl_vector_light->int_val) {
|
||||
for (l = r_dlights, lnum = 0; lnum < r_maxdlights; lnum++, l++) {
|
||||
|
@ -589,8 +604,6 @@ R_DrawAliasModel (entity_t *e)
|
|||
// 1.5 to allow some pastelization (curb darkness from dlight)
|
||||
if (d > 1.5) {
|
||||
VectorScale (emission, 1.5 / d, emission);
|
||||
} else if (d < minlight) { // had !used_lights (wtf)
|
||||
emission[2] = emission[1] = emission[0] = minlight;
|
||||
}
|
||||
|
||||
qfglMaterialfv (GL_FRONT, GL_EMISSION, emission);
|
||||
|
@ -619,8 +632,6 @@ R_DrawAliasModel (entity_t *e)
|
|||
// 1.5 to allow some fading (curb emission making stuff dark)
|
||||
if (d > 1.5) {
|
||||
VectorScale (emission, 1.5 / d, emission);
|
||||
} else if (d < minlight) {
|
||||
emission[2] = emission[1] = emission[0] = minlight;
|
||||
}
|
||||
|
||||
emission[0] *= e->colormod[0];
|
||||
|
|
|
@ -53,6 +53,7 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
#include "QF/sound.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "r_cvar.h"
|
||||
#include "r_dynamic.h"
|
||||
#include "r_local.h"
|
||||
|
@ -414,6 +415,7 @@ R_DrawEntitiesOnList (void)
|
|||
float lightvec[3] = { -1, 0, 0 };
|
||||
vec3_t dist;
|
||||
float add;
|
||||
float minlight = 0;
|
||||
|
||||
if (!r_drawentities->int_val)
|
||||
return;
|
||||
|
@ -432,10 +434,13 @@ R_DrawEntitiesOnList (void)
|
|||
VectorCopy (currententity->origin, r_entorigin);
|
||||
VectorSubtract (r_origin, r_entorigin, modelorg);
|
||||
|
||||
minlight = max (currententity->model->min_light, currententity->min_light);
|
||||
|
||||
// see if the bounding box lets us trivially reject, also
|
||||
// sets trivial accept status
|
||||
if (R_AliasCheckBBox ()) {
|
||||
j = R_LightPoint (currententity->origin);
|
||||
// 128 instead of 255 due to clamping below
|
||||
j = max (R_LightPoint (currententity->origin), minlight * 128);
|
||||
|
||||
lighting.ambientlight = j;
|
||||
lighting.shadelight = j;
|
||||
|
@ -479,6 +484,7 @@ R_DrawViewModel (void)
|
|||
unsigned int lnum;
|
||||
vec3_t dist;
|
||||
float add;
|
||||
float minlight;
|
||||
dlight_t *dl;
|
||||
|
||||
if (r_inhibit_viewmodel
|
||||
|
@ -496,10 +502,10 @@ R_DrawViewModel (void)
|
|||
VectorCopy (vup, viewlightvec);
|
||||
VectorInverse (viewlightvec);
|
||||
|
||||
j = R_LightPoint (currententity->origin);
|
||||
minlight = max (currententity->min_light, currententity->model->min_light);
|
||||
|
||||
j = max (R_LightPoint (currententity->origin), minlight * 128);
|
||||
|
||||
if (j < 24)
|
||||
j = 24; // always give some light on gun
|
||||
r_viewlighting.ambientlight = j;
|
||||
r_viewlighting.shadelight = j;
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ static __attribute__ ((unused)) const char rcsid[] =
|
|||
#include "QF/sound.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "r_cvar.h"
|
||||
#include "r_dynamic.h"
|
||||
#include "r_local.h"
|
||||
|
@ -434,6 +435,7 @@ R_DrawEntitiesOnList (void)
|
|||
float lightvec[3] = { -1, 0, 0 };
|
||||
vec3_t dist;
|
||||
float add;
|
||||
float minlight;
|
||||
|
||||
if (!r_drawentities->int_val)
|
||||
return;
|
||||
|
@ -452,10 +454,13 @@ R_DrawEntitiesOnList (void)
|
|||
VectorCopy (currententity->origin, r_entorigin);
|
||||
VectorSubtract (r_origin, r_entorigin, modelorg);
|
||||
|
||||
minlight = max (currententity->min_light, currententity->model->min_light);
|
||||
|
||||
// see if the bounding box lets us trivially reject, also
|
||||
// sets trivial accept status
|
||||
if (R_AliasCheckBBox ()) {
|
||||
j = R_LightPoint (currententity->origin);
|
||||
// 128 instead of 255 due to clamping below
|
||||
j = max (R_LightPoint (currententity->origin), minlight * 128);
|
||||
|
||||
lighting.ambientlight = j;
|
||||
lighting.shadelight = j;
|
||||
|
@ -499,6 +504,7 @@ R_DrawViewModel (void)
|
|||
unsigned int lnum;
|
||||
vec3_t dist;
|
||||
float add;
|
||||
float minlight;
|
||||
dlight_t *dl;
|
||||
|
||||
if (r_inhibit_viewmodel || !r_drawviewmodel->int_val
|
||||
|
@ -515,10 +521,10 @@ R_DrawViewModel (void)
|
|||
VectorCopy (vup, viewlightvec);
|
||||
VectorInverse (viewlightvec);
|
||||
|
||||
j = R_LightPoint (currententity->origin);
|
||||
minlight = max (currententity->min_light, currententity->model->min_light);
|
||||
|
||||
j = max (R_LightPoint (currententity->origin), minlight * 128);
|
||||
|
||||
if (j < 24)
|
||||
j = 24; // always give some light on gun
|
||||
r_viewlighting.ambientlight = j;
|
||||
r_viewlighting.shadelight = j;
|
||||
|
||||
|
|
Loading…
Reference in a new issue