Strange pixelation in landscape on Nexus 5

Hi Guys
I Simplified the terrain shader in the racing sample to work on mobile platforms (7 samplers per shader max). The results look good in the editor and mobile previews. But strangely there is heavy pixelation when I run it on my Nexus 5.

Here it is running in the editor:

This is in the Mobile Preview (not sure why the character is black… need to investigate) :

And here are some shots of it running on my nexus 5 - as you can see the other textures render fine but the landscape is rather pixelated :


09ef9d28964b55e0447e3d0bfeb98ea065ada822.jpeg

Please help !

Thanks
Sanjit

2 Likes

I’ve seen terrain pixelation on mobile when the shaders are using very low precision variables for the UV coordinates. Usually, UV coordinates are between 0 and 1 so OpenGL ES only *guarantees *16 bits of precision (even on highp variables). If you have large terrain and the texture loops on it many times you can start to run out of precision when your UV values start getting too high. You will start to get weird pixel artifacts in your textures. Some devices/drivers will have more precision and the problem will disappear (like all PCs).

If your texture looks okay in part of the terrain (where the UV coordinates are closest to 0), and slowly get more distorted as you move across the terrrain, then this is likely your problem. There’s nothing much you can do other than breaking your terrain into smaller chunks and/or using larger tiling for your terrain texture (so the UV values accumulate at a lower rate).

It does look a bit different than the pixelation I’ve seen this problem in the past so I wouldn’t rule out other causes.

@CaptainScience
Thanks for the inputs. Yes you are correct, there seems to be a precision issue. When I move to one corner of the landscape it looks OK but then rapidly deteriorates as I move away. It looks like the usable space is only 20 meters or so which is really small for any landscape :frowning: I think I am making some errors in the landscape setup. I also tried with a smaller landscape but had similar issues.

Also is there any differences between the LanscapeCoords node and the TextureCoords node ? In many examples in the wiki the LandscapeCoords node is used to texture the terrain.

This is proving to be a showstopper … Some more advise will help !

Cheers
Sanjit

I don’t have enough experience UE4 specifically to know off-hand the best way to deal with this.

You could try using a modulo operation somewhere to keep the UV values in a range from 0 to X instead of constantly accumulating. It might work in the material shader, but it would ideally be applied to the texture coordinates of the terrain vertex data itself to avoid ever dealing with large UV values.

At this point I have literally zero experience dealing with UE4 terrains so I don’t know specifically what the best solution is.

I wonder if this is because of lowp vs highp in the shaders …

In OpenGL ES 2 even highp is only required to have 16 bits of precision. That’s the *minimum *so certain combinations of hardware and drivers will have more, but you will run into problems on certain devices that only implement the bare minimum requirements.

OpenGL ES 3 bumped highp up to 32-bit and mediump’s to 16-bit, I believe, so it would help to bump it up to highp in that case.

If you want to support a wide range of Android devices, you will want to find a way to work with low precision variables.

I still dont understand. I am not doing a lot of tiling. Infact I tried with a tiling factor of 1 and with a very elementary texture - no blending. And I got precision issues. Infact its real bad. If I load in the third person shooter template and create a landscape the largest I can get it is around 20 meters before it starts pixellating. This is also the Nexus 5 with an Adreno 320 GPU…

OK I just ran the content examples project and specifically the BPLandscape level. There are a few small landscape examples and they all show the pixelation on Nexus 5. Definitely something is amiss …

Hi does 4.3 address the landscape pixelation issue on mobile devices ?

Sanjit

Hi, there are some precision limitations on mobile, and to work around them you need a slightly different material setup so that the math gets performed in the vertex shader (normally it will occur in the pixel shader).

Firstly you need to enable one or more “Customized UV” inputs in your material. To do that, put a number in the “Num Customized UVs” property of the material (it’s hidden under Advanced so click the little arrow). Then you need to connect LansdcapeCoords nodes and any calculations you want to the Customized UV inputs.

Now you’ve setup your custom UVs, you can use them where you want to connect them to a texture, by specifying a Custom UV Type value in your LandscapeCoords node:

