Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
SNMetamorph committed Nov 2, 2023
1 parent c2a6931 commit 6c1a567
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
20 changes: 10 additions & 10 deletions client/render/gl_decals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void DecalGroupEntry :: PreloadTextures( void )

gl_diffuse_id = id;
if (FBitSet(gl_diffuse_id.GetFlags(), TF_HAS_ALPHA))
opaque = true;
has_alpha = true;

Q_snprintf( path, sizeof( path ), "gfx/decals/%s_norm", name );
if( IMAGE_EXISTS( path ))
Expand Down Expand Up @@ -382,7 +382,7 @@ static word R_ShaderDecalForward( brushdecal_t *decal )
if( CVAR_TO_BOOL( cv_specular ) && ( texinfo->gl_specular_id != tr.blackTexture ))
GL_AddShaderDirective( options, "HAS_GLOSSMAP" );

if( !texinfo->opaque )
if( !texinfo->has_alpha )
{
// GL_DST_COLOR, GL_SRC_COLOR
GL_AddShaderDirective( options, "APPLY_COLORBLEND" );
Expand Down Expand Up @@ -466,7 +466,7 @@ static word R_ShaderDecalDeferred( brushdecal_t *decal )
if( CVAR_TO_BOOL( cv_specular ) && ( texinfo->gl_specular_id != tr.blackTexture ))
GL_AddShaderDirective( options, "HAS_GLOSSMAP" );

if( !texinfo->opaque )
if( !texinfo->has_alpha )
{
// GL_DST_COLOR, GL_SRC_COLOR
GL_AddShaderDirective( options, "APPLY_COLORBLEND" );
Expand Down Expand Up @@ -1593,10 +1593,10 @@ static void R_DrawSurfaceDecalsDebug( msurface_t *surf, drawlist_t drawlist_type
if( !p->surface || !p->texinfo )
continue; // bad decal?

if( drawlist_type == DRAWLIST_SOLID && !p->texinfo->opaque )
if( drawlist_type == DRAWLIST_SOLID && !p->texinfo->has_alpha )
continue;

if( drawlist_type == DRAWLIST_TRANS && p->texinfo->opaque )
if( drawlist_type == DRAWLIST_TRANS && p->texinfo->has_alpha )
continue;

DrawWireDecal( p );
Expand All @@ -1613,10 +1613,10 @@ static void R_RenderSurfaceDecals( msurface_t *surf, drawlist_t drawlist_type )
if( !p->surface || !p->texinfo )
continue; // bad decal?

if( drawlist_type == DRAWLIST_SOLID && !p->texinfo->opaque )
if( drawlist_type == DRAWLIST_SOLID && !p->texinfo->has_alpha )
continue;

if( drawlist_type == DRAWLIST_TRANS && p->texinfo->opaque )
if( drawlist_type == DRAWLIST_TRANS && p->texinfo->has_alpha )
continue;

// initialize decal shader
Expand All @@ -1634,7 +1634,7 @@ static void R_RenderSurfaceDecals( msurface_t *surf, drawlist_t drawlist_type )

if( !FBitSet( RI->params, RP_DEFERREDSCENE ))
{
if( p->texinfo->opaque )
if( p->texinfo->has_alpha )
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
else pglBlendFunc( GL_DST_COLOR, GL_SRC_COLOR );
}
Expand Down Expand Up @@ -1943,9 +1943,9 @@ void DecalsInit( void )
if( token[0] == '$' )
{
Q_strncpy( token, token + 1, sizeof( token ));
tempentries[numtemp].opaque = true;// force solid
tempentries[numtemp].has_alpha = true;// force solid
}
else tempentries[numtemp].opaque = false;
else tempentries[numtemp].has_alpha = false;
Q_strncpy( tempentries[numtemp].m_DecalName, token, sizeof( tempentries[numtemp].m_DecalName ));
tempentries[numtemp].xsize = Q_atof( sz_xsize ) / 2.0f;
tempentries[numtemp].ysize = Q_atof( sz_ysize ) / 2.0f;
Expand Down
2 changes: 1 addition & 1 deletion client/render/gl_decals.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DecalGroupEntry
int xsize, ysize;
matdesc_t *matdesc; // pointer to settings
float overlay;
bool opaque; // solid decal doesn't use blend
bool has_alpha; // solid decal doesn't use blend
const DecalGroup *group; // get group name
bool m_init;

Expand Down
8 changes: 4 additions & 4 deletions client/render/gl_studiodecal_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ word CStudioModelRenderer :: ShaderDecalForward( studiodecal_t *pDecal, bool ver
if (tr.fogEnabled && !RP_CUBEPASS())
GL_AddShaderDirective( options, "APPLY_FOG_EXP" );

if( !texinfo->opaque )
if( !texinfo->has_alpha )
{
// GL_DST_COLOR, GL_SRC_COLOR
GL_AddShaderDirective( options, "APPLY_COLORBLEND" );
Expand All @@ -859,7 +859,7 @@ word CStudioModelRenderer :: ShaderDecalForward( studiodecal_t *pDecal, bool ver
GL_AddShaderDirective( options, "PARALLAX_OCCLUSION" );
}

if (!texinfo->opaque || FBitSet(mat->flags, STUDIO_NF_FULLBRIGHT) || R_FullBright())
if (!texinfo->has_alpha || FBitSet(mat->flags, STUDIO_NF_FULLBRIGHT) || R_FullBright())
{
GL_AddShaderDirective( options, "LIGHTING_FULLBRIGHT" );
}
Expand Down Expand Up @@ -1768,7 +1768,7 @@ void CStudioModelRenderer :: DrawDecal( CSolidEntry *entry, GLenum cull_mode )
continue;

SetDecalUniforms( pDecal );
if( pDecal->texinfo->opaque )
if( pDecal->texinfo->has_alpha )
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
else pglBlendFunc( GL_DST_COLOR, GL_SRC_COLOR );
DrawMeshFromBuffer( &pDecal->mesh );
Expand All @@ -1785,7 +1785,7 @@ void CStudioModelRenderer :: DrawDecal( CSolidEntry *entry, GLenum cull_mode )
continue;

SetDecalUniforms( pDecal );
if( pDecal->texinfo->opaque )
if( pDecal->texinfo->has_alpha )
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
else pglBlendFunc( GL_DST_COLOR, GL_SRC_COLOR );
DrawMeshFromBuffer( &pDecal->mesh );
Expand Down
7 changes: 4 additions & 3 deletions client/render/gl_world_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3225,9 +3225,10 @@ void R_SetSurfaceUniforms( word hProgram, msurface_t *surface, bool force )
================
R_RenderDynLightList
fills solid/transparent/light lists for grass and world/models surfaces
================
*/
void R_BuildFaceListForLight( CDynLight *pl, bool solid )
void R_BuildFaceListsForLight( CDynLight *pl, bool solid )
{
RI->currententity = GET_ENTITY( 0 );
RI->currentmodel = RI->currententity->model;
Expand Down Expand Up @@ -3388,7 +3389,7 @@ void R_DrawLightForSurfList( CDynLight *pl )
================
R_RenderDynLightList
draw dynamic lights for world and bmodels
draw dynamic lights for world, bmodels and grass
================
*/
void R_RenderDynLightList( bool solid )
Expand Down Expand Up @@ -3433,7 +3434,7 @@ void R_RenderDynLightList( bool solid )
RI->currentlight = pl;

// draw world from light position
R_BuildFaceListForLight( pl, solid );
R_BuildFaceListsForLight( pl, solid );

if( !RI->frame.light_faces.Count() && !RI->frame.light_grass.Count() )
continue; // no interaction with this light?
Expand Down

0 comments on commit 6c1a567

Please sign in to comment.