6
\$\begingroup\$

I'm currently writing a simple voxel engine just to get some practice in, and I'm coming across some odd issues. In order to generate terrain, I create a mesh and then assign UV coordinates on a texture atlas to each vertex. Whenever I run the game, I get strange distortions, like these:

enter image description here

enter image description here

enter image description here

I've tried doing a few things so far:

  • Generating mip maps for the texture atlas.
  • Play around with the max size of the texture atlas.
  • Play around with the format of the texture atlas.

Unfortunately, none of these have worked so far. As of right now, the import settings on the texture atlas itself look like this:

enter image description here

Is there any way I can get rid of these obnoxious distortions?

\$\endgroup\$
  • \$\begingroup\$ I'm not so sure the mipmapping was properly enabled. Because it looks very much like the textures are not mipmapped. gamedev.stackexchange.com/questions/12150/…. I'd suggest making a flat world, so you can get a real good feel for the effect. \$\endgroup\$ – MichaelHouse May 22 '16 at 22:51
  • \$\begingroup\$ Serious question here, but is this unrelated to anisotropic filtering? \$\endgroup\$ – ssb May 23 '16 at 1:10
  • \$\begingroup\$ It might also be worth looking at the shader. You have a low-res pixely aesthetic, but are you achieving it with actually using low-res textures with a shader without texture filtering or are you using high-res textures which just look low-res? \$\endgroup\$ – Philipp May 23 '16 at 6:54
  • \$\begingroup\$ @ssb No, I don't believe so. The import settings on the texture atlas have the filtering mode set to point. \$\endgroup\$ – Ethan Bierlein May 23 '16 at 11:52
  • \$\begingroup\$ @Philipp I am using low-red textures. \$\endgroup\$ – Ethan Bierlein May 23 '16 at 11:53
6
\$\begingroup\$

This distortion pattern is an aliasing artifact caused by point sampling the wrong mip level of a texture. Change the "Filter Mode" from "Point" to bilinear, and make sure to check "Generate Mip Maps". (There is rarely a good reason to disable mip-map generation.) As some have suggested in the comments, anisotropic filtering will work even better to eliminate this kind of artifact.

The problem is caused because at a distance each square in the checkerboard pattern is almost, but not quite, the width of a screen pixel. The pattern of texture samples overlaid on the texture checkerboard pattern gives rise to a new visual pattern. Mip maps and anisotropic sampling will cause the GPU to average together neighboring texels so that distant pixels blend to green instead of generating a pattern.

Here's an article with images that explain what you're seeing: https://paroj.github.io/gltut/Texturing/Tut15%20Anisotropy.html

\$\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.