• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by z3nth10n · Jun 18, 2022 at 09:20 PM · distancegridlod

Trying to do a flexible/generic minimum distance level of detail distance ranges system

Well, I'll like to create a level of detail system for my game to load the terrain.

The point here is that I'll like to use the minimum expression for distances, so all the chunks that I load match at the corners but there are no redundant parts, like here:

...

So, more somet$$anonymous$$ng like t$$anonymous$$s:

...

The purpose here is to have the maximum render distance with the minimum count of gameobjects to load.

I have two main concerns the system is not flexible for initial minimum distances that are non-base of 2.

As somet$$anonymous$$ng like t$$anonymous$$s is browsed:

...

Another t$$anonymous$$ng is that distance must be patched:

``` //// If the number is even, then we must do t$$anonymous$$s patch if (currentDistanceLevel == 128) sum += currentDistanceLevel / 2; // TODO, why? ```

I don't understand why...

T$$anonymous$$s is what happens:

...

T$$anonymous$$s is my code:

         /// <summary>
         /// Calculate the the minimum distances between level of detail chunks.
         /// </summary>
         /// <param name="lodLevels">The number of lod levels to go into.</param>
         /// <param name="numberOfChunks">The number of chunks after the view distance from the ChunkGenerator system finishes.</param>
         /// <returns>A list of distances to use on a grid of level of detail. (See https://i.gyazo.com/0ceb8ff3a4ebab8391532892fc8b6f82.png)</returns>
         public static IEnumerable<float> CalculateOptimumLoDValues(int lodLevels, int numberOfChunks, int chunkSize)
         {
             var back = false;
             var sum = 0;
             var currentDistanceLevel = chunkSize;
             for (var l = 1; l < lodLevels; l++)
             {
                 // The last step is give the previous sum
                 yield return sum;
 
                 // At the second step, if we didn't went to the previous level
                 if (!back)
                 {
                     // We half the number of chunks of the previous level
                     numberOfChunks /= 2;
 
                     // And we double distance for the next level
                     currentDistanceLevel *= 2;
                 }
                 else
                     back = false;
 
                 numberOfChunks += 2;
 
                 // First, if we want to avoid t$$anonymous$$s effect, we must do the following step.
                 // https://i.stack.imgur.com/1nfgd.png
                 // at https://stackoverflow.com/questions/72636128/trying-to-position-all-chunks-for-distinct-lod-levels
                 // ----------------
                 // If the following distance level has an odd number of elements then I try to match the current row/column by doubling it, in that way non of the following corner will be half of the previous one.
                 // The number of chunk on the rows goes, 16-10(8+2)-12(10+2)-8(12/2+2)-6(8/2+2)-8(12/2+2)-6(12/2+2)....
                 if (numberOfChunks / 2 % 2 != 0)
                 {
                     // Then, if the number is odd after summing the two corners and dividing it,
                     // we must go into he back level, set the flag to true and sum the distance
                     l--;
                     back = true;
 
                     sum += currentDistanceLevel * 3 / 4;
                 }
                 else
                 {
                     //// If the number is even, then we must do t$$anonymous$$s patch
                     if (currentDistanceLevel == 128)
                         sum += currentDistanceLevel / 2; // TODO, why?
                     else
                         sum += currentDistanceLevel; // For the rest of the levels we sum it
                 }
             }
         }


Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

138 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Various shadows quality basing on distance 1 Answer

How to handle collisions for LODs with different submeshes? 1 Answer

Change Lighting of grid base on distance from player. 0 Answers

Change Lighting of grid base on distance from player. 1 Answer

Hexagon-Grid Distance 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges