Skip to content

Commit

Permalink
Merge pull request #800 from krizej/outlines
Browse files Browse the repository at this point in the history
Outline tweaks and spectator xray
  • Loading branch information
tcsabina committed Sep 13, 2023
2 parents b9565e5 + bc4cb0d commit 4dd9ac9
Show file tree
Hide file tree
Showing 25 changed files with 373 additions and 131 deletions.
73 changes: 63 additions & 10 deletions help_variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -5167,19 +5167,19 @@
"default": "0",
"desc": "Controls outlining of models and map. Disallowed in qcon ruleset.",
"group-id": "35",
"remarks": "See /r_fx_geometry for edge outlining of the map.",
"remarks": "World outlines require vid_framebuffer 1|2 and Modern OpenGL (vid_renderer 1). With vid_renderer 0, ruleset default and sv_cheats 1, gl_outline 2 draws outlines of every surface that is rendered.",
"type": "enum",
"values": [
{
"description": "Outlining disabled",
"name": "0"
},
{
"description": "Outline models to create rotoscope effect",
"description": "Outline models",
"name": "1"
},
{
"description": "Outline world (used only for map development)",
"description": "Outline world",
"name": "2"
},
{
Expand All @@ -5188,6 +5188,66 @@
}
]
},
"gl_outline_color_world": {
"default": "0 0 0",
"desc": "Determines the color of world outlines.",
"group-id": "35",
"type": "string"
},
"gl_outline_color_model": {
"default": "0 0 0",
"desc": "Determines the color of model outlines.",
"remarks": "Requires vid_renderer 1",
"group-id": "35",
"type": "string"
},
"gl_outline_scale_model": {
"default": "1",
"desc": "Determines the scale of model outlines. Allows values 0 to 1 for rulesets smackdown and qcon, and 0 to 5 for other rulesets.",
"remarks": "Requires vid_renderer 1",
"group-id": "35",
"type": "float"
},
"gl_outline_world_depth_threshold": {
"default": "4",
"desc": "Threshold for finding edges with depth values. Higher value means vanishing lines at close range. Lower value means false positives at longer range.",
"group-id": "35",
"type": "float"
},
"gl_outline_use_player_color": {
"default": "0",
"desc": "Use the top and bottom color for drawing player outlines",
"remarks": "Requires vid_renderer 1",
"group-id": "35",
"type": "boolean"
},
"gl_outline_color_team": {
"default": "",
"desc": "Determines the outline color of friendly players. Set to \"\" to use the value of gl_outline_color_model.",
"remarks": "Requires vid_renderer 1",
"group-id": "35",
"type": "string"
},
"gl_outline_color_enemy": {
"default": "",
"desc": "Determines the outline color of enemy players. Set to \"\" to use the value of gl_outline_color_model.",
"remarks": "Requires vid_renderer 1",
"group-id": "35",
"type": "string"
},
"gl_spec_xray": {
"default": "0",
"desc": "See players through walls (demo/qtv only). Is affected by gl_outline_* values like color, scale, etc.",
"remarks": "Requires vid_renderer 1",
"group-id": "35",
"type": "boolean"
},
"gl_spec_xray_distance": {
"default": "512",
"desc": "Distance from which you can see the players through walls, see gl_spec_xray",
"group-id": "35",
"type": "float"
},
"gl_part_blobs": {
"default": "0",
"desc": "Determines particles used for blob explosions (EMPs).",
Expand Down Expand Up @@ -15855,13 +15915,6 @@
}
]
},
"r_fx_geometry": {
"default": "0",
"desc": "Outlines the world based on surface normals. Disallowed in qcon ruleset.",
"group-id": "35",
"remarks": "Requires vid_framebuffer 1|2 and Modern OpenGL (vid_renderer 1). See /gl_outline for model outline",
"type": "boolean"
},
"r_glstats": {
"default": "0",
"desc": "When enabled, it creates a window in the top right of the screen showing the number of particles and etc. in use.",
Expand Down
34 changes: 28 additions & 6 deletions src/cl_ents.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "utils.h"
#include "qmb_particles.h"
#include "rulesets.h"
#include "teamplay.h"

static int MVD_TranslateFlags(int src);
void TP_ParsePlayerInfo(player_state_t *, player_state_t *, player_info_t *info);
Expand Down Expand Up @@ -1651,7 +1652,11 @@ static qbool CL_AddVWepModel (entity_t *ent, int vw_index, int old_vw_frame)
newent.skinnum = 0;
newent.colormap = vid.colormap;
newent.renderfx |= RF_PLAYERMODEL; // not really, but use same lighting rules
newent.renderfx |= RF_VWEPMODEL;
if(ent->renderfx & RF_BEHINDWALL)
newent.renderfx |= RF_BEHINDWALL;
newent.effects = ent->effects; // Electro - added for shells
newent.scoreboard = ent->scoreboard; // for team color in gl_outline

if ((!cls.mvdplayback || Cam_TrackNum() >= 0) && cl.racing && !CL_SetAlphaByDistance(&newent)) {
return false;
Expand Down Expand Up @@ -1684,16 +1689,17 @@ void CL_StorePausePredictionLocations(void)
static void CL_LinkPlayers(void)
{
int j, msec, i, flicker, oldphysent;
float *org;
vec3_t tmp;
float *org, distance;
vec3_t tmp, end, diff;
double playertime = CL_PlayerTime();
player_info_t *info;
player_state_t *state, exact;
entity_t ent;
centity_t *cent;
frame_t *frame;
trace_t trace;
customlight_t cst_lt = {0};
extern cvar_t cl_debug_antilag_ghost, cl_debug_antilag_view;
extern cvar_t cl_debug_antilag_ghost, cl_debug_antilag_view, gl_spec_xray_distance;

frame = &cl.frames[cl.parsecount & UPDATE_MASK];
memset (&ent, 0, sizeof(entity_t));
Expand Down Expand Up @@ -1955,16 +1961,32 @@ static void CL_LinkPlayers(void)
}
}

if ((cl.vwep_enabled && r_drawvweps.value && state->vw_index) && (state->modelindex != cl_modelindices[mi_eyes]))
VectorCopy(cent->lerp_origin, end);
end[2] += 12;
trace = PM_TraceLine(r_refdef.vieworg, end);

if (trace.fraction != 1) {
VectorSubtract(cent->lerp_origin, r_refdef.vieworg, diff);
distance = VectorLength(diff);

if(distance > gl_spec_xray_distance.value)
continue;
else
ent.renderfx |= RF_BEHINDWALL;
} else
ent.renderfx &= ~RF_BEHINDWALL;

ent.renderfx |= RF_PLAYERMODEL;

if ((cl.vwep_enabled && r_drawvweps.value && state->vw_index) && (state->modelindex != cl_modelindices[mi_eyes]))
{
qbool vwep;
vwep = CL_AddVWepModel (&ent, state->vw_index, cent->old_vw_frame);
if (vwep)
if (vwep)
{
if (cl.vw_model_name[0][0] != '-')
{
ent.model = cl.vw_model_precache[0];
ent.renderfx |= RF_PLAYERMODEL;
if (Cam_TrackNum() >= 0 && cl.racing) {
CL_SetAlphaByDistance(&ent);
}
Expand Down
6 changes: 3 additions & 3 deletions src/gl_framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern cvar_t vid_framebuffer_hdr;
extern cvar_t vid_framebuffer_blit;
extern cvar_t vid_framebuffer_smooth;
extern cvar_t vid_framebuffer_multisample;
extern cvar_t r_fx_geometry;
extern cvar_t gl_outline;

static framebuffer_id VID_MultisampledAlternateId(framebuffer_id id);

Expand Down Expand Up @@ -171,7 +171,7 @@ C_ASSERT(sizeof(framebuffer_multisample_alternate) / sizeof(framebuffer_multisam

static framebuffer_data_t framebuffer_data[framebuffer_count];

//
//
GL_StaticProcedureDeclaration(glGenFramebuffers, "n=%d, ids=%p", GLsizei n, GLuint* ids)
GL_StaticProcedureDeclaration(glDeleteFramebuffers, "n=%d, ids=%p", GLsizei n, GLuint* ids)
GL_StaticProcedureDeclaration(glBindFramebuffer, "target=%u, framebuffer=%u", GLenum target, GLuint framebuffer)
Expand Down Expand Up @@ -477,7 +477,7 @@ qbool GL_FramebufferStartWorldNormals(framebuffer_id id)
GLenum buffers[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
float clearValue[] = { 0.0f, 0.0f, 0.0f, 0.0f };

if (!r_fx_geometry.integer || !GL_Supported(R_SUPPORT_FRAMEBUFFERS) || !RuleSets_AllowEdgeOutline()) {
if (!(gl_outline.integer & 2) || !GL_Supported(R_SUPPORT_FRAMEBUFFERS) || !RuleSets_AllowEdgeOutline()) {
return false;
}

Expand Down
16 changes: 16 additions & 0 deletions src/gl_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,22 @@ static r_program_uniform_t program_uniforms[] = {
{ r_program_lightmap_compute, "firstLightmap", 1, false },
// r_program_uniform_turb_glc_fog_skyFogMix,
{ r_program_sky_glc, "skyFogMix", 1, false },
// r_program_uniform_outline_color
{ r_program_fx_world_geometry, "outline_color", 1, false },
// r_program_uniform_outline_depth_threshold
{ r_program_fx_world_geometry, "outline_depth_threshold", 1, false },
// r_program_uniform_outline_scale
{ r_program_fx_world_geometry, "outline_scale", 1, false },
// r_program_uniform_aliasmodel_outline_color_model
{ r_program_aliasmodel, "outline_color", 1, false },
// r_program_uniform_aliasmodel_outline_color_team
{ r_program_aliasmodel, "outline_color_team", 1, false },
// r_program_uniform_aliasmodel_outline_color_enemy
{ r_program_aliasmodel, "outline_color_enemy", 1, false },
// r_program_uniform_aliasmodel_outline_use_player_color
{ r_program_aliasmodel, "outline_use_player_color", 1, false },
// r_program_uniform_aliasmodel_outline_scale
{ r_program_aliasmodel, "outline_scale", 1, false },
};

#ifdef C_ASSERT
Expand Down
Loading

0 comments on commit 4dd9ac9

Please sign in to comment.