Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Blocks, with GL_NEAREST

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


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!

share|improve this question
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
up vote 4 down vote accepted

Well, the simplest way to do it is use a higher-resolution texture, together with a full mip chain, trilinear filtering, and you'll probably want to turn on anisotropic filtering as well; that should give you smooth edges without (as much) over-blurring.

Another approach would be to use distance field textures, which are specifically for two-tone images (in the paper, for text rendering, where the two tones are the text color and transparent). They are able to get sharp, but aliased edges at any level of magnification. This should work for minification too although they only touch on it in the paper.

share|improve this answer
This is the approach I've taken. Thanks for the help. – Isaac Waller Jan 9 '12 at 6:14

If you were to employ post-process antialiasing such as SMAA, it would not differentiate between geometric edges and texel edges. This might be sufficient in conjunction with the nearest neighbor texture filtering.

share|improve this answer
+1 This seems like a good alternative to implementing a more advanced texture filtering algorithm. – David Gouveia Jan 7 '12 at 19:11
Just keep in mind that there is an SMAA method demonstrated that uses a depth buffer to give a greater bias towards geometric edges. Basically you don't want to use that. Determine edges with chroma/luma instead. – ChrisC Jan 7 '12 at 23:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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