I have a 2D game (C#, XNA) that uses a 3D effect. Below you can see a battle against 3 pigs. These pigs look 2D but they are actually drawn using 3D quads. This is so I can invoke a tilting effect (when they get hit, they tilt back as if they are wooden cut outs).
I have noticed recently that when they are drawn in the neutral position, there is a strange and
inconsistent graphical artifacting bug that occurs sometimes. What’s odd is that, after many experiments, I’ve found that the artifacting is related to WHERE the pigs are drawn on the spritesheet.
In the below image, you can see where each pig comes from within the spritesheet. The first pig has a lot of artifacting around the feet, the second not so much, and the third one is perfect. These pigs are the same in every way except where they are drawn from the spritesheet (which is 1024x1024 png). So far I the artifacting appears more severe when a the sprite rect is close to an edge, but I’m not entirely sure.
Strange huh? I fear that this isn’t something that I will solve and the best solution I have is to just draw these pigs using the regular spritebatch while they are in the neutral position and switch them back to 3D when they are tilting. But I thought it was worth posting here in case any obvious solution jumps out to anyone.
Here is the most relevant code (removed are the many functions that handle the tilt effect).
(I kept the below images in their native resolution, which is very small and difficult to see the artifacting I’m referring to. But I didn’t want to create additional confusion by scaling them for visibility.)
Update: Here I replaced the pigs with checkerboard (black and white 1px with green outline issues) and the issue becomes clearer. You can see a triangle where things are getting stretched here. Again, the third grid is perfect just like the third pig was perfect and the issue somehow relates to where images are placed on the png. And any idea you come up with would have to explain this difference.