Advertisement

Rotating a 2D Sprite with OpenGL, Artifacts Appear Around Border

Started by February 26, 2018 04:58 AM
2 comments, last by JackOfCandles 6 years, 11 months ago

I've got a pretty basic 2D rendering system where I send textured quads to my shaders for sprite rendering. I recently tried to add sprite rotation, but it's giving me really ugly results and I have no idea why. Does anyone know why I might be seeing this result?

Here is what my sprite looks like after being rotated a bit (zoomed in to make it easier to see). You can see the line along the top border that appears:

ldRL4r6.png

This is what the source image looks like. The magenta background is the transparency key:

KO2GtuU.png

 

Sounds like you're sampling your texture with a GL_REPEAT+linear filter. The pixels you see at the top are most likely repeated from the feet because of linear interpolation. Try using GL_CLAMP_TO_BORDER if you don't want that to happen at the top.

Advertisement
1 minute ago, ChuckNovice said:

Sounds like you're sampling your texture with a GL_REPEAT+linear filter. The pixels you see at the top are most likely repeated from the feet because of linear interpolation. Try using GL_CLAMP_TO_BORDER if you don't want that to happen at the top.

Thank you so much, I just tried that and this was exactly the problem!

This topic is closed to new replies.

Advertisement