• Advertisement
Sign in to follow this  

Render to texture with alpha transparency

This topic is 4340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I follow the DirectX samples and implements render to texture using SetRenderTarget. Everything went fine until I added textures with alpha transparency... The transparency does not work anymore! If I render direct to the screen buffer, it works fine. I set up the surface texture by using CreateTexture( ScreenWidth, ScreenHeight,1,RENDERTARGET, FMT_A32B32G32R32F, D3DPOOL_DEFAULT, &m_pSurface,NULL); Do I have to set up the surface different in order to get transparency works? Any help is appriciated ;) Thanks

Share this post


Link to post
Share on other sites
Advertisement
Have you set up the appropriate render states and texture states as well? Check out a quick tutorial here on CodeSampler - it should get you up and running in no time at all.

Share this post


Link to post
Share on other sites
Thanks for the fast reply. I have double checked the render states and they seem to be fine. The problem only happens when I try to render the scene to a texture surface by using SetRenderTarget(0, &pTextureSurface). That's why I wonder if I set up the surface incorrectly or there is some extra depth buffer I need to set up for the surface to store the depth values so the alpha transparency would work. Also, is there any D3D function acts like glCopyTexSubImage2D which might fix this problem.

Share this post


Link to post
Share on other sites
32 bit per component FP formats don't support blending on NVIDIA hardware (only 16 bit per component). Don't have the ATI info at hand.

Share this post


Link to post
Share on other sites
Quote:
Original post by ET3D
32 bit per component FP formats don't support blending on NVIDIA hardware (only 16 bit per component). Don't have the ATI info at hand.
Agreed - Drop back to FP16 and you should be sorted [smile]

As for ATI... From the info I have, the X1k series supports FP16 blending the same as Nvidia, earlier models support NO blending. No currently available hardware supports FP32 blending.

Bare in mind that it is possible to implement it as a shader if you really need it. In my code it knocked about 25% performance though [lol]

Jack

Share this post


Link to post
Share on other sites
I tried several format like FMT_A16B16G16R16F and A8B8G8R8 for my rendering target surface texture. I also drop back the AutoDepthStencilFormat to D3DFMT_D16. But the transparency still doesn't work while I try to render it to the texture surface. The steps I take to render to the surface is:

1. Create The Surface texture.
2. Get the original render target( which is render to screen directly).
3. SetRenderTarget to the surface texture
4. Clean surface
5. draw objects ( some shader is applied while drawing them)
6. SetRenderTarget back to screen
7. Render Texture to a quad that covers the whole screen.

I feel like I must set up something wrong or missing some steps, which is vital for the transparency to work.



Share this post


Link to post
Share on other sites
Make sure alpha blending is set, and make sure you're clearing the render target to a value that has transparent alpha. The latter mistake is very common (using D3DCOLOR_XRGB to clear).

Share this post


Link to post
Share on other sites
Yes, check if the aplha channel is cleared. Leaving the alpha set is
the kind of silly mistake I tend to do. :)

I once met a similar problem.
http://www.gamedev.net/community/forums/topic.asp?topic_id=380688

Share this post


Link to post
Share on other sites
I just tried some different Clear function and change the color of it. And it turns out the transparency texture shows the color of the clean color. I did render the background first then the transparent part second that the transparent should show the background color not the clear part. But it might give a good clue on what I missed or did wrong. Again this only happens when I render it to a texture surface which makes me think somethig is wrong when I set up the surface.


[Edited by - jayhs on April 5, 2006 5:12:05 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement