From e3417e5c0861a28f1171910bdf8dd78b91dd507d 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 | 18 +++++++++--------- client/render/gl_decals.h | 2 +- client/render/gl_studiodecal_new.cpp | 8 ++++---- client/render/gl_world_new.cpp | 7 ++++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/client/render/gl_decals.cpp b/client/render/gl_decals.cpp index cdc80bc1..daf35687 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" ); @@ -1497,10 +1497,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 ); @@ -1517,10 +1517,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 @@ -1529,7 +1529,7 @@ static void R_RenderSurfaceDecals( msurface_t *surf, drawlist_t drawlist_type ) R_SetDecalUniforms( p ); - 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 ); @@ -1823,9 +1823,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 4ba3907f..2c959889 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 b57cee7c..fcd1ca47 100644 --- a/client/render/gl_studiodecal_new.cpp +++ b/client/render/gl_studiodecal_new.cpp @@ -844,7 +844,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" ); @@ -858,7 +858,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" ); } @@ -1751,7 +1751,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 ); @@ -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 ); diff --git a/client/render/gl_world_new.cpp b/client/render/gl_world_new.cpp index 27d9ee80..4648fd02 100644 --- a/client/render/gl_world_new.cpp +++ b/client/render/gl_world_new.cpp @@ -2913,9 +2913,10 @@ static int R_SortSolidBrushFaces( const CSolidEntry *a, const CSolidEntry *b ) ================ 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; @@ -3076,7 +3077,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 ) @@ -3121,7 +3122,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?