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

How to reduce draw distance for detailing on a model?

Discussion in 'Scripting' started by Sargon_of_Akkad, Aug 12, 2011.

  1. Sargon_of_Akkad

    Sargon_of_Akkad

    Joined:
    Jan 16, 2011
    Posts:
    147
    How do I change the range from the camera at which details are displayed? Can I reduce the model detail dynamically at all?
     
  2. Sargon_of_Akkad

    Sargon_of_Akkad

    Joined:
    Jan 16, 2011
    Posts:
    147
    Noone has any idea then?
     
  3. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    by writing a lod system that either modifies the mesh if you want mesh details change or by changing the materials shader lod level.

    Unity has no LOD system inbuilt so its up to you
     
  4. Machacator

    Machacator

    Joined:
    Oct 1, 2014
    Posts:
    6
  5. ZO5KmUG6R

    ZO5KmUG6R

    Joined:
    Jul 15, 2010
    Posts:
    490
    You can do this in the free version. It's just up to you custom-building it.

    For example, you can do it with a script like this :
    Code (CSharp):
    1. public Mesh LODMesh1;
    2. public Mesh LODMesh2;
    3. public Camera distanceCamera;
    4. void Start(){
    5. if(distanceCamera == null){
    6. distanceCamera = Camera.main;
    7. }
    8. }
    9. void Update(){
    10. if(Vector3.Distance(distanceCamera.transform.position,this.transform.position) > 10){
    11. this.GetComponent<MeshFilter>().sharedMesh = LODMesh1;
    12. }else{
    13. this.GetComponent<MeshFilter>().sharedMesh = LODMesh2;
    14. }
    15. }
    16.  
    17.  
    18. }

    This is a basic example and not intended to be used in a production. Although it will work, It is intended to show the concept behind a LOD system
     
    Last edited: Oct 14, 2014
    Machacator likes this.