Texture antialiasing?

In my Minecraft-clone style game, blocks are textured with a border that is lighter then the block color. See picture below:

To achieve this effect without the textures being blurry I use this code:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);


Without setting the MAG_FILTER to GL_NEAREST, it looks like this:

This is ugly and blurry. The upper picture (with GL_NEAREST enabled) is obviously superior. My issue is that the edges in the upper picture are aliased (it is more obvious if you view the photo full-size.)

Is there any way to anti-alias textures? It does not look very good if the borders are aliased like this. Alternatively, is there any way to get rid of the aliasing on the borders?

Thank you for any help!

• Just to be clear, you're talking about the aliasing between the white and gray portions of the textures, not on the outer side of the geomtry, right? Do you have multisampling turned on just in case? – David Gouveia Jan 7 '12 at 18:49
• Exactly. I have 4x antialiasing enabled, so the outside of the geometry is not aliased at all. If you enlarge the first picture you can see that the line between the border and the interior part of the texture is aliased. – Isaac Waller Jan 7 '12 at 18:52
• I think you might have to implement a more advanced type of filtering on the pixel shader. The first resource I've run into was this although I only glanced through it. – David Gouveia Jan 7 '12 at 19:07
• It reads: In this section we look at methods for improving the visual quality of rendered textures using interpolation filters and antialiasing. We also present a method for restoring sharp edges in interpolated textures. So I think it might be what you need. – David Gouveia Jan 7 '12 at 19:08