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. Dismiss Notice

Question regarding Environment art

Discussion in 'General Graphics' started by McPeppergames, Mar 11, 2021.

  1. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    I wonder when building a terrain out of different small objects if there is a feature to "remove" the unseen polygons in meshes. For example when putting different small rocks together to get a big formation of rocks there is so much stuff which can't be seen inside the game but still gets calculated, right?

    What is the best practice to build a detailed map with rocks, trees and buildings without using a to high polycount?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    Best practice is to ignore this as being a problem, because generally it's not actually going to be a significant bottleneck.

    The only time it's likely to be a problem is if you're doing mobile VR. In which case you're going to have to be really selective about the geometry you put into the game to begin with, and if you want to really optimize it or push the detail you'll need to remove the unnecessary vertices (which is much more important than removing triangles) in an external application before importing the mesh into the editor.
     
    mikedarnbrough likes this.
  3. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    Good question. But it is a semi tough question to answer.
    Because according to how the map you designed looks on paper, means, there might be a specific way, or a few specific ways to build, model and detail that map in 3d, especially if you don't want to use a high polycount. The other thing is, we have no idea what the map you imagined looks like, so it is difficult to give an upfront answer. Note, this is not your fault, as alot of people go through this problem too. If possible, could you show us a sketch or concept, of the map you want to make?
     
    Last edited: Mar 27, 2021
  4. Kona

    Kona

    Joined:
    Oct 13, 2010
    Posts:
    208
    There are a bazillion of articles on the internet concerning level design that I recommend you to have a look at, since alot of the level design process is the same no matter what engine you are using. In regard to the subject of this post, what you'ld be looking for to hide "rocks behind other rocks" is called Occlusion Culling, although it's not used to hide small objects behind other small objects, but more in the fashion of occluding large( or large-ish ) sections of a map that are hidden behind an object of relatively large size (like a wall, or mountain, etc.)

    By doing some research on level design, one of the subjects you'll encounter is OC. But to be able to use occlusion culling properly it's also important to understand the fundamentals aswell, in particular how to plan map layouts, what obstacles that could end up as bottlenecks aswell as how such bottlenecks could be avoided or reduced. It's often tricky to optimize a map if it has not been properly planned to start with- but it can also be easy to waste unnecessarily much time optimizing a map in places where it doesn't need to be.
     
  5. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,644
    Theres so much in optimization, OC being only one, but an important one. As previously stated, we cant see your map to know scale, objects, etc. so answers like this will be "generalized".
     
  6. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    Take a look at this video (below) and how the map is designed by adding a LOT of single objects to it. Most part of this objects are hidden and never will be seen by a player. The parts where they intersect for example or what is below the terrain ground. This stuff still is there and gets drawn, right? But it never will be visible... so I thought this is not a "good" way to design a map but you can see this approach everywhere and I wonder if this can be optimized somehow and how you avoid this kind of "Brute Force" editing and throwing in polygons / vertices you never will see?

    Video:
    (about 1:30 minutes into the video, where he is starting to put the rocks on the map!)
     
  7. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    I think youtubers like Sykoo are poor examples for studying level design. Since all they are concerned with are pretty videos with zero real game application. Always working with single camera view only is the most obvious sign.
     
    warthos3399 likes this.
  8. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,644
    That is a single scene, and only a part of one. If you were to build a complete map by deving that way, the sheer number of objects would be insane, and you would have next to no fps. As DimitriX89 said, its not real game applicable.

    If you read the comments for that video, he says when done he was getting 60fps...thats honestly pretty bad for a single area of a scene. You should not follow these videos or believe it can be done in a game, not possible. Ive created the same type of deving in a full scene/map, and the performance was horrible, even when optimized and stream chunking terrain, nothing worked.

    Its just eye candy,..
     
  9. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,791
  10. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    All is a strong word. Used in a lot of AAA games is more accurate. Many AAA games still hand author their lower poly models, or use internal tools to do it rather than Simplygon. There are also tools to reduce the polygon count of a model included in almost every modelling program in existence that can get you 90% of the way.

    Simplygon is extremely good at it compared to most tools though.

    However it's just a single object polygon reduction tool. It doesn't know if polygons won't be visible due overlapping or being embedded in another separate mesh or the terrain, and thus won't remove those.
     
  11. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,791
    I'm sorry
    I meant to use this solution(Low Poly models) in all games, not simplygon
     
  12. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    Thanks for your feedback and the info!
     
  13. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    What about this:


    It is also not optimal, right?
     
  14. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    @DimitriX89 's comment above still applies. If they're building to a single camera view, it's probably not a great reference for the optimal way to do something for a real time game.

    That said, it's totally the way many games have been successfully made. It's not optimal, but it will get the job done. Many very successful games have been made by just placing objects manually everywhere. They may not be games known for their excellent performance, but that brings me back to my original comment of ignoring the problem until it becomes an issue. It also depends greatly on the kind of game you're trying to make. If you're going to make a large world using the above techniques of manual placing objects, the bottleneck is going to be how long it takes to fill out the world probably before the performance becomes an issue. Unless you're doing mobile VR or something else similarly extremely performance constrained.

    Unity's built in terrain tools for grass and object placement, or tools on the asset store like Vegetation Studio, can greatly speed up how easy it is to place and tweak the density of scattered objects, as well as handle more performant ways of rendering and culling those objects than manual placement would. For larger objects like buildings or larger structural elements that do need to be hand placed it's all a balancing act of trying to add enough detail in your meshes to look good without causing a performance problem. Though @UnityLighting 's mention of Simplygon brings up the importance of using LOD meshes and/or an impostor system like Amplify Impostors on especially high vertex count meshes.

    But micro optimization like culling hidden faces on every placed mesh just generally isn't something done anymore today. It's not worth the time to implement over other more general purpose optimizations.
     
    warthos3399 and McPeppergames like this.
  15. McPeppergames

    McPeppergames

    Joined:
    Feb 15, 2019
    Posts:
    103
    Thank you!
     
  16. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    Relevant: https://twitter.com/socrates200X/status/1374036978799415298?s=20

    Those are screenshots from Skyrim if you don't recognize it. Not exactly a small game. Bethesda is well known for just shoving massive models into walls / the ground if they only want part of it rather than making bespoke versions of the assets with the extra parts removed. In Fallout games it's not unusual for more of the mesh to be hidden underground or behind a wall than visible.
     
    Last edited: Mar 22, 2021
    BrandyStarbrite likes this.
  17. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    If optimisation of hidden faces concerns you, then there is an option is to place your decorative meshes using some 3d modeling application that supports Boolean operations. For example, newest Blender's Boolean modifier can work on Collections (sort of scene layers), which is ideal for joining together large number of objects such as rocks while removing their internal faces (if Boolean Union is used). Then, you could Boolean Subtract your terrain from the rocks' mesh, further optimizing it.
    I did not try to export terrain from Unity to other applications, but heard it is possible, either using 3rd party assets or some standard functionality.
     
    Last edited: Mar 22, 2021
  18. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
  19. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    On topic of export, at the very least Unity can export terrain heightmaps. Then, it will be on you to recreate the terrain in the editor of choice using some kind of Displace modifier
     
  20. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    You really don't want to do that.

    Boolean operations can add more vertices to a mesh than it removes, especially on complex intersections.

    Unity's terrain dynamically tessellates on the CPU based on distance. Tools that export Unity's terrain mesh exporting usually exports the highest tessellation level across the entire terrain, but that means the most added vertices, as the terrain will be the most detailed version and thus have the most complex intersection. It also means objects placed on the terrain might appear to hover or have holes as soon as you move away from them as the lower detail terrain tiles don't perfectly match the higher detail tiles leaving gaps between the terrain and the "perfectly" booleaned cut.

    Booleans are an excellent tool for modeling complex hard surface shapes. They're rarely any kind of optimization.


    This really is a non issue that you shouldn't waste time worrying about. You'll create more problems for yourself than you'll fix if you try to focus on this "issue" as there are many other much lower hanging optimization techniques to focus on first.
     
  21. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    ^^Your point about booleans makes sense, though the theoretic mesh made of merged rocks can then be decimated, and, depending on the structure, it may get rid of excess vertices. I just dont know what to suggest in this place, other than placing objects by hand. What about terrain, the Unity terrain map can be used as a "sketch", and then the map is finalized as a mesh in the 3d editor. Fits for the cases when there is no large drawing distance and dynamic tesselation isnt needed.
     
    Last edited: Mar 22, 2021
  22. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    That's why I wanted to frame boolean as a modelling tool, not an optimization tool. Merging two complex shapes together as a step in modelling some merged shape is fine, as long as you plan on doing further mesh optimization or hand remodeling of the results. Boolean operations almost always create really heinous geometry.

    As a quick example I merged two geospheres in two different ways. On the left I just appended the geometry together. All the overlapping triangles still exist and have not been removed at all. On the right the two meshes where booleaned together into a single mesh.
    upload_2021-3-22_14-52-15.png
    While the boolean mesh has 8 fewer triangles, it has 244 more vertices! Vertex count is a much bigger factor to consider for performance than triangle count, so saving 8 triangles out of 640 is meaningless compared to the addition of >60% more vertices.

    Though, unless you have thousands of this mesh in the scene, neither are really bad enough to really be a performance concern. And even then the number of game objects is going to likely have a bigger performance impact than the vertex count on any desktop device.
     
  23. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550

    Any Decimation algorithm should be enough to get rid of those extra vertices along the seams. Most 3d programs nowadays have it. Good call on Booleans causing this problem, anyway.
     
  24. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    UV coordinates will be a mess though
     
  25. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    Yep, again, modelling tool, not optimization tool.

    Also Blender's vertices count is not going to match Unity's because what they count as "a vertex" is different.
     
  26. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    Turned out that with some Blender hacks (like splitting mesh along the seams before decimation) it is doable
     
  27. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    550
    So is Max's since 3d editors do not count hard edges and UV seams as split edges. Doesnt matter, as the result of Boolean + Decimate lowers the vertex count in any case.