DirectX 11 Blending works only for the half of the quad

0

I am new to DX11 and am trying to get Blending to work. Below is my output which was not what I expected.

Output

I wanted the entire quad to be the same transparency.

Here is my Blend description:

D3D11_BLEND_DESC    blend_desc;
ZeroMemory(&blend_desc, sizeof(blend_desc));

D3D11_RENDER_TARGET_BLEND_DESC rtbd;
ZeroMemory(&rtbd, sizeof(rtbd));

rtbd.BlendEnable = true;
rtbd.SrcBlend = D3D11_BLEND::D3D11_BLEND_SRC_ALPHA;
rtbd.DestBlend = D3D11_BLEND::D3D11_BLEND_INV_SRC_ALPHA;
rtbd.BlendOp = D3D11_BLEND_OP::D3D11_BLEND_OP_ADD;
rtbd.SrcBlendAlpha = D3D11_BLEND::D3D11_BLEND_ONE;
rtbd.DestBlendAlpha = D3D11_BLEND::D3D11_BLEND_ZERO;
rtbd.BlendOpAlpha = D3D11_BLEND_OP::D3D11_BLEND_OP_ADD;
rtbd.RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE::D3D11_COLOR_WRITE_ENABLE_ALL;
    blend_desc.RenderTarget[0] = rtbd;

hr = m_Device->CreateBlendState(&blend_desc, m_BlendState.GetAddressOf());

My Draw Call:

this->m_Context->ClearRenderTargetView(this->m_RTV.Get(), bgcolor);

m_Context->ClearDepthStencilView(m_DepthStencilView.Get(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);

m_Context->IASetInputLayout(this->m_TriVertexShader.GetInputLayout().Get());

m_Context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY::D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);

m_Context->RSSetState(m_RasterizerState.Get());
m_Context->OMSetDepthStencilState(m_DepthStencilState.Get(), 0);
m_Context->OMSetBlendState(m_BlendState.Get(), NULL, 0xFFFFFFFF);
m_Context->PSSetSamplers(0, 1, m_SamplerState.GetAddressOf());

m_Context->VSSetShader(m_TriVertexShader.GetShader().Get(), NULL, 0);

m_Context->PSSetShader(m_TriPixelShader.GetShader().Get(), NULL, 0);

m_Context->VSSetConstantBuffers(0, 1, m_CB_VS_ConstantBuffer.GetAddressOf());

    m_CB_PS_ConstantBuffer.m_Data.alpha = alpha;
m_CB_PS_ConstantBuffer.ApplyChanges();
m_Context->PSSetConstantBuffers(0, 1, m_CB_PS_ConstantBuffer.GetAddressOf());

m_Context->PSSetShaderResources(0, 1, m_TextureShaderResourceView.GetAddressOf());
m_Context->IASetVertexBuffers(0, 1, m_TriangleVBuffer.GetAddressOf(), m_TriangleVBuffer.StridePtr(), &offset);
m_Context->IASetIndexBuffer(m_TriangleIBuffer.GetBuffer(), DXGI_FORMAT_R32_UINT, 0);

this->m_Context->DrawIndexed(m_TriangleIBuffer.GetBufferSize(), 0, 0);

I tried debugging it, but I could not figure out what was wrong. Here was one screenshot that might help.

[![Debug Output][2]][2] 

Picture at https://i.stack.imgur.com/1nL7o.png

Please let me know if you need any further details.

directx-11
asked on Stack Overflow Feb 23, 2019 by Quicksillver • edited Feb 24, 2019 by Quicksillver

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0