启用混合后,为什么会出现此渲染问题?

时间:2018-10-13 09:21:22

标签: rendering direct3d unreal-engine4 alphablending

我想在透明背景上渲染一个立方体。我确实为此启用了混合功能,并尝试为背景设置alpha 0。窗口背景是透明的。如果窗口背景为黑色(黑色不是窗口背景的颜色,我不确定为什么要渲染它),则多维数据集将正常渲染。 当我四处移动时,它的行为就像用白色画笔绘制。有什么帮助吗? picture

struct CD3D11_BLEND_DESC : public D3D11_BLEND_DESC
{
    CD3D11_BLEND_DESC()
    {}
    explicit CD3D11_BLEND_DESC( const D3D11_BLEND_DESC& o ) :
        D3D11_BLEND_DESC( o )
    {}
    explicit CD3D11_BLEND_DESC( CD3D11_DEFAULT )
    {
        AlphaToCoverageEnable = FALSE;
        IndependentBlendEnable = TRUE; //FALSE;
        const D3D11_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc =
        {
             TRUE, //FALSE, // 
             D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, //D3D11_BLEND_SRC_ALPHA, D3D11_BLEND_INV_SRC_ALPHA, D3D11_BLEND_OP_ADD, //
            D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, //
            D3D11_COLOR_WRITE_ENABLE_ALL, //0x0f  // 
        };
        for (UINT i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
            RenderTarget[ i ] = defaultRenderTargetBlendDesc;
    }
    ~CD3D11_BLEND_DESC() {}
    operator const D3D11_BLEND_DESC&() const { return *this; }
};
...
SLATE_BEGIN_ARGS( SViewport )
        : _Content()
        , _ShowEffectWhenDisabled(true)
        , _RenderDirectlyToWindow(true)
        , _EnableGammaCorrection(true)
        , _ReverseGammaCorrection(false)
        , _EnableBlending(true)
        , _EnableStereoRendering(false)
        , _PreMultipliedAlpha(true)  
        , _IgnoreTextureAlpha(false)
        , _ViewportSize(FVector2D(320.0f, 240.0f))
    ...
SceneColorBufferFormat = PF_FloatRGBA;

0 个答案:

没有答案