I am building something for Android. Everything seems fine until one day I notice a “pixelation” on the ground texture.
Not sure how this come about, I tried to play around with the mipmaps without luck. I decided to remove all texture but leave one to see what happen.
Apparently up to certain area, the same texture seems to pixelize/show boxes. The area of the map is 500x500 but this separation from “good” looking into bad seems to happen around 60% through. It happens only in Android device (Galaxy Note). Running it on Editor seems fine. Any clue why this is happening?
Same problem here, it happens because the gpu of the device doesn’t use enough precision for the multiple times tiled textures’ uv-coordinates. I have tried to tile them less, edit the terrain shader, resize the texture, and edit other terrain settings, but still always pixelation and jitter:(
Odd thing is that every second texture assigned to the terrain looks a bit better.
Here the textures marked with ‘x’ look a lot worse than the others, these look just some weird rectangles glitching…
It seems to be always the first, third and so on, that look worse.
Here is pic of the “better” textures (the second and fourth) on Galaxy Tab 7.0 Plus GT-P6210
Still some jitter and pixelation though…
The textures are a bit blurry as i tried to tile them less to see if it helps…
Does anyone have found a way to fix this? The “worse” textures look so bad that they are useless, and with only 2 textures the terrain will look a bit boring. (and assigning over 4 textures and using only the better looking will cause unnecessary draw calls and triangle count will go up)
After investigating this problem more I found that the textures’ pixelation scales from the Terrain’s origin as you can see from the following screenshots. The car is aligned to same direction in every pic - front pointing to Z-Axis.
This is from the terrain pivot, no pixelation or any jitter. Here everything works well, but after like couple of hundred meters the problems starts:
This is the diagonal corner from the pivot, pixelation and jitter are worst here, and the rectangles biggest (they scale as squares along the diagonal from the pivot):
I tried to split the terrain to 4 smaller terrains but the pixelation and jitter were still almost as bad:(
Can the accuracy of the uv’s be improved somehow? Or can the uv coordinate’s value be “reseted” to 0 on every start of a new terrain “chunk”/the-area-where-the-tiled-textures-are-used, I mean calculating the uv’s on each chunk individually so they wouldn’t get so high. (I don’t know much about uv mapping so this could be a stupid question…)
With the “chunk” i mean this area:
Hey, found a trick that helps a bit.
Setting the offset on the terrain’s splat textures to negative half of the terrains dimensions will make the center area of the terrain look better (same like the pivot point with 0 offsets). For example my terrain is 2000x2000, so I set the offsets on all terrain textures to -1000. And in your -pssoft7- case you would set the offsets to -250, also if you can use bigger texture and tile it less it helps a bit. (Of course this helps only if your main playing area is more in the center of the map instead of the edges)
Thanks for the info elias_t, but isn’t the terrain generated on load from the heightmap, so the vertex colors would need to be painted on runtime/start with some script/shader or something, right?
Ok, hope it works, I can post here if I found anything that helps more
I am using mesh terrain, split in pieces (to reduce even more the accuracy issues). The vertex colors/alpha is done in the editor. The vertex colors then are used by the shader as a splatmap.
adjusting offset is still not satisfying me. I still can see some pixelation (but more uniform) in my second texture.
It’ll be great if you could share links to tutorials like what you did, elias_t.
Yes, I noticed after more testing that the offset thing didn’t work so well as it seemed first, the problems “moved” a bit though…
By the way how many textures you need on your terrain? Because if you only need 2 you can assign some 32x32 textures on the 1st and 3rd slot in the terrain and use only the 2nd and 4th.
I also got an idea now to make some low res textures that have almost no contrast, like one color only. And then use those in the 1st and 3rd slot, and paint them to give some color on top of the better textures. I try the result soon on my device to see if it works.
Edit:
Hey, great news pssoft7 the low contrast color texture fix works great!
Here’s how it looks with 512x512 normal texture, not good at all:
And here with 32x32 low contrast texture (almost one color) in the same place, no pixelation problems at all! (the contrast is from cliff texture that is blended with the “sand color texture”):
Here’s what I did to get it like that.
take a normal terrain texture (that is assigned in the terrain in 1st or 3rd slot)
edit it with image editor to make it have almost none details (or just paint an empty texture with some color, but I did it like this…)
import it in Unity with 32x32 resolution (actually this could be all that is needed, as it will blur the texture maybe enough, but I’m not sure)
add it to the terrain (on 1st or 3rd slot in the splat textures)
paint it on top of the 2nd or 4th texture with lowered opacity (if you paint with 100% opacity it looks just a plain color)
Of course you won’t get details from the 1st and 3rd texture with this workaround, but you can blend the 2nd and 4th texture with the color only textures to get some more variation.
I have found that whatever you do, terrain or mesh - you can’t use surface shading if you tile too much on Android.
I solved this issue today by making unlit terrain shader that uses fragment shading only.
Copy-paste this into new shader, then make a new material, select AndroidTerrain/Unlit as a material shader, then paste it into terrain material slot.
I think I might add lightmap support if I will need it myself, but for now you can adjust “Control” texture brightness in different areas to make parts of terrain darker.
There is two limitations: you can’t set different tiling on textures, tiling of the first texture will be used while others are ignored, also you can’t use more then 4 textures.
If anybody knows how to get more then 2 uv texcoords or more then 4 textures into this without hardcoding it into shader, please mod it and post back here.