Fix subtract blending mode

This commit is contained in:
Jack Andersen 2018-01-29 21:49:00 -10:00
parent 5b62fcd826
commit c314730d51
5 changed files with 15 additions and 15 deletions

View File

@ -616,9 +616,9 @@ class D3D11ShaderPipeline : public GraphicsDataNode<IShaderPipeline>
blDesc.RenderTarget[0].BlendEnable = (dstFac != BlendFactor::Zero); blDesc.RenderTarget[0].BlendEnable = (dstFac != BlendFactor::Zero);
if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract) if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract)
{ {
blDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_DEST_COLOR; blDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
blDesc.RenderTarget[0].DestBlend = D3D11_BLEND_SRC_COLOR; blDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
blDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_SUBTRACT; blDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_REV_SUBTRACT;
} }
else else
{ {

View File

@ -748,9 +748,9 @@ class D3D12ShaderPipeline : public GraphicsDataNode<IShaderPipeline>
desc.BlendState.RenderTarget[0].BlendEnable = true; desc.BlendState.RenderTarget[0].BlendEnable = true;
if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract) if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract)
{ {
desc.BlendState.RenderTarget[0].SrcBlend = D3D12_BLEND_DEST_COLOR; desc.BlendState.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA;
desc.BlendState.RenderTarget[0].DestBlend = D3D12_BLEND_SRC_COLOR; desc.BlendState.RenderTarget[0].DestBlend = D3D12_BLEND_ONE;
desc.BlendState.RenderTarget[0].BlendOp = D3D12_BLEND_OP_SUBTRACT; desc.BlendState.RenderTarget[0].BlendOp = D3D12_BLEND_OP_REV_SUBTRACT;
} }
else else
{ {

View File

@ -741,7 +741,7 @@ public:
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFuncSeparate(m_sfactor, m_dfactor, GL_ONE, GL_ZERO); glBlendFuncSeparate(m_sfactor, m_dfactor, GL_ONE, GL_ZERO);
if (m_subtractBlend) if (m_subtractBlend)
glBlendEquation(GL_FUNC_SUBTRACT); glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
else else
glBlendEquation(GL_FUNC_ADD); glBlendEquation(GL_FUNC_ADD);
} }
@ -904,8 +904,8 @@ ObjToken<IShaderPipeline> GLDataFactory::Context::newShaderPipeline
if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract) if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract)
{ {
shader.m_sfactor = GL_DST_COLOR; shader.m_sfactor = GL_SRC_ALPHA;
shader.m_dfactor = GL_SRC_COLOR; shader.m_dfactor = GL_ONE;
shader.m_subtractBlend = true; shader.m_subtractBlend = true;
} }
else else

View File

@ -909,9 +909,9 @@ class MetalShaderPipeline : public GraphicsDataNode<IShaderPipeline>
desc.colorAttachments[0].blendingEnabled = dstFac != BlendFactor::Zero; desc.colorAttachments[0].blendingEnabled = dstFac != BlendFactor::Zero;
if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract) if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract)
{ {
desc.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorDestinationColor; desc.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
desc.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorSourceColor; desc.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOne;
desc.colorAttachments[0].rgbBlendOperation = MTLBlendOperationSubtract; desc.colorAttachments[0].rgbBlendOperation = MTLBlendOperationReverseSubtract;
} }
else else
{ {

View File

@ -2305,9 +2305,9 @@ public:
colorAttachment.blendEnable = m_dstFac != BlendFactor::Zero; colorAttachment.blendEnable = m_dstFac != BlendFactor::Zero;
if (m_srcFac == BlendFactor::Subtract || m_dstFac == BlendFactor::Subtract) if (m_srcFac == BlendFactor::Subtract || m_dstFac == BlendFactor::Subtract)
{ {
colorAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_DST_COLOR; colorAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
colorAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_SRC_COLOR; colorAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
colorAttachment.colorBlendOp = VK_BLEND_OP_SUBTRACT; colorAttachment.colorBlendOp = VK_BLEND_OP_REVERSE_SUBTRACT;
} }
else else
{ {