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

Textures blurry from some distance but normal when very close

Discussion in 'Editor & General Support' started by Icefinity, Dec 3, 2017.

  1. Icefinity

    Icefinity

    Joined:
    Nov 10, 2017
    Posts:
    3
    As the title is saying, i get in both the rendered game and in the editor a very blurry ground texture when moving away from the textured location.

    Like in this image:
    1. Is when i hold left mouse button and how it should normally be
    2. When i release the left mouse button it becomes blurry at that distance and how it looks in the game when playing untill i get very very close
    3. Without holding left mouse button but when very very close (how it should be from far away too)



    Additional info:
    Because the mountains that i want to put the texture on are very big , i use in the terrain add texture the size: x:1000 and y:1000 (did 15 too and it still gets blurry) ; 0 offset ;0 metalic ;0 smooth

    What i have tried to fix the problem:
    -aniso level to max (16)
    -texture is 2048x2048 RGB 24 bit
    -filter mode from bilinear to trilinear

    If someone can suggest something to me, i am willing to try.
    Thank you
     
    Last edited: Dec 3, 2017
  2. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    What Mip Map settings do you have for the texture?
     
  3. Raestream_G

    Raestream_G

    Joined:
    Aug 18, 2017
    Posts:
    79
    It might be worth setting the mip map filtering on your textures to Kaiser instead of Box, and see if that helps.
     
  4. Icefinity

    Icefinity

    Joined:
    Nov 10, 2017
    Posts:
    3
    I have tried disabling / enabling / changing every setting at mipmap and there is no difference , it's still as blurry.

    I have tried that and sadly i get the same blurry effect.

    The solution to the problem is this:
    You make a C# Script and put this code in:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [ExecuteInEditMode]
    6.  
    7. public class TerrainBlurryTextureFix : MonoBehaviour {
    8.     //Add as Terrain Component and modify in text box
    9.         public float BasemapDistance = 80000;
    10.         private Terrain terrain;
    11.  
    12.         void OnEnable ()
    13.         {
    14.             terrain = GetComponent<Terrain> ();
    15.             #if UNITY_EDITOR
    16.             UnityEditor.EditorApplication.update += Set;
    17.             #endif
    18.         }
    19.  
    20.         #if !UNITY_EDITOR
    21.         void Update ()
    22.         {
    23.         Set
    24.         }
    25.         #endif
    26.     void OnDisable()
    27.     {
    28.         UnityEditor.EditorApplication.update -= Set;
    29.     }
    30.         void Set ()
    31.         {
    32.             if (terrain == null)
    33.                 terrain = GetComponent<Terrain> ();
    34.             else if (terrain.basemapDistance != BasemapDistance)
    35.                 terrain.basemapDistance = BasemapDistance;
    36.         }
    37.     }
    38.  
    39.  
    Just add this script as a component on the terrain in the inspector and modify the ammount of distance you want the script to render the texture for.

    Also as another helpful script for distances , this is a Tree load distance:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [ExecuteInEditMode]
    6.  
    7. public class TreeDistanceRender : MonoBehaviour {
    8.     //Add as Terrain Component and modify in text box
    9.     public float TreeDistance = 6000;
    10.     private Terrain terrain;
    11.  
    12.     void OnEnable ()
    13.     {
    14.         terrain = GetComponent<Terrain> ();
    15.         #if UNITY_EDITOR
    16.         UnityEditor.EditorApplication.update += Set;
    17.         #endif
    18.     }
    19.  
    20.     #if !UNITY_EDITOR
    21.     void Update ()
    22.     {
    23.     Set
    24.     }
    25.     #endif
    26.     void OnDisable()
    27.     {
    28.         UnityEditor.EditorApplication.update -= Set;
    29.     }
    30.     void Set ()
    31.     {
    32.         if (terrain == null)
    33.             terrain = GetComponent<Terrain> ();
    34.         else if (terrain.treeDistance != TreeDistance)
    35.             terrain.treeDistance = TreeDistance;
    36.     }
    37. }
    38.  
    39.  
    Same as above just add this script as a component on the terrain in the inspector and modify the amount of distance you want the script to render the trees for.
     
    Last edited: Dec 11, 2017
    Westland likes this.
  5. fjruizf

    fjruizf

    Joined:
    Apr 17, 2019
    Posts:
    1
    Thank you very much! That code works perfect in Edit mode. The only issue was when building it.

    I modify the code slightly as follows to fix those errors in the build.


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. [ExecuteInEditMode]
    5. public class TerrainBlurryTextureFix : MonoBehaviour
    6. {
    7.     //Add as Terrain Component and modify in text box
    8.     public float BasemapDistance = 10000; // 10 km distance
    9.     private Terrain terrain;
    10.  
    11.     void OnEnable ()
    12.     {
    13.         terrain = GetComponent<Terrain> ();
    14.         #if UNITY_EDITOR
    15.         UnityEditor.EditorApplication.update += Set;
    16.         #endif
    17.     }
    18.  
    19.     #if !UNITY_EDITOR
    20.     void Update ()
    21.     {
    22.         Set();
    23.     }
    24.     #endif
    25.  
    26.     void OnDisable()
    27.     {
    28.         #if UNITY_EDITOR
    29.         UnityEditor.EditorApplication.update -= Set;
    30.         #endif
    31.     }
    32.  
    33.     void Set ()
    34.     {
    35.         if (terrain == null)
    36.             terrain = GetComponent<Terrain> ();
    37.         else if (terrain.basemapDistance != BasemapDistance)
    38.             terrain.basemapDistance = BasemapDistance;
    39.     }
    40. }
     
  6. Rasmus58

    Rasmus58

    Joined:
    Jun 3, 2019
    Posts:
    23
    What about textures ? Does it work ?
     
  7. Westland

    Westland

    Joined:
    Jan 26, 2015
    Posts:
    26
    Icefinity & fjruizf, you're heroes, dudes!

    It does, indeed!