Overlapping sprites with transparency

Started by
2 comments, last by MasterEvilAce 12 years, 1 month ago
alpha.png

Using XNA 4.
I'm rendering a bunch of overlapping sprites to the screen based on a calculated layerDepth.
Any sprites that might conceal the player I draw with a transparent color in the draw function.
Is there a way to prevent visible overlapping edges in this scenario? (See corner block sides "doubling up" against the other transparent pieces)
Basically, I'd like the three partially-transparent walls to look like one object, without seeing the sides of the walls that you wouldn't normally see, if they were fully opaque.
Advertisement
Nice graphics!

Anyway. One possible solution, you generate another 3 'blocks' yet the places where the overlap now you make half the opacity. You could then check when this situation occurs and hence replace the images with the 'half opacity' areas.

That's something I quickly thought up. But having it overlap doesn't look bad at all in my oppinion.
If you are fine with rendering the sprites in a separate SpriteBatch or your RenderMode is Immediate you could alter the alpha blend function. I would suggest min instead of add.

http://msdn.microsoft.com/en-us/library/bb976070.aspx
I need to be able to do this all within one sprite batch, due to render order and performance issues.
I've been looking into BlendStates trying to figure this out, but there is a severe lack of tutorials / understanding on my part. I have to use the XNA "Reach" profile which seems to have some limitations on BlendState settings (unsure if this should affect what i'm trying to achieve.)

Basically, the objective (I believe) is basically to only draw the latest partially-transparent, if there are multiple transparent pixels at the same location. But figuring this out is tough without a good understanding.

This topic is closed to new replies.

Advertisement