I was watching a youtube video of JamesTKhan about importing GLTF files into LibGDX and there he mentioned in passing how to activate anti-aliasing in the desktop version.

This was a little piece of knowledge I had never came across before. It takes just a few seconds to add, literally one line of code, and if really improves the visual quality by gettig rid of those jagged edges. Or at least on the desktop version.

If you are running LibGDX using LWGL2 just add set config.samples to, for example, 4 to use anti-aliasing. I supposed you can put the number higher at some performance cost.

public class DesktopLauncher {
	public static void main (String[] arg) {
		LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
		config.samples = 4;
		new LwjglApplication(new Main(), config);
	}
}

With the newer versions of LibGDX based on LWGL3 it is slightly more complicated, but still only a one-liner: use config.setBackBuffer(). The last value sets the samples to use. (The other values are bits for red, green, blue, alpha, depth and stencil respectively).

public class DesktopLauncher {
	public static void main (String[] arg) {
		Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
		config.setBackBufferConfig(8, 8, 8, 8, 16, 0, 4);		// anti-aliasing 4 samples
		new Lwjgl3Application(new Main(), config);
	}
}

The following pictures show the before and after shots:

samples

Happy coding!

[1]Importing 3D Models From Blender to libGDX with gdx-gltf


<
Previous Post
Isometric projection
>
Next Post
Post Mortem - Under the Sea