Archived

This topic is now archived and is closed to further replies.

RelisH

Using transparency with textures

Recommended Posts

RelisH    122
yes, I know that this question has been asked many times, and I searched for it and I''ve tried what the people have suggested. I''ve tried adding SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); and a few other suggested lines before I go into my render loop, but they don''t seem to work. I''m using a 32 bit TGA file that has an alpha channel that has spots all over it so some parts should be transparent and others not. The texture loads fine but then when I run the program, I just have the face spinning around with a texture with no transparency, or in other words fully opaque. Is there something else I must do to ensure that my texture comes out with transparent areas?

Share this post


Link to post
Share on other sites
Nubbinoski    122
does your format have to be targa?

I had the same problem, and then I changed to .PNG and it loaded and displayed with a full range of transparency, without any change in my code.

nubbinoski-

Share this post


Link to post
Share on other sites
DrunkenHyena    805
G''day!

(website flogging time)
On my website (www.drunkenhyena.com) there are a number fo transparency tutorials. The tutorial you''d be most interested in is: http://www.drunkenhyena.com/docs/d3d_tutorial.phtml#DHAlphaChannel since it loads an image with an alpha channel and displays it. You can try replacing the image provided with yours, and see if it displays properly. If it doesn''t, there''s a problem with your image, if it does, peek at the code to see what I did.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
RelisH    122
Wow! Thanks!
it seems it wasn''t working because I was using a TGA, but PNG''s are easier to work with. Thanks for the help Hyena!

Share this post


Link to post
Share on other sites
DrunkenHyena    805
G''day!

Targa files SHOULD work. The main problem with them is that the Targa spec is pretty wide. I''ve had some luck using them, but sometimes the alpha channel gets lost. I like PNG. PNGs are compressed (almost as good as a good quality jpeg) and they can have alpha channels and all that good stuff and I''ve never had a problem using PNGs created by various programs. A nice tight spec is your friend.



Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites