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

Decrease resolution the further you are.

Discussion in 'General Graphics' started by Username0101, Nov 6, 2015.

  1. Username0101

    Username0101

    Joined:
    Sep 3, 2015
    Posts:
    18
    I had a thought about optimization of the game.

    What if, the resolution of an object would decrease, the further you went from it, and then less details you needed. Of course I could use Vector3.Distance or .magintude() but that would murder every GPU and CPU there is. Is there maybe a built-in way? Using methods mentioned before would be murder for hardware when programmed in C#, but maybe Unity has some good bindings in C++? I would like to define images of sizes n*n, where n would be: 1 (few kilometers away), 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 (right in-front of it).
     
  2. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Isn't this already covered by Unity with MipMaps and LOD?

    MipMap settings are on the texture import settings.
     
  3. ClearRoseOfWar

    ClearRoseOfWar

    Joined:
    Sep 6, 2015
    Posts:
    87
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    Minor correction: Mipmaps are editor generated. The engine just passes the textures with the generated mipmaps to the GPU which handles the actual choosing of the mipmap level. This isn't done by distance exactly, but instead by calculating the texel screen size, or how many screen pixels a texture pixel covers, which takes into account the distance, surface facing, and field of view.
     
  5. Username0101

    Username0101

    Joined:
    Sep 3, 2015
    Posts:
    18
    Read both. Exactly. But I'm not interested in mipmap images resolution change on lower-pixel-coverage. But more distance based.
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    The expensive part of distance calculations is the square root, so you just don't do it and keep a table of the distances you want the different detail levels as distance squared. This is pretty standard LOD stuff for large scale environments. Open world games will often combine huge portions of the game into single low polygon meshes with a single low resolution texture across the entire surface. Then as you get closer load multiple slightly higher poly mesh chunks, etc. until you finally are close enough to show the full detail models.