Announcement

Collapse
No announcement yet.

Strange pixelation in landscape on Nexus 5

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:

    Click image for larger version

Name:	DSCN2762.JPG
Views:	1
Size:	248.8 KB
ID:	1136378

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

    Click image for larger version

Name:	MobilePreview.jpg
Views:	1
Size:	292.2 KB
ID:	1136379

    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 :
    Click image for larger version

Name:	DSCN2765.JPG
Views:	1
Size:	194.5 KB
ID:	1136380
    Click image for larger version

Name:	DSCN2769.JPG
Views:	1
Size:	200.9 KB
ID:	1136381

    Please help !

    Thanks
    Sanjit

    #2
    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.

    Comment


      #3
      @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 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

      Comment


        #4
        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.

        Comment


          #5
          I wonder if this is because of lowp vs highp in the shaders .....

          Comment


            #6
            Originally posted by dsanjit View Post
            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.

            Comment


              #7
              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...

              Comment


                #8
                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 ....

                Comment


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

                  Sanjit

                  Comment


                    #10
                    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.

                    Click image for larger version

Name:	CustomUVs1.png
Views:	1
Size:	88.3 KB
ID:	1052549

                    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:

                    Click image for larger version

Name:	CustomUVs2.png
Views:	1
Size:	43.1 KB
ID:	1052550

                    Hope that helps.

                    - Jack
                    Last edited by JackP_oldaccount; 07-11-2014, 06:19 AM. Reason: (edited image slightly)

                    Comment


                      #11
                      Originally posted by dsanjit View Post
                      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...
                      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.

                      Comment


                        #12
                        Thanks Jack ! It worked and looks great now !

                        Sanjit

                        Comment


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

                          Comment


                            #14
                            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.

                            Comment


                              #15
                              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...
                              Dialectical a futuristic racer is out now on Google Play (currently soft launched in Australia / New Zealand only).

                              Comment

                              Working...
                              X