0

I want to render a cube on a transparent background. I did enable blending for this and tryed to set alpha 0 for background. The window background is transparent. If the window background would be black (the black color is not from the windows background, I am not sure why it's rendering it) , the cube would render normally. When I move around it acts like drawing with a white brush. Any help, please ? 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;
Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • Did you happen to forget to clear your render target each frame? – Michael Kenzel Oct 13 '18 at 13:46
  • The engine is clearing though I dont really understand what is it doing, there are tons of clearing calls, let me search . I think my problem is with the blendstate, I think I need to change it somehow. – warriorforce Oct 13 '18 at 16:02
  • I found the following codes regarding clear render target `if (MobileMultiViewSceneColor && !(MobileMultiViewSceneColor->GetRenderTargetItem().TargetableTexture->GetClearBinding() == DefaultColorClear)) { MobileMultiViewSceneColor.SafeRelease(); }` – warriorforce Oct 13 '18 at 16:05
  • `...SetAndClearViewGBuffer(RHICmdList, Views[0], BasePassDepthStencilAccess, !bDepthWasCleared); ...// clear the render target the first time, re-use afterwards SetRenderTarget(RHICmdList, (*SeparateTranslucency)->GetRenderTargetItem().TargetableTexture, SeparateTranslucencyDepth, bFirstTimeThisFrame ? ESimpleRenderTargetMode::EClearColorExistingDepth : ESimpleRenderTargetMode::EExistingColorAndDepth, FExclusiveDepthStencil::DepthRead_StencilWrite);` – warriorforce Oct 13 '18 at 16:09
  • `SetDefaultColorClear(bUseMonoClearValue ? FClearValueBinding() : FClearValueBinding::Black); SetDefaultDepthClear(bUseMonoClearValue ? FClearValueBinding(ViewFamily.MonoParameters.StereoDepthClip, 0) : FClearValueBinding::DepthFar);` – warriorforce Oct 13 '18 at 16:12

0 Answers0