Jump to content

  • Log In with Google      Sign In   
  • Create Account


Transparent background for render targets


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Daenyx   Members   -  Reputation: 104

Like
0Likes
Like

Posted 10 July 2013 - 11:04 PM

Hello everyone,
 
I'm a beginner on directx 9 programming and I have a problem regarding render targets where I wanted to set the backgound to be transparent (transparent to the backbufffer). I used the Clear method and used D3DCOLOR_ARGB where I set the Alpha value to 0. I also have my render target to have a A8R8G8B8 format but the clear ignores the transparency. And when I take the Clear code away, the background messes up with some lines on it. Here is my code:

3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 1.0f, 0  );

Here is how I set up my render target:

pd3dDevice->CreateTexture( 400, 400, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pTextureTarget, 0);
m_pTextureTarget->GetSurfaceLevel( 0, &m_pSurfaceTarget );

3dDevice->SetRenderTarget( 0, m_pSurfaceTarget );

    
3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 1.0f, 0  );

I'm just not sure if I'm missing something. Hopefully, you guys could help out. If you need more info please just ask.


Edited by Daenyx, 10 July 2013 - 11:05 PM.


Sponsor:

#2 Hodgman   Moderators   -  Reputation: 27454

Like
0Likes
Like

Posted 11 July 2013 - 12:23 AM

That code should be binding your render target and clearing it fine. I assume the next step is that you draw some things into the render target (with alpha values greater than 0), and then you somehow composite this render-target over the top of the back-buffer.

What does that compositing step look like?



#3 imoogiBG   Members   -  Reputation: 1016

Like
0Likes
Like

Posted 11 July 2013 - 04:38 AM

You must enable blending operations. If they are turned off the alpha channel is ignored


Edited by imoogiBG, 11 July 2013 - 04:38 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS