Graphics: Fix blending (temporary fix until frame graph handles it)
This commit is contained in:
parent
d475bbd4a2
commit
b8b0552a4e
|
|
@ -34,7 +34,7 @@ namespace Nz
|
|||
Graphics(Config config);
|
||||
~Graphics();
|
||||
|
||||
inline const std::shared_ptr<RenderPipeline>& GetBlitPipeline() const;
|
||||
inline const std::shared_ptr<RenderPipeline>& GetBlitPipeline(bool transparent) const;
|
||||
inline const std::shared_ptr<RenderPipelineLayout>& GetBlitPipelineLayout() const;
|
||||
inline const DefaultTextures& GetDefaultTextures() const;
|
||||
inline const std::shared_ptr<AbstractBuffer>& GetFullscreenVertexBuffer() const;
|
||||
|
|
@ -73,6 +73,7 @@ namespace Nz
|
|||
std::shared_ptr<AbstractBuffer> m_fullscreenVertexBuffer;
|
||||
std::shared_ptr<RenderDevice> m_renderDevice;
|
||||
std::shared_ptr<RenderPipeline> m_blitPipeline;
|
||||
std::shared_ptr<RenderPipeline> m_blitPipelineTransparent;
|
||||
std::shared_ptr<RenderPipelineLayout> m_blitPipelineLayout;
|
||||
std::shared_ptr<VertexDeclaration> m_fullscreenVertexDeclaration;
|
||||
DefaultTextures m_defaultTextures;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
namespace Nz
|
||||
{
|
||||
inline const std::shared_ptr<RenderPipeline>& Graphics::GetBlitPipeline() const
|
||||
inline const std::shared_ptr<RenderPipeline>& Graphics::GetBlitPipeline(bool transparent) const
|
||||
{
|
||||
return m_blitPipeline;
|
||||
return (transparent) ? m_blitPipelineTransparent : m_blitPipeline;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<RenderPipelineLayout>& Graphics::GetBlitPipelineLayout() const
|
||||
|
|
|
|||
|
|
@ -386,15 +386,23 @@ namespace Nz
|
|||
{
|
||||
builder.SetScissor(renderRegion);
|
||||
builder.SetViewport(renderRegion);
|
||||
builder.BindPipeline(*graphics->GetBlitPipeline());
|
||||
builder.BindPipeline(*graphics->GetBlitPipeline(false));
|
||||
builder.BindVertexBuffer(0, *graphics->GetFullscreenVertexBuffer());
|
||||
|
||||
bool first = true;
|
||||
|
||||
for (const ViewerData* viewerData : viewers)
|
||||
{
|
||||
const ShaderBindingPtr& blitShaderBinding = viewerData->blitShaderBinding;
|
||||
|
||||
builder.BindShaderBinding(0, *blitShaderBinding);
|
||||
builder.Draw(3);
|
||||
|
||||
if (first)
|
||||
{
|
||||
builder.BindPipeline(*graphics->GetBlitPipeline(true));
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.EndDebugRegion();
|
||||
|
|
|
|||
|
|
@ -164,15 +164,6 @@ namespace Nz
|
|||
|
||||
RenderPipelineInfo pipelineInfo;
|
||||
|
||||
// Alpha blending
|
||||
pipelineInfo.blending = true;
|
||||
pipelineInfo.blend.modeColor = BlendEquation::Add;
|
||||
pipelineInfo.blend.modeAlpha = BlendEquation::Add;
|
||||
pipelineInfo.blend.srcColor = BlendFunc::One;
|
||||
pipelineInfo.blend.dstColor = BlendFunc::One;
|
||||
pipelineInfo.blend.srcAlpha = BlendFunc::One;
|
||||
pipelineInfo.blend.dstAlpha = BlendFunc::One;
|
||||
|
||||
pipelineInfo.pipelineLayout = m_blitPipelineLayout;
|
||||
pipelineInfo.shaderModules.push_back(std::move(blitShader));
|
||||
pipelineInfo.vertexBuffers.assign({
|
||||
|
|
@ -182,7 +173,18 @@ namespace Nz
|
|||
}
|
||||
});
|
||||
|
||||
m_blitPipeline = m_renderDevice->InstantiateRenderPipeline(std::move(pipelineInfo));
|
||||
m_blitPipeline = m_renderDevice->InstantiateRenderPipeline(pipelineInfo);
|
||||
|
||||
// Blending
|
||||
pipelineInfo.blending = true;
|
||||
pipelineInfo.blend.modeColor = BlendEquation::Add;
|
||||
pipelineInfo.blend.modeAlpha = BlendEquation::Add;
|
||||
pipelineInfo.blend.srcColor = BlendFunc::SrcAlpha;
|
||||
pipelineInfo.blend.dstColor = BlendFunc::InvSrcAlpha;
|
||||
pipelineInfo.blend.srcAlpha = BlendFunc::SrcAlpha;
|
||||
pipelineInfo.blend.dstAlpha = BlendFunc::InvSrcAlpha;
|
||||
|
||||
m_blitPipelineTransparent = m_renderDevice->InstantiateRenderPipeline(std::move(pipelineInfo));
|
||||
}
|
||||
|
||||
void Graphics::BuildDefaultTextures()
|
||||
|
|
|
|||
Loading…
Reference in New Issue