1
\$\begingroup\$

http://www.gfycat.com/FlawedLimpingGrizzlybear http://www.gfycat.com/UnawareQuerulousHawk

Every texture and shader has the same problem. It seems like the problem has nothing to do with either.

Tried all the things my friends suggested I should, reimported everything, restarted my machine, nothing seems to work.

\$\endgroup\$
1
\$\begingroup\$

This might be related to using texture atlas techniques combined with mipmapping.

Mipmapping means that you generate scaled down versions of your textures. These are used when looking at textures that are at a far distance or viewed at a sharp angle. The reason for this is that you want to sample a larger area of the texture when looking at it from a distance. For instance, consider using a black-white checkerboard texture. If you look at it from a close distance, you can see the individual tiles. If you look at it from a far distance, the texture will appear uniformly gray, as you cannot distinguish between individual tiles. This is what mipmapping achieves. Without mipmapping, you'll be sampling a single point from your texture, which can cause flickering as you move the camera.

A texture atlas means that multiple textures (eg, different faces of your cube) are stored in the same texture. This is useful to prevent excessive file access operations and texture allocations. Different textures are essentially stored in the same texture, layed out across the texture. Don't worry about the term "texture atlas". Essentially, if all faces of your cube are in the same texture file, you are using an atlas.

When these two techniques are combined a problem can occur for the smaller mipmap levels. As mipmaps are generated by downsizing the original image, it is possible for textures in the texture atlas to bleed into neighbouring textures. For instance, if you have an atlas texture with four different subtextures (eg. a red, green, blue and yellow one), the lowest mipmap level would be the average of all these subtextures.

I believe that this is the effect you're seeing in the image you provided. I'm not very familiar with Unity, but here are some general solutions you could try:

  • Limit the amount of mipmaps generated (in your case, level 4 seems to be the last correct mipmap image). Note that this could cause flickering when looking at the texture from a distance, while moving the camera.
  • Choose a clever alignment of the subtextures in your texture atlas. Mipmaps are generated by scaling down in powers of two. If you align your textures on a 2x2 grid, a 4x4 grid, a 8x8 grid, or any other power of two grid, you should be able to generate higher level mipmaps without bleeding.
  • Add guard spaces inbetween the different textures in your texture atlas. This means that you leave a gaps inbetween the faces of your cube texture. It would be wise to fill these gaps with the same colour as the neighbouring subtextures.
\$\endgroup\$
  • \$\begingroup\$ Apparently it was a Unity bug, I created a new project and moved everything, now the texture bleeding is gone. Thank you for your explanation anyway, it was really informative! \$\endgroup\$ – morbidintel Jul 2 '14 at 2:50
0
\$\begingroup\$

I created a new project, ported everything over. It solves the problem, so I assume it is a Unity bug.

I have no idea how to recreate it though.

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