Hope that helps.

Landscape UV coordinates are based on the landscape’s position world space, so if you have two landscapes next to each other the tiling will be seamless across it. That’s why there are precision issues even for seemingly simple cases. See the Customized UVs above to solve this problem.

Thanks ! It worked and looks great now !

Sanjit

Can You please post a full photo of your setup im having the smae problem but dont know much about materials.
Thanks in advance.

This was a while back and i dont hve the setup. First you need to simplify the shader to use 6 or so texture samplers. Might need a good understanding of how shaders work especially at the glsl level to pull this off. I took the existing shader in the racing game sample and modified it. Then use custom uvs as explained above to prevent loss of precision.

This is a very old thread but there don’t seem to be any others, so going to necromance here for the benefit of others searching.

I didn’t see any UV artifacts, but also had a small landscape (so UV precision is less of an issue) - and didn’t test on a wide variety of devices.
Performance is another issue - Landscape performance on ‘previous gen’ mobile is not good (to be expected, really).

Scenerio:
Nexus 7 (2013) - Adreno 320.
UE4 4.9 LDR mobile mode.
Very small landscape - 187x187 verts (31x31 quads, 3x3 components). Collisions disabled. Stretched over a relatively large area (90000x90000 unreal units).
Unlit opaque material (LDR), 3 samplers (base texture, detail textures in RGB channels, lerped by static colors in each landscape layer, combined for final result).

Render thread.
Using landscape layer nodes in a material (vert colors internally?) even on an unlit material can easily double the time spent in the render thread.
Suspect this relates to the tile based rendering of mobile hardware (one extra pass per landscape layer?).

Using an ‘standard’ unlit material with no landscape material nodes works best.
Use customised UV’s in the second (index1) and third slot (index 2) to tile textures - using UV slot 0 as a customised UV does not work on device (bound to landscape chunk UV’s internally?).
Multiplying UV’s of an existing custom UV per pixel for additional detail textures seems to perform OK.
Divide your UV coordinate by the number of vertices in the height map to get a 1:1 mapping (ie. UV divide 187 in above scenerio covers entire landscape once with no repetition).
Getting landscape materials to look good with these limitations is “rather challenging”.

Game thread.
As I had a small landscape area, I was forcing LODing to occur by increasing ‘Landscape -> LOD -> LOD Distance Factor’ from 1.0 to 3.0.
Don’t do this. While it reduces the number of triangles in a scene, it has a large performance hit - it can actually be quicker just to render the triangles than to recompute LOD’s each frame.

I had a 33ms max per frame target (30fps).
In the above scenerio, this landscape LODing was costing up to 18ms a frame depending on the view (more than the rest of the game thread including running as a server).

Hope this helps someone else out there save time…

1 Like

very useful information, saved me lots of time! Thanks!

Currently developing a mobile game. It seems that information about using and optimizing ue4 landscape tool on mobile platform is really scarce. I wonder if everyone is using some in-house tech
or people just don’t do landscape on mobile.

While packaging for es2.0 android device, output log shows error in landscape material compilation. What to do?

You can see the log file where it says “Cannot access field LayerWeights of structure”. How to resolve even when mobile texture samplers show only 5 ??

I know it’s an old post and after searching around google came across this at last which looked a lot similar to my issue. Made customized UV but the last image was missing so not sure what else to go towards. Sorry still trying to learn so not sure.
Since the image is missing from the accepted solution hard to tell what is missing as I am still not able to resolve exactly the same issue as OP. Hopefully, someone can suggest. Been going through it for days now.
Update: Time of issue i was using UE5 early access. Thought maybe some issue in there. Now using 4.26.2 again. Base mobile project same issue on materials. Assuming it is related to material rendering for Mobile. As we can not use auto layers for Landscape on sm4 below. But even starter pack materials showing same issue.

I had the same problem. Here is the solution that worked for me: Read the comments

1 Like

So as for landscape material ,Num Customized UVs are not more than 3? I have four layers , and I set 4 cutomized UVs ,but the fourth layer donesn’t work . That’s really sad.