From e8ae9bafc72f3538ee2bbfe8102a95f8a2b457a0 Mon Sep 17 00:00:00 2001 From: Yui <50331474+SirYodaJedi@users.noreply.github.com> Date: Wed, 3 Dec 2025 14:10:32 -0500 Subject: [PATCH] VRAD - don't generate per-vertex fallbacks for lightmaped props by default Speeds up compile times; can re-enable old behavoir with `-propmapvertexfallbacks`. --- src/utils/vrad/vrad.cpp | 6 +++ src/utils/vrad/vradstaticprops.cpp | 85 ++++++++++++++++-------------- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/src/utils/vrad/vrad.cpp b/src/utils/vrad/vrad.cpp index 241771524cb..72401dcd836 100644 --- a/src/utils/vrad/vrad.cpp +++ b/src/utils/vrad/vrad.cpp @@ -61,6 +61,7 @@ bool bRed2Black = true; bool g_bFastAmbient = false; bool g_bNoSkyRecurse = false; bool g_bDumpPropLightmaps = false; +bool g_bPropLightmapFallbacks = false; int junk; @@ -2698,6 +2699,10 @@ int ParseCommandLine( int argc, char **argv, bool *onlydetail ) return -1; } } + else if (!Q_stricmp(argv[i],"-propmapvertexfallbacks")) + { + g_bPropLightmapFallbacks = true; + } #if ALLOWDEBUGOPTIONS else if (!Q_stricmp(argv[i],"-scale")) @@ -2876,6 +2881,7 @@ void PrintUsage( int argc, char **argv ) " -textureshadows : Allows texture alpha channels to block light - rays intersecting alpha surfaces will sample the texture\n" " -noskyboxrecurse : Turn off recursion into 3d skybox (skybox shadows on world)\n" " -nossprops : Globally disable self-shadowing on static props\n" + " -propmapvertexfallbacks : Generate fallback per-vertex lighting for lightmapped static props" "\n" #if 1 // Disabled for the initial SDK release with VMPI so we can get feedback from selected users. ); diff --git a/src/utils/vrad/vradstaticprops.cpp b/src/utils/vrad/vradstaticprops.cpp index cb15683ad31..2cc055a7977 100644 --- a/src/utils/vrad/vradstaticprops.cpp +++ b/src/utils/vrad/vradstaticprops.cpp @@ -1377,57 +1377,60 @@ void CVradStaticPropMgr::ComputeLighting( CStaticProp &prop, int iThread, int pr GenerateLightmapSamplesForMesh( matPos, matNormal, iThread, skip_prop, nFlags, prop.m_LightmapImageWidth, prop.m_LightmapImageHeight, pStudioHdr, pStudioModel, pVtxModel, meshID, pResults ); } - // If we do lightmapping, we also do vertex lighting as a potential fallback. This may change. - for ( int vertexID = 0; vertexID < pStudioMesh->numvertices; ++vertexID ) + // If we do lightmapping, only do vertex lighting as a potential fallback if user requests. + if (!withTexelLighting || g_bPropLightmapFallbacks) { - Vector sampleNormal; - Vector samplePosition; - // transform position and normal into world coordinate system - VectorTransform(*vertData->Position(vertexID), matPos, samplePosition); - VectorTransform(*vertData->Normal(vertexID), matNormal, sampleNormal); - - if ( PositionInSolid( samplePosition ) ) - { - // vertex is in solid, add to the bad list, and recover later - badVertex_t badVertex; - badVertex.m_ColorVertex = numVertexes; - badVertex.m_Position = samplePosition; - badVertex.m_Normal = sampleNormal; - badVerts.AddToTail( badVertex ); - } - else + for ( int vertexID = 0; vertexID < pStudioMesh->numvertices; ++vertexID ) { - Vector direct_pos=samplePosition; - - + Vector sampleNormal; + Vector samplePosition; + // transform position and normal into world coordinate system + VectorTransform(*vertData->Position(vertexID), matPos, samplePosition); + VectorTransform(*vertData->Normal(vertexID), matNormal, sampleNormal); - Vector directColor(0,0,0); - ComputeDirectLightingAtPoint( direct_pos, - sampleNormal, directColor, iThread, - skip_prop, nFlags ); - Vector indirectColor(0,0,0); - - if (g_bShowStaticPropNormals) + if ( PositionInSolid( samplePosition ) ) { - directColor= sampleNormal; - directColor += Vector(1.0,1.0,1.0); - directColor *= 50.0; + // vertex is in solid, add to the bad list, and recover later + badVertex_t badVertex; + badVertex.m_ColorVertex = numVertexes; + badVertex.m_Position = samplePosition; + badVertex.m_Normal = sampleNormal; + badVerts.AddToTail( badVertex ); } else { - if (numbounce >= 1) - ComputeIndirectLightingAtPoint( - samplePosition, sampleNormal, - indirectColor, iThread, true, - ( prop.m_Flags & STATIC_PROP_IGNORE_NORMALS) != 0 ); + Vector direct_pos=samplePosition; + + + + Vector directColor(0,0,0); + ComputeDirectLightingAtPoint( direct_pos, + sampleNormal, directColor, iThread, + skip_prop, nFlags ); + Vector indirectColor(0,0,0); + + if (g_bShowStaticPropNormals) + { + directColor= sampleNormal; + directColor += Vector(1.0,1.0,1.0); + directColor *= 50.0; + } + else + { + if (numbounce >= 1) + ComputeIndirectLightingAtPoint( + samplePosition, sampleNormal, + indirectColor, iThread, true, + ( prop.m_Flags & STATIC_PROP_IGNORE_NORMALS) != 0 ); + } + + colorVerts[numVertexes].m_bValid = true; + colorVerts[numVertexes].m_Position = samplePosition; + VectorAdd( directColor, indirectColor, colorVerts[numVertexes].m_Color ); } - colorVerts[numVertexes].m_bValid = true; - colorVerts[numVertexes].m_Position = samplePosition; - VectorAdd( directColor, indirectColor, colorVerts[numVertexes].m_Color ); + numVertexes++; } - - numVertexes++; } }