• Advertisement
Sign in to follow this  

Edit texture (alpha channel)

This topic is 3024 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 I'm trying to change the alpha channel of a texture (for example poke holes into it) in order to make the texture appear transparent in some areas. What's the best approach for this? Can this be done without moving the texture between system and GPU memory every time the operation is done? Any help would be appreciated

Share this post


Link to post
Share on other sites
Advertisement
Yeah the obvious way is to simply edit the pixels using your CPU and re-upload the modified texture back to the GPU, but this would be slow, and waste system-RAM.

You should be able to set up your (GPU) texture as a "render target", which allows you to render primitives to that texture, instead of to the frame buffer.

To poke a hole in the texture, all you need to do is render a circle with an alpha-value of zero (and with alpha-blending/testing disabled!) to that render target.

Share this post


Link to post
Share on other sites
Hi, I need to bump this

I'm currently using FBO to render the main_texture to fbo_texture. After that I poke all the necessary holes into the fbo_texture by drawing transparent shapes. Now I draw the new fbo_texture on the screen. Everything works.

The problem: How can I use the edited (full of holes) fbo_texture as a main_texture, so that if I draw the next frame, all the changes would not be lost?

I have tried simply assigning the value of the fbo_texture to the main_texture after the image has been drawn to the FBO, but this gives me a white screen.

Do I somehow need to copy the fbo_texture after the fbo drawing is finished for this frame?

Share this post


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

  • Advertisement