Skip to content

Commit

Permalink
ALIASMODELS: Add gl_smoothmodels back in (glsl only)
Browse files Browse the repository at this point in the history
Not going to bother with immediate mode
  • Loading branch information
meag committed Jul 16, 2021
1 parent 2843371 commit 2808f33
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 8 deletions.
9 changes: 7 additions & 2 deletions glc_aliasmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extern float r_avertexnormals[NUMVERTEXNORMALS][3];
extern cvar_t r_lerpframes;
extern cvar_t gl_outline;
extern cvar_t gl_program_aliasmodels;
extern cvar_t gl_smoothmodels;

extern float r_framelerp;

Expand Down Expand Up @@ -245,13 +246,14 @@ static void GLC_AliasModelLightPoint(float color[4], entity_t* ent, vbo_model_ve
#define DRAWFLAGS_TEXTURED 2
#define DRAWFLAGS_FULLBRIGHT 4
#define DRAWFLAGS_MUZZLEHACK 8
#define DRAWFLAGS_MAXIMUM (DRAWFLAGS_CAUSTICS | DRAWFLAGS_TEXTURED | DRAWFLAGS_FULLBRIGHT | DRAWFLAGS_MUZZLEHACK)
#define DRAWFLAGS_FLATSHADING 16
#define DRAWFLAGS_MAXIMUM (DRAWFLAGS_CAUSTICS | DRAWFLAGS_TEXTURED | DRAWFLAGS_FULLBRIGHT | DRAWFLAGS_MUZZLEHACK | DRAWFLAGS_FLATSHADING)

int GLC_AliasModelSubProgramIndex(qbool textured, qbool fullbright, qbool caustics, qbool muzzlehack)
{
return
(textured ? DRAWFLAGS_TEXTURED : 0) |
(fullbright ? DRAWFLAGS_FULLBRIGHT : 0) |
(fullbright ? DRAWFLAGS_FULLBRIGHT : (gl_smoothmodels.integer ? 0 : DRAWFLAGS_FLATSHADING)) |
(caustics ? DRAWFLAGS_CAUSTICS : 0) |
(muzzlehack ? DRAWFLAGS_MUZZLEHACK : 0);
}
Expand All @@ -275,6 +277,9 @@ qbool GLC_AliasModelStandardCompileSpecific(int subprogram_index)
if (subprogram_index & DRAWFLAGS_MUZZLEHACK) {
strlcat(included_definitions, "#define EZQ_ALIASMODEL_MUZZLEHACK\n", sizeof(included_definitions));
}
if (subprogram_index & DRAWFLAGS_FLATSHADING) {
strlcat(included_definitions, "#define EZQ_ALIASMODEL_FLATSHADING\n", sizeof(included_definitions));
}

R_ProgramCompileWithInclude(r_program_aliasmodel_std_glc, included_definitions);
R_ProgramUniform1i(r_program_uniform_aliasmodel_std_glc_texSampler, 0);
Expand Down
9 changes: 7 additions & 2 deletions glm_aliasmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ extern float r_framelerp;
#define DRAW_CAUSTIC_TEXTURES 2
#define DRAW_REVERSED_DEPTH 4
#define DRAW_LERP_MUZZLEHACK 8
#define DRAW_FLAT_SHADING 16
static uniform_block_aliasmodels_t aliasdata;

static int cached_mode;
Expand All @@ -118,12 +119,13 @@ static int TEXTURE_UNIT_CAUSTICS;

qbool GLM_CompileAliasModelProgram(void)
{
extern cvar_t r_lerpmuzzlehack;
extern cvar_t r_lerpmuzzlehack, gl_smoothmodels;

unsigned int drawAlias_desiredOptions =
(r_refdef2.drawCaustics ? DRAW_CAUSTIC_TEXTURES : 0) |
(glConfig.reversed_depth ? DRAW_REVERSED_DEPTH : 0) |
(r_lerpmuzzlehack.integer ? DRAW_LERP_MUZZLEHACK : 0);
(r_lerpmuzzlehack.integer ? DRAW_LERP_MUZZLEHACK : 0) |
(gl_smoothmodels.integer ? 0 : DRAW_FLAT_SHADING);

if (R_ProgramRecompileNeeded(r_program_aliasmodel, drawAlias_desiredOptions)) {
static char included_definitions[1024];
Expand Down Expand Up @@ -152,6 +154,9 @@ qbool GLM_CompileAliasModelProgram(void)
if (drawAlias_desiredOptions & DRAW_LERP_MUZZLEHACK) {
strlcat(included_definitions, "#define EZQ_ALIASMODEL_MUZZLEHACK\n", sizeof(included_definitions));
}
if (drawAlias_desiredOptions & DRAW_FLAT_SHADING) {
strlcat(included_definitions, "#define EZQ_ALIASMODEL_FLATSHADING\n", sizeof(included_definitions));
}

// Initialise program for drawing image
R_ProgramCompileWithInclude(r_program_aliasmodel, included_definitions);
Expand Down
4 changes: 4 additions & 0 deletions glsl/draw_aliasmodel.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ layout(binding=SAMPLER_MATERIAL_TEXTURE_START) uniform sampler2D samplers[SAMPLE

in vec2 fsTextureCoord;
in vec2 fsAltTextureCoord;
#ifdef EZQ_ALIASMODEL_FLATSHADING
flat in vec4 fsBaseColor;
#else
in vec4 fsBaseColor;
#endif
flat in int fsFlags;
flat in int fsTextureEnabled;
flat in int fsMaterialSampler;
Expand Down
4 changes: 4 additions & 0 deletions glsl/draw_aliasmodel.vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ layout(std140, binding=EZQ_GL_BINDINGPOINT_ALIASMODEL_DRAWDATA) buffer AliasMode

out vec2 fsTextureCoord;
out vec2 fsAltTextureCoord;
#ifdef EZQ_ALIASMODEL_FLATSHADING
flat out vec4 fsBaseColor;
#else
out vec4 fsBaseColor;
#endif
flat out int fsFlags;
flat out int fsTextureEnabled;
flat out int fsMaterialSampler;
Expand Down
4 changes: 4 additions & 0 deletions glsl/glc/glc_aliasmodel_std.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ uniform float fsCausticEffects;
varying vec2 fsTextureCoord;
#endif

#ifdef EZQ_ALIASMODEL_FLATSHADING
varying flat vec4 fsBaseColor;
#else
varying vec4 fsBaseColor;
#endif

void main()
{
Expand Down
12 changes: 8 additions & 4 deletions glsl/glc/glc_aliasmodel_std.vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@ attribute float flags;
#ifdef BACKFACE_PASS

// for outline
uniform float lerpFraction;
uniform float outlineScale;
varying vec4 fsBaseColor;

#else

#if defined(TEXTURING_ENABLED) || defined(DRAW_CAUSTIC_TEXTURES)
varying vec2 fsTextureCoord;
#endif
varying vec4 fsBaseColor;

#ifndef FULLBRIGHT_MODELS
uniform vec3 angleVector; // normalized
uniform float shadelight; // divided by 256 in C
uniform float ambientlight; // divided by 256 in C
#endif
uniform float lerpFraction; // 0 to 1

#endif // BACKFACE_PASS (outlining)

uniform float lerpFraction; // 0 to 1
#ifdef EZQ_ALIASMODEL_FLATSHADING
varying flat vec4 fsBaseColor;
#else
varying vec4 fsBaseColor;
#endif


#define AM_VERTEX_NOLERP 1

void main()
Expand Down
2 changes: 2 additions & 0 deletions r_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ cvar_t gl_simpleitems_size = {"gl_simpleitems_size", "16"};
cvar_t gl_simpleitems_orientation = {"gl_simpleitems_orientation", "2"};
cvar_t gl_modulate = {"gl_modulate", "1"};
cvar_t gl_outline = {"gl_outline", "0"};
cvar_t gl_smoothmodels = {"gl_smoothmodels", "1"};
cvar_t r_fx_geometry = {"r_fx_geometry", "0"};

cvar_t gl_vbo_clientmemory = {"gl_vbo_clientmemory", "0", CVAR_LATCH_GFX };
Expand Down Expand Up @@ -612,6 +613,7 @@ void R_Init(void)
Cvar_Register(&gl_modulate);

Cvar_Register(&gl_outline);
Cvar_Register(&gl_smoothmodels);

Cvar_Register(&r_fx_geometry);

Expand Down
1 change: 1 addition & 0 deletions release-notes-latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Leaving these here as bugs between dev versions of 3.6 aren't in the release not
- On startup (after `autoexec.cfg` executed), a `vid_restart`/`s_restart` will be issued if any latched variables were changed (#458)
- Fixed bug causing off-by-one error when drawing rectangle outlines (3.5 bug, reported by Matrix, #536)
- Detection of AMD drivers .13399 wasn't being working in classic renderer (#416)
- Added `/gl_smoothmodels` back in, (requested by Repast via [quakeworld.nu](https://www.quakeworld.nu/forum/topic/7508/why-is-the-command-glsmoothmodels-r))

### Changes from alpha7=>alpha8 (Feb 9th => July 13th)

Expand Down

0 comments on commit 2808f33

Please sign in to comment.