Fix graphical issues when batching materials that use Forward Shading for instancing

This commit is contained in:
Wojtek Figat
2025-06-29 13:52:29 +02:00
parent bdd7bae459
commit f126a83b79
3 changed files with 6 additions and 2 deletions

View File

@@ -29,7 +29,7 @@ bool DeferredMaterialShader::CanUseLightmap() const
bool DeferredMaterialShader::CanUseInstancing(InstancingHandler& handler) const
{
handler = { SurfaceDrawCallHandler::GetHash, SurfaceDrawCallHandler::CanBatch, };
return true;
return _instanced;
}
void DeferredMaterialShader::Bind(BindParameters& params)
@@ -114,6 +114,9 @@ void DeferredMaterialShader::Unload()
bool DeferredMaterialShader::Load()
{
// TODO: support instancing when using ForwardShadingFeature
_instanced = _info.BlendMode == MaterialBlendMode::Opaque && _info.ShadingModel != MaterialShadingModel::CustomLit;
bool failed = false;
auto psDesc = GPUPipelineState::Description::Default;
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None;

View File

@@ -65,6 +65,7 @@ private:
private:
Cache _cache;
Cache _cacheInstanced;
bool _instanced;
public:
DeferredMaterialShader(const StringView& name)

View File

@@ -25,7 +25,7 @@ DrawPass ForwardMaterialShader::GetDrawModes() const
bool ForwardMaterialShader::CanUseInstancing(InstancingHandler& handler) const
{
handler = { SurfaceDrawCallHandler::GetHash, SurfaceDrawCallHandler::CanBatch, };
return true;
return false; // TODO: support instancing when using ForwardShadingFeature
}
void ForwardMaterialShader::Bind(BindParameters& params)