我是DX11的新手,正在尝试使Blending正常工作。下面是我的输出,这不是我期望的。
我希望整个四边形具有相同的透明度。
这是我的Blend描述:
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());
我的抽奖电话:
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);
我尝试调试它,但是我无法弄清楚出了什么问题。这是一个可能有用的屏幕截图。
[![Debug Output][2]][2]
https://i.stack.imgur.com/1nL7o.png上的图片
如果您需要更多详细信息,请告诉我。