[SlimDX] Sprite has a flickering border

Started by
3 comments, last by invicticide 15 years, 3 months ago
I have a source image as a sprite sheet that's laid out with 1-pixel borders around all the frames. I draw one frame at a time for an entity... pretty standard old-school 2D animation stuff here. If I have a stationary entity animate through its frames, everything looks fine. If that entity is moving while animating, the frame's border flickers on and off during the move. The border is outside the subrectangle I'm using to grab from the source image, and what I see is the frame's color at half-alpha. I suspect there's something going on with texture filtering when the sprite's location is sub-pixel (e.g. 'x = 10.5' as opposed to just 'x = 10') and it's blending the border pixels into the sprite subrectangle. I've been poking around in the docs for some way to disable filtering, or something along those lines, but it's proving fruitless. Perhaps I fail at searching docs. :( Any suggestions? P.S. I did try quantizing the sprite's position to the nearest pixel before drawing; that works, but the movement isn't as smooth. There are occasional, slightly-noticeable hitches when the sub-pixel position rounds to the same pixel two frames in a row. So I'd like to try to resolve this without resorting to this method. P.P.S. I would just paint zero-alpha over the frame pixels in the source image, but a) I have a separate, very retarded problem with color comparisons (we'll not get into that here) and b) it would just be hiding a problem rather than solving it... and I'd like to solve it if it all possible. ;)
Advertisement
Are you using the Sprite object to draw your sprites, or are you doing the rendering by hand using quads? If the latter, I might try setting texture filtering to nearest, although I'm not entirely sure how it works for the Sprite interface.
Mike Popoloski | Journal | SlimDX
I'm using the Sprite object to draw them. So that's the problem, I guess... I have no idea how to access any texture filtering properties this way. :(
Your problem sounds very odd though. Translating the sprite shouldn't translate the texture coordinates at all. You might want to do a search for the same problem in XNA, since its Sprite interface is mostly the same.
Mike Popoloski | Journal | SlimDX
Umm... now I'm not so sure it *is* translating texture coordinates. It seems to be doing some full-scene antialiasing, maybe? If I take one sprite and put it over another one, there's a blended border around the front sprite that doesn't exist in that sprite's RGB or alpha data.

This makes me wish I actually knew how to use DirectX, before starting to use SlimDX. :P

This topic is closed to new replies.

Advertisement