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
15 changes: 14 additions & 1 deletion src/engine/renderer/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,8 @@ void ProcessMaterialLightMapping( Material* material, shaderStage_t* pStage, Mat

gl_lightMappingShaderMaterial->SetReliefMapping( pStage->enableReliefMapping );

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

gl_lightMappingShaderMaterial->SetPhysicalShading( pStage->enablePhysicalMapping );

Expand Down Expand Up @@ -1445,7 +1446,19 @@ void MaterialSystem::ProcessStage( MaterialSurface* surface, shaderStage_t* pSta
material.usePolygonOffset = shader->polygonOffset;

material.bspSurface = surface->bspSurface;

pStage->materialProcessor( &material, pStage, surface );

if ( pStage->enableSpecularMapping && pStage->shaderBinder == BindShaderLightMapping ) {
/* This will get the non-reflective version of the material if reflection mapping is enabled,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't cubemaps being unavailable give you the version with specular mapping enabled but reflective specular disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah? Reflective specular isn't used if there are no cubemaps available, so I'm not sure what the question is here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I thought there would be a compile option for enable specular but there isn't.

But in any case, the branch doesn't work for me. If I load Parpax with reflection mapping enabled, I get about 5 single shader builds after running buildcubemaps either with this branch or on master.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work correctly now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not working on my end - with the test in the previous comment I get the same results. The variants with reflective specular enabled are not pre-built.

because the reflection maps will need to be built with it if there's no valid cache or the caching is disabled */
Material tmp = material;

pStage->enableSpecularMapping = false;
pStage->materialProcessor( &tmp, pStage, surface );
pStage->enableSpecularMapping = true;
}

pStage->paddedSize = material.shader->GetSTD140Size();

// HACK: Copy the shaderStage_t and MaterialSurface that we need into the material, so we can use it with glsl_restart
Expand Down
1 change: 0 additions & 1 deletion src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,6 @@ void GLShader::PostProcessUniforms() {
auto iterNext = FindUniformForOffset( uniformQueue, std140Size );
if ( iterNext == uniformQueue.end() ) {
// add 1 unit of padding
ASSERT( !( *iterNext )->_components ); // array WriteToBuffer impls don't handle padding correctly
++std140Size;
++_materialSystemUniforms.back()->_std430Size;
} else {
Expand Down