3
\$\begingroup\$

With my research I have found that using a VBO to render graphics is much faster than using depreciated OpenGL. I've found with this that you can't switch textures mid VBO render, so if I have multiple objects in a single VBO, they all have to use the same texture. I solved this problem by using a texture atlas to combine multiple textures together into one texture used throughout the whole VBO.

Now all this works perfectly. It's fast, it's efficient, and it looks good until you turn on SFML's anti-aliasing. If you look at the pictures, it appears that it's merging textures in the texture atlas at a distance. These pictures should help clear up what that means.

Without Anti-Aliasing: enter image description here

With Anti-Aliasing: With anti-aliasing

The Atlas Map as it looks in memory:

enter image description here

Also if it helps, I experimented with adding blank space between these individual textures to see if that would hide the problem. The problem persists, only it makes objects far away appear translucent because of the alpha between the textures.

\$\endgroup\$
  • 3
    \$\begingroup\$ The VBO has nothing to do with this problem; it's fundamentally an issue with texture atlas + mip-mapping. Just so that you know the right terms for the issue you're running into. :) \$\endgroup\$ – Trevor Powell May 21 '16 at 23:48
  • \$\begingroup\$ Makes sense. I just included the VBO because it's part of the system I've made here. So it's a problem with the texture atlas an mip-mapping? Do you know where I can find a lead on that? \$\endgroup\$ – That Crazy Carl Guy May 22 '16 at 1:11
  • \$\begingroup\$ What you want is to clamp texture sampling to be within a single texture. Since you are using atlas builtin wrapping modes won't do it for you. I think you need to define your own clamp-to-edge in shaders. (Not sure about sfml capabilities though...) \$\endgroup\$ – Andreas May 22 '16 at 9:43
  • 1
    \$\begingroup\$ Instead of using an atlas, you can use a texture array (particularly easy because all of your images seem the same size) and all of these problems just go away. \$\endgroup\$ – Maximus Minimus Aug 15 '16 at 19:46
  • 1
    \$\begingroup\$ @LeComteduMerde I gave that a shot and it works WAY better! Thanks for the advice. \$\endgroup\$ – That Crazy Carl Guy Sep 16 '16 at 17:05
2
\$\begingroup\$

Sure took long enough to solve this, but the cause of the problem was SFML's anti-aliasing shader script. I kind of knew that was the problem all along, but didn't know how to fix it. The solution was to simply write my own shader script for anti-aliasing (which is designed to work with an atlas map) and disable mip-maps.

I got the general idea of how to do it from here: How do I implement anti-aliasing in OpenGL?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.