LEGOlars
Member
Hello
I'm running into an alpha issue when drawing surfaces with semi-transparent sprites inside surfaces and I can't really figure out a clean way to solve this.
I'm drawing a menu with a plain background colour (stretched 1 pixel sprite with colour) and bunch of buttons to surface. These buttons have a shadow, which get created by drawing the button sprite blended in black with 0.5 alpha. Everything works as expected when drawing the surface to the screen. But when I draw this surface onto another surface, the background colour takes the alpha from the shadows of the buttons, and you can suddenly see through the background.
In this image I'm drawing the menu normally (left) and then blended black (right), where the expected result on the right is an entirely black rectangle with no see-through parts.
I'm using a simple green-screen shader ( pass-through shader except changing pixels that has rgba (0,1,0, 1) -> (0,0,0,0) ) to mask out an (animated) portion of the menu surface, so I don't want to disable the entire alpha channel when drawing the surface. I just want to be able to draw semi-transparent sprites on top of the background colour / image without affecting the alpha of the background.
Anyone has ideas for a good solution? Thanks!
I'm running into an alpha issue when drawing surfaces with semi-transparent sprites inside surfaces and I can't really figure out a clean way to solve this.
I'm drawing a menu with a plain background colour (stretched 1 pixel sprite with colour) and bunch of buttons to surface. These buttons have a shadow, which get created by drawing the button sprite blended in black with 0.5 alpha. Everything works as expected when drawing the surface to the screen. But when I draw this surface onto another surface, the background colour takes the alpha from the shadows of the buttons, and you can suddenly see through the background.
In this image I'm drawing the menu normally (left) and then blended black (right), where the expected result on the right is an entirely black rectangle with no see-through parts.
I'm using a simple green-screen shader ( pass-through shader except changing pixels that has rgba (0,1,0, 1) -> (0,0,0,0) ) to mask out an (animated) portion of the menu surface, so I don't want to disable the entire alpha channel when drawing the surface. I just want to be able to draw semi-transparent sprites on top of the background colour / image without affecting the alpha of the background.
Anyone has ideas for a good solution? Thanks!
Last edited: