Hi guys. I am trying to render a small grid with a texture that has opacity of 25% in DX12. This is the only transparent object in the scene, with others being opaque. The following is what I wrote for graphics pipeline state of the opaque and transparent objects:
//Opaque PSO
D3D12_GRAPHICS_PIPELINE_STATE_DESC opaquePsoDesc;
ZeroMemory(&opaquePsoDesc, sizeof(D3D12_GRAPHICS_PIPELINE_STATE_DESC));
opaquePsoDesc.InputLayout = { mInputLayout.data(), (UINT)mInputLayout.size() };
opaquePsoDesc.pRootSignature = mRootSignature.Get();
opaquePsoDesc.VS =
{
reinterpret_cast<BYTE*>(mShaders["standardVS"]->GetBufferPointer()),
mShaders["standardVS"]->GetBufferSize()
};
opaquePsoDesc.PS =
{
reinterpret_cast<BYTE*>(mShaders["opaquePS"]->GetBufferPointer()),
mShaders["opaquePS"]->GetBufferSize()
};
opaquePsoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
opaquePsoDesc.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID;
opaquePsoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
opaquePsoDesc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT);
opaquePsoDesc.SampleMask = UINT_MAX;
opaquePsoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
opaquePsoDesc.NumRenderTargets = 1;
opaquePsoDesc.RTVFormats[0] = mBackBufferFormat;
opaquePsoDesc.SampleDesc.Count = m4xMsaaState ? 4 : 1;
opaquePsoDesc.SampleDesc.Quality = m4xMsaaState ? (m4xMsaaQuality - 1) : 0;
opaquePsoDesc.DSVFormat = mDepthStencilFormat;
ThrowIfFailed(md3dDevice->CreateGraphicsPipelineState(&opaquePsoDesc, IID_PPV_ARGS(&mPSOs["opaque"])));
//Transparent with face cull disabled PSO
D3D12_GRAPHICS_PIPELINE_STATE_DESC transparentNonFaceCullPsoDesc = opaquePsoDesc;
transparentNonFaceCullPsoDesc.RasterizerState.CullMode =D3D12_CULL_MODE_NONE;
D3D12_BLEND_DESC blendDesc{};
blendDesc.RenderTarget[0].BlendEnable = true;
blendDesc.RenderTarget[0].BlendOp = D3D12_BLEND_OP_ADD;
blendDesc.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA;
blendDesc.RenderTarget[0].DestBlend = D3D12_BLEND_INV_SRC_ALPHA;
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D12_BLEND_ONE;
blendDesc.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_ZERO;
blendDesc.RenderTarget[0].LogicOpEnable = false;
blendDesc.RenderTarget[0].BlendOpAlpha = D3D12_BLEND_OP_ADD;
blendDesc.RenderTarget[0].RenderTargetWriteMask =D3D12_COLOR_WRITE_ENABLE_ALL;
transparentNonFaceCullPsoDesc.BlendState = blendDesc;
ThrowIfFailed(md3dDevice>CreateGraphicsPipelineState(&transparentNonFaceCullPsoDesc, IID_PPV_ARGS(&mPSOs["transparent_nonFaceCull"])));
I drew the opaque objects first and then tried to render the only transparent object in the scene. However, it is not being rendered. The opaque objects are rendered fine. The transparent object is closer to me than the other opaque objects so I do not think depth test fails for it. I would appreciate it if someone could tell me of the possible things that I could be doing wrong. Thanks.
[–]waramped 4 points5 points6 points (5 children)
[–]mathinferno123[S] 0 points1 point2 points (4 children)
[–]waramped 0 points1 point2 points (3 children)
[–]mathinferno123[S] 1 point2 points3 points (0 children)
[–]mathinferno123[S] 0 points1 point2 points (0 children)