diff --git a/lib/graphicsdev/D3D11.cpp b/lib/graphicsdev/D3D11.cpp index 35f8d9f..a7afbcf 100644 --- a/lib/graphicsdev/D3D11.cpp +++ b/lib/graphicsdev/D3D11.cpp @@ -616,9 +616,9 @@ class D3D11ShaderPipeline : public GraphicsDataNode blDesc.RenderTarget[0].BlendEnable = (dstFac != BlendFactor::Zero); if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract) { - blDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_DEST_COLOR; - blDesc.RenderTarget[0].DestBlend = D3D11_BLEND_SRC_COLOR; - blDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_SUBTRACT; + blDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; + blDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE; + blDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_REV_SUBTRACT; } else { diff --git a/lib/graphicsdev/D3D12.cpp b/lib/graphicsdev/D3D12.cpp index 010f61a..2460725 100644 --- a/lib/graphicsdev/D3D12.cpp +++ b/lib/graphicsdev/D3D12.cpp @@ -748,9 +748,9 @@ class D3D12ShaderPipeline : public GraphicsDataNode desc.BlendState.RenderTarget[0].BlendEnable = true; if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract) { - desc.BlendState.RenderTarget[0].SrcBlend = D3D12_BLEND_DEST_COLOR; - desc.BlendState.RenderTarget[0].DestBlend = D3D12_BLEND_SRC_COLOR; - desc.BlendState.RenderTarget[0].BlendOp = D3D12_BLEND_OP_SUBTRACT; + desc.BlendState.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA; + desc.BlendState.RenderTarget[0].DestBlend = D3D12_BLEND_ONE; + desc.BlendState.RenderTarget[0].BlendOp = D3D12_BLEND_OP_REV_SUBTRACT; } else { diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index 117b964..a87bc70 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -741,7 +741,7 @@ public: glEnable(GL_BLEND); glBlendFuncSeparate(m_sfactor, m_dfactor, GL_ONE, GL_ZERO); if (m_subtractBlend) - glBlendEquation(GL_FUNC_SUBTRACT); + glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); else glBlendEquation(GL_FUNC_ADD); } @@ -904,8 +904,8 @@ ObjToken GLDataFactory::Context::newShaderPipeline if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract) { - shader.m_sfactor = GL_DST_COLOR; - shader.m_dfactor = GL_SRC_COLOR; + shader.m_sfactor = GL_SRC_ALPHA; + shader.m_dfactor = GL_ONE; shader.m_subtractBlend = true; } else diff --git a/lib/graphicsdev/Metal.mm b/lib/graphicsdev/Metal.mm index 682bd41..a110323 100644 --- a/lib/graphicsdev/Metal.mm +++ b/lib/graphicsdev/Metal.mm @@ -909,9 +909,9 @@ class MetalShaderPipeline : public GraphicsDataNode desc.colorAttachments[0].blendingEnabled = dstFac != BlendFactor::Zero; if (srcFac == BlendFactor::Subtract || dstFac == BlendFactor::Subtract) { - desc.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorDestinationColor; - desc.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorSourceColor; - desc.colorAttachments[0].rgbBlendOperation = MTLBlendOperationSubtract; + desc.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha; + desc.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOne; + desc.colorAttachments[0].rgbBlendOperation = MTLBlendOperationReverseSubtract; } else { diff --git a/lib/graphicsdev/Vulkan.cpp b/lib/graphicsdev/Vulkan.cpp index f4bd0ff..e1d56ad 100644 --- a/lib/graphicsdev/Vulkan.cpp +++ b/lib/graphicsdev/Vulkan.cpp @@ -2305,9 +2305,9 @@ public: colorAttachment.blendEnable = m_dstFac != BlendFactor::Zero; if (m_srcFac == BlendFactor::Subtract || m_dstFac == BlendFactor::Subtract) { - colorAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_DST_COLOR; - colorAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_SRC_COLOR; - colorAttachment.colorBlendOp = VK_BLEND_OP_SUBTRACT; + colorAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; + colorAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE; + colorAttachment.colorBlendOp = VK_BLEND_OP_REVERSE_SUBTRACT; } else {