From 6c1a567a809a90d5fe58bba04c4dbc9bae699a06 Mon Sep 17 00:00:00 2001 From: SNMetamorph <25657591+SNMetamorph@users.noreply.github.com> Date: Thu, 2 Nov 2023 21:50:32 +0400 Subject: [PATCH] WIP --- client/render/gl_decals.cpp | 20 ++++++++++---------- client/render/gl_decals.h | 2 +- client/render/gl_studiodecal_new.cpp | 8 ++++---- client/render/gl_world_new.cpp | 7 ++++--- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/client/render/gl_decals.cpp b/client/render/gl_decals.cpp index 9cc59b90..e36b3d0e 100644 --- a/client/render/gl_decals.cpp +++ b/client/render/gl_decals.cpp @@ -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 )) @@ -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" ); @@ -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" ); @@ -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 ); @@ -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 @@ -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 ); } @@ -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; diff --git a/client/render/gl_decals.h b/client/render/gl_decals.h index f98491d6..f812978b 100644 --- a/client/render/gl_decals.h +++ b/client/render/gl_decals.h @@ -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; diff --git a/client/render/gl_studiodecal_new.cpp b/client/render/gl_studiodecal_new.cpp index 4d694f91..21a28f5f 100644 --- a/client/render/gl_studiodecal_new.cpp +++ b/client/render/gl_studiodecal_new.cpp @@ -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" ); @@ -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" ); } @@ -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 ); @@ -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 ); diff --git a/client/render/gl_world_new.cpp b/client/render/gl_world_new.cpp index b4e7fd9d..503b217a 100644 --- a/client/render/gl_world_new.cpp +++ b/client/render/gl_world_new.cpp @@ -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; @@ -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 ) @@ -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?