cvar_t cl_locs_enable = {CVAR_SAVE, "locs_enable", "1", "enables replacement of certain % codes in chat messages: %l (location), %d (last death location), %h (health), %a (armor), %x (rockets), %c (cells), %r (rocket launcher status), %p (powerup status), %w (weapon status), %t (current time in level)"};
cvar_t cl_locs_show = {0, "locs_show", "0", "shows defined locations for editing purposes"};
+extern cvar_t r_equalize_entities_fullbright;
+
client_static_t cls;
client_state_t cl;
if (e->state_current.number == cl.viewentity)
e->render.flags |= RENDER_EXTERIORMODEL;
// either fullbright or lit
- if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
- e->render.flags |= RENDER_LIGHT;
+ if(!r_fullbright.integer)
+ {
+ if (!(e->render.effects & EF_FULLBRIGHT))
+ e->render.flags |= RENDER_LIGHT;
+ else if(r_equalize_entities_fullbright.integer)
+ e->render.flags |= RENDER_LIGHT | RENDER_EQUALIZE;
+ }
// hide player shadow during intermission or nehahra movie
if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST))
&& (e->render.alpha >= 1)
// need to re-fetch the model pointer
e->render.model = cl.model_precache[e->state_baseline.modelindex];
// either fullbright or lit
- if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
- e->render.flags |= RENDER_LIGHT;
+ if(!r_fullbright.integer)
+ {
+ if (!(e->render.effects & EF_FULLBRIGHT))
+ e->render.flags |= RENDER_LIGHT;
+ else if(r_equalize_entities_fullbright.integer)
+ e->render.flags |= RENDER_LIGHT | RENDER_EQUALIZE;
+ }
// hide player shadow during intermission or nehahra movie
if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST)) && (e->render.alpha >= 1))
e->render.flags |= RENDER_SHADOW;
//4 feature darkplaces csqc: add builtins to clientside qc for gl calls
extern cvar_t v_flipped;
+extern cvar_t r_equalize_entities_fullbright;
sfx_t *S_FindName(const char *name);
int Sbar_GetSortedPlayerIndex (int index);
Matrix4x4_CreateFromQuakeEntity(&staticent->render.matrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], staticent->render.scale);
// either fullbright or lit
- if (!(staticent->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
- staticent->render.flags |= RENDER_LIGHT;
+ if(!r_fullbright.integer)
+ {
+ if (!(staticent->render.effects & EF_FULLBRIGHT))
+ staticent->render.flags |= RENDER_LIGHT;
+ else if(r_equalize_entities_fullbright.integer)
+ staticent->render.flags |= RENDER_LIGHT | RENDER_EQUALIZE;
+ }
// turn off shadows from transparent objects
if (!(staticent->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST)) && (staticent->render.alpha >= 1))
staticent->render.flags |= RENDER_SHADOW;
}
extern cvar_t cl_noplayershadow;
+extern cvar_t r_equalize_entities_fullbright;
qboolean CSQC_AddRenderEdict(prvm_edict_t *ed)
{
int renderflags;
entrender->flags &= ~(RENDER_SHADOW | RENDER_LIGHT | RENDER_NOSELFSHADOW);
// either fullbright or lit
- if (!(entrender->effects & EF_FULLBRIGHT) && !r_fullbright.integer)
- entrender->flags |= RENDER_LIGHT;
+ if(!r_fullbright.integer)
+ {
+ if (!(entrender->effects & EF_FULLBRIGHT))
+ entrender->flags |= RENDER_LIGHT;
+ else if(r_equalize_entities_fullbright.integer)
+ entrender->flags |= RENDER_LIGHT | RENDER_EQUALIZE;
+ }
// hide player shadow during intermission or nehahra movie
if (!(entrender->effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST))
&& (entrender->alpha >= 1)
cvar_t r_motionblur_maxblur = {CVAR_SAVE, "r_motionblur_maxblur", "0.88", "cap for motionblur alpha value"};
cvar_t r_motionblur_randomize = {CVAR_SAVE, "r_motionblur_randomize", "0.1", "randomizing coefficient to workaround ghosting"};
+// TODO do we want a r_equalize_entities cvar that works on all ents, or would that be a cheat?
+cvar_t r_equalize_entities_fullbright = {CVAR_SAVE, "r_equalize_entities_fullbright", "0", "render fullbright entities by equalizing their lightness, not by not rendering light"};
+cvar_t r_equalize_entities_by = {CVAR_SAVE, "r_equalize_entities_by", "0.7", "equalize entity lighting (exponent)"};
+cvar_t r_equalize_entities_to = {CVAR_SAVE, "r_equalize_entities_to", "0.8", "equalize entity lighting (level)"};
+
cvar_t r_animcache = {CVAR_SAVE, "r_animcache", "1", "cache animation frames to save CPU usage, primarily optimizes shadows and reflections"};
cvar_t r_depthfirst = {CVAR_SAVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"};
Cvar_RegisterVariable(&r_motionblur_vcoeff);
Cvar_RegisterVariable(&r_motionblur_randomize);
Cvar_RegisterVariable(&r_damageblur);
+ Cvar_RegisterVariable(&r_equalize_entities_fullbright);
+ Cvar_RegisterVariable(&r_equalize_entities_by);
+ Cvar_RegisterVariable(&r_equalize_entities_to);
Cvar_RegisterVariable(&r_animcache);
Cvar_RegisterVariable(&r_depthfirst);
Cvar_RegisterVariable(&r_useinfinitefarclip);
{
int i;
entity_render_t *ent;
- vec3_t tempdiffusenormal;
+ vec3_t tempdiffusenormal, avg;
+ vec_t f;
for (i = 0;i < r_refdef.scene.numentities;i++)
{
vec3_t org;
Matrix4x4_OriginFromMatrix(&ent->matrix, org);
r_refdef.scene.worldmodel->brush.LightPoint(r_refdef.scene.worldmodel, org, ent->modellight_ambient, ent->modellight_diffuse, tempdiffusenormal);
+ if(r_equalize_entities_by.value != 0 && r_equalize_entities_to.value != 0 && (ent->flags & RENDER_EQUALIZE))
+ {
+ VectorMA(ent->modellight_ambient, 0.25f, ent->modellight_diffuse, avg);
+ f = 0.299f * avg[0] + 0.587f * avg[1] + 0.114f * avg[2];
+ if(f > 0)
+ {
+ f = pow(f / r_equalize_entities_to.value, -r_equalize_entities_by.value);
+ VectorScale(ent->modellight_ambient, f, ent->modellight_ambient);
+ VectorScale(ent->modellight_diffuse, f, ent->modellight_diffuse);
+ }
+ }
}
else // highly rare
VectorSet(ent->modellight_ambient, 1, 1, 1);
#define RENDER_LIGHT 131072 // receive light
#define RENDER_NOSELFSHADOW 262144 // render lighting on this entity before its own shadow is added to the scene
// (note: all RENDER_NOSELFSHADOW entities are grouped together and rendered in a batch before their shadows are rendered, so they can not shadow eachother either)
+#define RENDER_EQUALIZE 524288 // (subflag of RENDER_LIGHT) equalize the light from the light grid hitting this ent (less invasive EF_FULLBRIGHT implementation)
typedef enum entity_state_active_e
{