Skip to main content

Timeline for Best way to mask 2D sprites in XNA?

Current License: CC BY-SA 3.0

7 events
when toggle format what by license comment
Oct 3, 2012 at 16:54 comment added electroflame Now it works perfectly, thank you! The only thing that I should mention is that if you have your sprites centered (using Width/2 and Height/2 for the origin) you will need to subtract half of your Width or Height for your X and Y locations (that you pass into the shader). After that it works perfectly, and is extremely fast! Thanks a ton!
Oct 3, 2012 at 16:52 vote accept electroflame
Oct 3, 2012 at 4:47 history edited Jim CC BY-SA 3.0
added 7 characters in body
Oct 3, 2012 at 4:40 comment added Jim I see the problem. I should have compiled the pixel shader before sharing it. :P In the maskCoord calculation one of the X's should have been a Y. I've edited my initial answer with the fix and included the UV clamp settings you will need for your MaskTexture sampler.
Oct 3, 2012 at 4:37 history edited Jim CC BY-SA 3.0
added 138 characters in body
Oct 3, 2012 at 1:24 comment added electroflame Thank you for the answer! This seems like it will work, but currently I'm having an issue with it. Currently, it's being cropped on the left of the image (with a straight edge, as well). Am I supposed to be using screen coordinates for the positions? Or am I already supposed to have converted them to 0 - 1?
Oct 3, 2012 at 0:37 history answered Jim CC BY-SA 3.0