• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Shaders how do I draw semi-transparent sprites inside surfaces that are inside other surfaces? *SOLVED*

LEGOlars

Member
Hello :D

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.

alpha_problem.png
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:
Top