Sign in to follow this  
MasterEvilAce

Overlapping sprites with transparency

Recommended Posts

MasterEvilAce    124
[img]http://dl.dropbox.com/u/3332756/alpha.png[/img]

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
ScottFranks    134
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.

[url="http://msdn.microsoft.com/en-us/library/bb976070.aspx"]http://msdn.microsoft.com/en-us/library/bb976070.aspx[/url]

Share this post


Link to post
Share on other sites
MasterEvilAce    124
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this