Skip to content

Commit d68ed0c

Browse files
committed
Mark lightMappingMaterial shaders for building correctly
1 parent a331254 commit d68ed0c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/engine/renderer/Material.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,8 @@ void ProcessMaterialLightMapping( Material* material, shaderStage_t* pStage, Mat
11761176

11771177
gl_lightMappingShaderMaterial->SetReliefMapping( pStage->enableReliefMapping );
11781178

1179-
gl_lightMappingShaderMaterial->SetReflectiveSpecular( pStage->enableSpecularMapping );
1179+
// Check for reflectionMappingAvailable here to better predict which shaders we need to build at the start
1180+
gl_lightMappingShaderMaterial->SetReflectiveSpecular( glConfig.reflectionMappingAvailable && pStage->enableSpecularMapping );
11801181

11811182
gl_lightMappingShaderMaterial->SetPhysicalShading( pStage->enablePhysicalMapping );
11821183

@@ -1410,7 +1411,19 @@ void MaterialSystem::ProcessStage( MaterialSurface* surface, shaderStage_t* pSta
14101411
material.usePolygonOffset = shader->polygonOffset;
14111412

14121413
material.bspSurface = surface->bspSurface;
1414+
14131415
pStage->materialProcessor( &material, pStage, surface );
1416+
1417+
if ( pStage->enableSpecularMapping && pStage->shaderBinder == BindShaderLightMapping ) {
1418+
/* This will get the non-reflective version of the material if reflection mapping is enabled,
1419+
because the reflection maps will need to be built with it if there's no valid cache or the caching is disabled */
1420+
Material tmp = material;
1421+
1422+
pStage->enableSpecularMapping = false;
1423+
pStage->materialProcessor( &tmp, pStage, surface );
1424+
pStage->enableSpecularMapping = true;
1425+
}
1426+
14141427
pStage->paddedSize = material.shader->GetSTD140Size();
14151428

14161429
// HACK: Copy the shaderStage_t and MaterialSurface that we need into the material, so we can use it with glsl_restart

0 commit comments

Comments
 (0)