Add support for sampling Scene Color in transparent materials (forward pass)

This commit is contained in:
Wojtek Figat
2022-04-12 21:48:52 +02:00
parent c99793d2a4
commit e32ad93020
6 changed files with 17 additions and 21 deletions

View File

@@ -70,7 +70,7 @@ void ForwardMaterialShader::Bind(BindParameters& params)
MaterialParameter::BindMeta bindMeta;
bindMeta.Context = context;
bindMeta.Constants = cb;
bindMeta.Input = nullptr; // forward pass materials cannot sample scene color for now
bindMeta.Input = params.Input;
bindMeta.Buffers = params.RenderContext.Buffers;
bindMeta.CanSampleDepth = GPUDevice::Instance->Limits.HasReadOnlyDepth;
bindMeta.CanSampleGBuffer = true;

View File

@@ -400,11 +400,13 @@ void MaterialParameter::Bind(BindMeta& meta) const
{
case MaterialSceneTextures::SceneDepth:
view = meta.CanSampleDepth
? (GPUDevice::Instance->Limits.HasReadOnlyDepth ? meta.Buffers->DepthBuffer->ViewReadOnlyDepth() : meta.Buffers->DepthBuffer->View())
? meta.Buffers->DepthBuffer->GetDescription().Flags & GPUTextureFlags::ReadOnlyDepthView ? meta.Buffers->DepthBuffer->ViewReadOnlyDepth() : meta.Buffers->DepthBuffer->View()
: GPUDevice::Instance->GetDefaultWhiteTexture()->View();
break;
case MaterialSceneTextures::AmbientOcclusion:
case MaterialSceneTextures::BaseColor:
case MaterialSceneTextures::DiffuseColor:
case MaterialSceneTextures::SpecularColor:
view = meta.CanSampleGBuffer ? meta.Buffers->GBuffer0->View() : nullptr;
break;
case MaterialSceneTextures::WorldNormal: