🔒 Locked
Transparent rendered texture
Advertisement
Original Post
How about setting the alpha to 0 and using alphablending?
I read an article that just explained the way of doing this but didnt show any code for it.
Firstly the texture must be a 4 channel RGBA texture. And then before drawing the 3D object I clear the screen with a 0 alpha clear color. And lastly I copy the vieport using glCopyTexImage2D with GL_RGBA mode. But It still doesnt work!?
Firstly the texture must be a 4 channel RGBA texture. And then before drawing the 3D object I clear the screen with a 0 alpha clear color. And lastly I copy the vieport using glCopyTexImage2D with GL_RGBA mode. But It still doesnt work!?
I''ll try and put you on the right track.
You really need to create an ALPHA map, which is basically just an 8 bit texture used to store transparency values. You can do this by going through your data manually and for a black pixel, on your alpha map have a value of 0.0, and for any over value have the alpha of 1.0. You could write some code to find the edges of your texture and have an alpha of say 0.5, thus you won''t have ultra sharp unrealistic edges.
The easiest way to do this is propably to copy your RGB texture into a RGBA texture and the process the fourth byte of each pixel as I describe above.
I hope I have at least been of some help.
You really need to create an ALPHA map, which is basically just an 8 bit texture used to store transparency values. You can do this by going through your data manually and for a black pixel, on your alpha map have a value of 0.0, and for any over value have the alpha of 1.0. You could write some code to find the edges of your texture and have an alpha of say 0.5, thus you won''t have ultra sharp unrealistic edges.
The easiest way to do this is propably to copy your RGB texture into a RGBA texture and the process the fourth byte of each pixel as I describe above.
I hope I have at least been of some help.
isn''t that extremly slow???
first copy the texture from AGP memory to system mem - then pass over it - send it back (i bet this takes 50% of the frame time)
Doesn''t the frame buffer have an alpha channel ? If so clear it with alpha 0.0 and render with alpha 1.0 . Or you could use a PBUFFER.
[ My Site ]
''I wish life was not so short,'' he thought. ''Languages take such a time, and so do all the things one wants to know about.'' - J.R.R Tolkien
/*ilici*/
first copy the texture from AGP memory to system mem - then pass over it - send it back (i bet this takes 50% of the frame time)
Doesn''t the frame buffer have an alpha channel ? If so clear it with alpha 0.0 and render with alpha 1.0 . Or you could use a PBUFFER.
[ My Site ]
''I wish life was not so short,'' he thought. ''Languages take such a time, and so do all the things one wants to know about.'' - J.R.R Tolkien
/*ilici*/
Not just loading, making a already existing texture transparent.
I still havent been able to make it transparent
I think that when i use glCopyTexImage2D to copy the framebuffer to a texture its background should also be alpha 0 when the background is cleared with alpha 0.... But no no
I still havent been able to make it transparent
I think that when i use glCopyTexImage2D to copy the framebuffer to a texture its background should also be alpha 0 when the background is cleared with alpha 0.... But no no
Maybe a stupid question, but you might have overlooked it, so I''ll ask it anyway
Did you use an internal-format in glCopyTexImage2d of RGBA or equivalent? If not, the alpha value wouldn''t be returned, would it?
Hellsp4wn
-----------
I''m having deja-vu and amnesia at the same time. It''s like I think I''ve forgotten this before.
Did you use an internal-format in glCopyTexImage2d of RGBA or equivalent? If not, the alpha value wouldn''t be returned, would it?
Hellsp4wn
-----------
I''m having deja-vu and amnesia at the same time. It''s like I think I''ve forgotten this before.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement