Hey everyone. I’m going crazy here. I have what I would consider a normal sized terrain (2000x2000) and any texture that I apply to it shows fine in the unity engine but when on device (iPhone 5) it appears pixelated and glitchy for lack of better terms. Here is what I have tried and it still does this to varying degrees:
- Turn off Mipmaps on the texture
- Remove all compression from texture.
- Create a new project
- Change render settings and quality
- Tried turning down tiling
- Tried applying same texture to a regular mesh object the same size
The only thing I can find out there on the internets or forums is one person’s attempt to fix the issue on an Android which everyone seems to think is the issue (tegra). I know for a fact this wasn’t happening in older versions of unity or iPhone. The only thing I have been able to find is someone saying to either lower the tiling amount or increase the precision on the material but I have absolutely no Idea how to do that or if it will even work.
I’m hopeing that someone out there will have come across this issue and a fix for it. I mean, it essentially renders any unity game with a large-ish terrain or world pointless.
Thanks in advance.
You are running out of precision for your texture coordinates. Minimum precision for highp in OpenGL ES is 16-bits. It can be more, but there are no guarantees. With that precision you can only specify a few digits (technically it’s powers of two not “digits” but you get the idea). It’s fine if you are between 0 and 1; you have lots of decimal places. But once your texture has looped 1000 times, you may only get one or two (very imprecise) digits after the decimal. Those imprecise digits are what’s making your terrain glitchy and blocky.
You can break your geometry into smaller chunks. Look into using a floating origin (occasionally re-center your player at 0,0 and shift the world to compensate). Lots of other things start to get weird due to similar precision problems once you get too far from 0. I don’t use terrains much so I’m not familiar with the technical details of using a grid of terrains in place of one large one.
A band-aid solution is to use a larger texture. A larger texture will take longer to build up the loop count. You can also decrease the tiling; your texture will be a bit blurrier but it will stretch farther.
There is no simple “fix”. This is a graphics driver trade-off made to improve the performance of the hardware in the general case. You rarely have situations where the texture coordinates get this high. 99% of the time they are between 0 and 1 so you don’t want to waste precious hardware resources with excessive precision that developers will rarely use. However, when you do need it, it is a pain that you have to work around.
Thank you for the in depth explanation. Indeed, making the terrain much smaller, something around 200x200 instead of 2,000x2,000 did decrease the blocky effect to almost nothing. I can live with this. Thanks to you, I now know more about WHY it is doing this so that I know that decreasing the size of my terrain and having it work isn’t just a fluke. Knowing why and not having a simple “fix” is much better than spinning my wheels trying to figure it all out.
Thanks again!