Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Distorted texture in distance on plane

Discussion in 'General Graphics' started by ComputerBruce, Aug 10, 2015.

  1. ComputerBruce

    ComputerBruce

    Joined:
    Aug 6, 2015
    Posts:
    22
    Hi all

    I have an extremely simple scene.

    Just a 50 scale plane with a 100,100 tiled texture on it.

    No matter what settings I use, I cant get it to render the top third without weird distortion.

    Its for android.

    Is it at all possible to have a tiled texted plane that goes to the horizon that doesn't distort on phones?

    Thanks for any info
     
  2. smd863

    smd863

    Joined:
    Jan 26, 2014
    Posts:
    292
    That's a lack of UV precision. According to the OpenGL ES spec, Android devices only need to have so much precision for UV coordinates in the fragment shader. I think it was 16-bits, but I'd have to look it up again to be sure. UV coordinates normally go from 0 to 1 so this is usually fine. If you start tiling textures a lot (common with something like a static terrain mesh), you will start getting distortion because the lack of precision will cause lots of huge rounding errors in your texture samples.

    You might need to add some more tessellation to your geometry, and the vertex shader needs to be performing a modulo operation on the coordinates to keep the UV values from getting too high.

    If what I wrote doesn't make any sense to you, an alternative that is just as good (or better) is to create your plane procedurally and perform the modulus operation on the UVs when you generate them. There should be some good examples you can find of generating procedural planes, and you just want to create them such that your UVs are never much greater than 1 (i.e. take the modulus of your world space (X,Y) coordinates). That should also solve the problem.

    If you're familiar with any 3D modeling software, you could also create your plane there--making sure to map all quads' UVs to a reasonable range--and then import it into Unity.
     
  3. ComputerBruce

    ComputerBruce

    Joined:
    Aug 6, 2015
    Posts:
    22
    Awesome, it worked :)

    Thanks a lot :)