Jump to content
  • Advertisement
Sign in to follow this  
invicticide

[SlimDX] Sprite has a flickering border

This topic is 3437 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. ;)

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!