@@ -2034,22 +2034,49 @@ void PBR_Renderer::CreatePSO(PsoHashMapType& PsoHashMap,
20342034 }
20352035 else
20362036 {
2037+ RenderTargetBlendDesc& RT0 = PSOCreateInfo.GraphicsPipeline .BlendDesc .RenderTargets [0 ];
20372038 if (AlphaMode == ALPHA_MODE_OPAQUE ||
20382039 AlphaMode == ALPHA_MODE_MASK)
20392040 {
2040- PSOCreateInfo.GraphicsPipeline .BlendDesc = BS_Default;
2041+ // Default blend state
2042+ RT0.BlendEnable = False;
2043+ RT0.SrcBlend = BLEND_FACTOR_ONE;
2044+ RT0.DestBlend = BLEND_FACTOR_ZERO;
2045+ RT0.BlendOp = BLEND_OPERATION_ADD;
2046+ RT0.SrcBlendAlpha = BLEND_FACTOR_ONE;
2047+ RT0.DestBlendAlpha = BLEND_FACTOR_ZERO;
2048+ RT0.BlendOpAlpha = BLEND_OPERATION_ADD;
2049+ // NB: Do NOT overwrite RenderTargetWriteMask
20412050 }
20422051 else if (AlphaMode == ALPHA_MODE_BLEND)
20432052 {
20442053 VERIFY (!IsUnshaded, " Unshaded mode should use OpaquePSO. The PSOKey's ctor sets the alpha mode to opaque." );
20452054 if (OITLayerCount > 0 )
20462055 {
2047- PSOCreateInfo.GraphicsPipeline .BlendDesc = BS_AdditiveBlend;
2056+ // Use additive blending for OIT
2057+ RT0.BlendEnable = True;
2058+ RT0.SrcBlend = BLEND_FACTOR_ONE;
2059+ RT0.DestBlend = BLEND_FACTOR_ONE;
2060+ RT0.BlendOp = BLEND_OPERATION_ADD;
2061+ RT0.SrcBlendAlpha = BLEND_FACTOR_ONE;
2062+ RT0.DestBlendAlpha = BLEND_FACTOR_ONE;
2063+ RT0.BlendOpAlpha = BLEND_OPERATION_ADD;
2064+ // NB: Do NOT overwrite RenderTargetWriteMask
2065+
2066+ // Disable depth writes, but keep depth testing enabled
20482067 GraphicsPipeline.DepthStencilDesc .DepthWriteEnable = False;
20492068 }
20502069 else
20512070 {
2052- GraphicsPipeline.BlendDesc = BS_PremultipliedAlphaBlend;
2071+ // Premultiplied alpha blending
2072+ RT0.BlendEnable = True;
2073+ RT0.SrcBlend = BLEND_FACTOR_ONE;
2074+ RT0.DestBlend = BLEND_FACTOR_INV_SRC_ALPHA;
2075+ RT0.BlendOp = BLEND_OPERATION_ADD;
2076+ RT0.SrcBlendAlpha = BLEND_FACTOR_ONE;
2077+ RT0.DestBlendAlpha = BLEND_FACTOR_INV_SRC_ALPHA;
2078+ RT0.BlendOpAlpha = BLEND_OPERATION_ADD;
2079+ // NB: Do NOT overwrite RenderTargetWriteMask
20532080 }
20542081 }
20552082 else
0 commit comments