Skip to content

Commit

Permalink
Quick hack at EF_ADDITIVE, for reliable overlapping transparencies (e…
Browse files Browse the repository at this point in the history
…specially light sources/rayvolues).
  • Loading branch information
Shpoike committed Nov 2, 2023
1 parent 528824e commit 32b433a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions Quake/pr_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -9069,6 +9069,7 @@ void PR_DumpPlatform_f(void)
fprintf(f, "const float EF_MUZZLEFLASH = %i;\n", EF_MUZZLEFLASH);
fprintf(f, "const float EF_BRIGHTLIGHT = %i;\n", EF_BRIGHTLIGHT);
fprintf(f, "const float EF_DIMLIGHT = %i;\n", EF_DIMLIGHT);
fprintf(f, "const float EF_ADDITIVE = %i;\n", EF_ADDITIVE);
fprintf(f, "const float EF_BLUE = %i;\n", EF_BLUE);
fprintf(f, "const float EF_RED = %i;\n", EF_RED);
fprintf(f, "const float EF_FULLBRIGHT = %i;\n", EF_FULLBRIGHT);
Expand Down
2 changes: 1 addition & 1 deletion Quake/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EF_BRIGHTLIGHT 4
#define EF_DIMLIGHT 8
//#define EF_NODRAW 16
//#define EF_ADDITIVE 32
#define EF_ADDITIVE 32
#define EF_BLUE 64
#define EF_RED 128
//#define EFDP_NOGUNBOB (1u<<8)
Expand Down
7 changes: 7 additions & 0 deletions Quake/r_alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,11 @@ void R_DrawAliasModel (entity_t *e)
}
else if (alphatest)
glEnable (GL_ALPHA_TEST);
if (e->effects & EF_ADDITIVE)
{
glBlendFunc (GL_SRC_ALPHA, GL_ONE);
glEnable(GL_BLEND);
}

//
// set up lighting
Expand Down Expand Up @@ -1432,6 +1437,8 @@ void R_DrawAliasModel (entity_t *e)
glColor3f(1,1,1);
if (e->eflags & EFLAGS_VIEWMODEL)
glDepthRange (0, 1);
if (e->effects & EF_ADDITIVE)
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPopMatrix ();
}

Expand Down
18 changes: 16 additions & 2 deletions Quake/r_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,11 +985,19 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain)
int lastlightmap;
gltexture_t *fullbright = NULL;
float entalpha;
unsigned int enteffects;

entalpha = (ent != NULL) ? ENTALPHA_DECODE(ent->alpha) : 1.0f;
enteffects = (ent != NULL) ? ent->effects : 0;

// enable blending / disable depth writes
if (entalpha < 1)
if (enteffects & EF_ADDITIVE)
{
glDepthMask (GL_FALSE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE);
glEnable (GL_BLEND);
}
else if (entalpha < 1)
{
glDepthMask (GL_FALSE);
glEnable (GL_BLEND);
Expand Down Expand Up @@ -1078,7 +1086,13 @@ void R_DrawTextureChains_GLSL (qmodel_t *model, entity_t *ent, texchain_t chain)
GL_UseProgramFunc (0);
GL_SelectTexture (GL_TEXTURE0);

if (entalpha < 1)
if (enteffects & EF_ADDITIVE)
{
glDepthMask (GL_TRUE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //our normal alpha setting.
glDisable (GL_BLEND);
}
else if (entalpha < 1)
{
glDepthMask (GL_TRUE);
glDisable (GL_BLEND);
Expand Down

0 comments on commit 32b433a

Please sign in to comment.