How do we adjust the objects' height positions on a Unity terrain with LOD and add buildings?

Discussion in 'Game Development (Technical)' started by GaiaDreamCreation, Dec 20, 2016.

  1. GaiaDreamCreation

    Indie Author

    Joined:
    Jun 8, 2008
    Messages:
    433
    Likes Received:
    22
    My question is about placing objects on a Unity terrain and getting the right position (height axis) when the LOD of the terrain changes. I did many searches, but I haven't found anything related. Here's the scenario.

    The terrain has LOD. I presumed that objects like trees and grass on terrains are repositioned when the LOD changes (not really sure). That would be required because the terrain has fewer polygons. The trees might be floating or sinking where the vertices were reduced. I tried playing with the terrain and I noticed that the trees/grass distance visibility is quite limited. Maybe that visibility limitation is about the position issue on terrains. It's faster and far easier to cull the trees and grass than trying to reposition them based on the LOD.

    I also had this question about adding buildings related to the issue above. How do you add buildings on terrains to ensure the correct height all the time? Let's say I want to create a building (house or skyscraper) on a terrain. When the LOD changes, the building might be floating over or sinking in the terrain. My research didn't allow me to know how to deal with this.

    After trying the Unity terrain with trees and grass, I think about adding my own trees and grass system without using the Unity terrain to add/manage them. I need more control about the visibility of my objects and my game also has a procedural terrain generation.

    Does anyone know how to deal with positioning the objects and LOD on Unity terrains?
     
  2. Scoper

    Indie Author

    Joined:
    Nov 5, 2015
    Messages:
    69
    Likes Received:
    17
    An interesting problem. i don't think you can do that in Unity without writing your own custom LOD algorithms.
    But I am curious as to why you want this. To me, it seems to go contrary to the purpose of LOD - that is to improve performance by reducing detail where the player won't notice. So the ideal algorithm cuts as many polygons as possible using as little processing power as possible with as little noticable effect as possible. Continually changing the height of trees would seem to require a lot of processing power while creating a very noticable effect of trees bouncing up and down.
    If the terrain loses some polygons it should not be noticable, because it happens far from the camera. Especially not if the grass and trees stay where they are.
     
  3. GaiaDreamCreation

    Indie Author

    Joined:
    Jun 8, 2008
    Messages:
    433
    Likes Received:
    22
    You're right about the issues and and effects.

    The reason why I want to do this is because Unity controls an aspect that does not create a good effect in the game that I'm creating.

    Another reason is because I want to place huge buildings (and other elements) on the terrain and I don't see how their position is going to be managed with the LOD. I anticipated the up and down bounces as you mentioned. I believe there's no bouncing because Unity hides the trees relatively close (before changing the LOD). I suspect the height adjustment is simply not implemented because of the complexity of managing those aspects.

    The Unity terrain is probably limited and I don't think that we can do whatever we want. A terrain is far more than just small trees, grass and small details (the integrated assets). Managing a city or a village is necessary. In that case, a simple solution is to flatten the area. That way, the change in the LOD won't create gaps between the ground and the buildings because of the same height applied to a larger area covering more LOD tiles.
     
  4. kaufenpreis

    kaufenpreis New Member

    Joined:
    Aug 1, 2014
    Messages:
    93
    Likes Received:
    3
    I used this and then adjusted my game objects manually accordingly because although it proves as a good guide to know how much you need to adjust everything, I think it is best to manually adjust the scale/position because to do this by code will take unnecessary overhead, but if you just take a bit of time and do it manually, you will end up with exactly what you want at no cost, but your time. On the other hand, if you want to do it manually maybe this will give you a head start.

    Unfortunately it doesn't allow me to post nice looking code as a comment and I didn't want to answer as I'm not sure if this completely answers your question.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer