From c137bb89260a21068023f20a27446f805cd5d02b Mon Sep 17 00:00:00 2001 From: Knightmare66 Date: Wed, 30 Sep 2020 03:17:50 -0400 Subject: [PATCH] Added r_entity_doublelight cvar to renderer. --- kmquake2_changelog.txt | 2 ++ renderer/r_light.c | 26 ++++++++++++++++++-------- renderer/r_local.h | 1 + renderer/r_main.c | 27 +++++++++++++++------------ 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/kmquake2_changelog.txt b/kmquake2_changelog.txt index b783718..f320780 100644 --- a/kmquake2_changelog.txt +++ b/kmquake2_changelog.txt @@ -66,6 +66,8 @@ Changes as of v0.20 update 8: - Added changeable gl_clear color controlled by cvars r_clearcolor_r, r_clearcolor_g, and r_clearcolor_b. Values are normalized (0-1). +- Added doubled entity lighting to mimic Q2's original entity lighting. Set the cvar r_entity_doublelight to 1 to enable this. + - Added ifeq, ifneq, ifgt, ifge, iflt, ifle, ifbit, and ifnbit layout script commands. - Added a check to prevent game code from sending unicasts to non-present clients (i.e. bots). This would diff --git a/renderer/r_light.c b/renderer/r_light.c index d418557..38e6418 100644 --- a/renderer/r_light.c +++ b/renderer/r_light.c @@ -399,7 +399,7 @@ void R_LightPoint (vec3_t p, vec3_t color, qboolean isEnt) } // this catches too bright modulated color - for (i=0;i<3;i++) + for (i=0; i<3; i++) if (color[i]>1) color[i] = 1; // @@ -422,8 +422,13 @@ void R_LightPoint (vec3_t p, vec3_t color, qboolean isEnt) if (add > 0) VectorMA (color, add, dl->color, color); } - //VectorScale (color, r_modulate->value, color); // Knightmare- this makes ents too bright - //VectorScale (color, r_modulate->value*1.5f, color); // Knightmare- this makes ents too bright + + // scale up light color by r_modulate if enabled + if (r_entity_doublelight->integer) { + VectorScale (color, r_modulate->value, color); + } +// VectorScale (color, r_modulate->value, color); // Knightmare- this makes ents too bright +// VectorScale (color, r_modulate->value*1.5f, color); // Knightmare- this makes ents too bright } @@ -462,7 +467,7 @@ void R_LightPointDynamics (vec3_t p, vec3_t color, m_dlight_t *list, int *amount VectorCopy (pointcolor, color); } - //this catches too bright modulated color + // this catches too bright modulated color for (i=0;i<3;i++) if (color[i]>1) color[i] = 1; @@ -471,7 +476,7 @@ void R_LightPointDynamics (vec3_t p, vec3_t color, m_dlight_t *list, int *amount // m_dl = 0; dl = r_newrefdef.dlights; - for (lnum=0 ; lnumspotlight) // spotlights continue; @@ -485,7 +490,7 @@ void R_LightPointDynamics (vec3_t p, vec3_t color, m_dlight_t *list, int *amount float highest = -1; VectorScale(dl->color, add, dlColor); - for (i=0;i<3;i++) + for (i=0; i<3; i++) if (highestinteger) { + VectorScale (color, r_modulate->value, color); + } + *amount = m_dl; } diff --git a/renderer/r_local.h b/renderer/r_local.h index c2fc759..1d250fd 100644 --- a/renderer/r_local.h +++ b/renderer/r_local.h @@ -241,6 +241,7 @@ extern cvar_t *r_dlights_normal; extern cvar_t *r_model_shading; extern cvar_t *r_model_dlights; extern cvar_t *r_model_minlight; +extern cvar_t *r_entity_doublelight; extern cvar_t *r_lightlevel; // FIXME: This is a HACK to get the client's light level diff --git a/renderer/r_main.c b/renderer/r_main.c index 7e63313..ae8ed0f 100644 --- a/renderer/r_main.c +++ b/renderer/r_main.c @@ -104,6 +104,7 @@ cvar_t *r_dlights_normal; // lerped dlights on models cvar_t *r_model_shading; cvar_t *r_model_dlights; cvar_t *r_model_minlight; +cvar_t *r_entity_doublelight; cvar_t *r_lightlevel; // FIXME: This is a HACK to get the client's light level @@ -683,9 +684,9 @@ void R_RenderView (refdef_t *fd) { R_SuspendFog (); - // R_DrawAllDecals(); - R_DrawAllEntities(false); - R_DrawAllParticles(); + // R_DrawAllDecals (); + R_DrawAllEntities( false); + R_DrawAllParticles (); R_ResumeFog (); } @@ -696,17 +697,17 @@ void R_RenderView (refdef_t *fd) R_RenderDlights(); if (r_transrendersort->integer) { - //R_BuildParticleList(); - R_SortParticlesOnList(); - R_DrawAllDecals(); - //R_DrawAllEntityShadows(); - R_DrawSolidEntities(); - R_DrawEntitiesOnList(ents_trans); + // R_BuildParticleList (); + R_SortParticlesOnList (); + R_DrawAllDecals (); + // R_DrawAllEntityShadows (); + R_DrawSolidEntities (); + R_DrawEntitiesOnList (ents_trans); } else { - R_DrawAllDecals(); - //R_DrawAllEntityShadows(); - R_DrawAllEntities(true); + R_DrawAllDecals (); + // R_DrawAllEntityShadows (); + R_DrawAllEntities (true); } R_DrawAllParticles (); @@ -964,6 +965,8 @@ void R_Register (void) Cvar_SetDescription ("r_model_dlights", "Sets maximum number of dynamic lights for a model."); r_model_minlight = Cvar_Get ("r_model_minlight", "0.02", CVAR_ARCHIVE ); Cvar_SetDescription ("r_model_minlight", "Sets minimum light level for alias model rendering."); + r_entity_doublelight = Cvar_Get ("r_entity_doublelight", "0", CVAR_ARCHIVE ); + Cvar_SetDescription ("r_entity_doublelight", "Enables original glitchy double-lighting of models. This is a sort-of-exploit, but is not considered a cheat."); r_lightlevel = Cvar_Get ("r_lightlevel", "0", 0); Cvar_SetDescription ("r_lightlevel", "Hack to send player's light level to server. This is overwritten every render frame.");