Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/utils/vrad/vrad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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.
);
Expand Down
85 changes: 44 additions & 41 deletions src/utils/vrad/vradstaticprops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}

Expand Down