Unsolved Converting placed meshes to forest items

Discussion in 'World Editor' started by nachtstiel, Jul 2, 2022.

  1. nachtstiel

    nachtstiel
    Expand Collapse

    Joined:
    Dec 10, 2016
    Messages:
    463
    Is there an in-editor tool that can convert already placed meshes to forest items? Currently, I am using a script I wrote to do so, but I was wondering if there was a native tool for this purpose.

    To clarify, I have meshes that I placed a bunch of before I realized they were going to have a huge performance hit(around 200 or so), and have been manually replacing each mesh with a corresponding forest item in the editor, but that proved to be inefficient and imprecise. Due to this, I made a quick script to scan the items json and spit out corresponding forest item data that I paste into the corresponding forest item json file.
     
    #1 nachtstiel, Jul 2, 2022
    Last edited: Jul 2, 2022
  2. ltntai

    ltntai
    Expand Collapse

    Joined:
    Mar 18, 2017
    Messages:
    656
    I'm not aware of such editor tool, but it could be useful. How does your script handle the scaling difference? Static object could be scaled individually on every axis, while a forest object can't.
     
  3. nachtstiel

    nachtstiel
    Expand Collapse

    Joined:
    Dec 10, 2016
    Messages:
    463
    It sets the scale to 1 and then I adjust it in-game until it looks good enough. I was surprised at first to find that the scaling is limited for the forest items, though.
     
    • Like Like x 1
  4. ltntai

    ltntai
    Expand Collapse

    Joined:
    Mar 18, 2017
    Messages:
    656
    Maybe the script could keep the scale of the mesh if the axis values are identical and ignore it from the conversion when they are not?
     
  5. nachtstiel

    nachtstiel
    Expand Collapse

    Joined:
    Dec 10, 2016
    Messages:
    463
    The problem I ran into is that there are several items that I would only want to scale on one axis, which forest items are incapable of doing, so I opted to just adjust them in-game instead of guessing lol. I am fairly noobish when it comes to coding, so I just went with something simple. Essentially, I just look through the items file for a specific mesh, then extract the position and rotation info, then populate a text file with the converted info, and finally paste that into the appropriate forest file. Afterwards, you need to delete the entries for that mesh in the items folder manually. I took a screenshot of the code if you want to see it. It's in Godot since that's what I have downloaded at the moment.
     

    Attached Files:

    • Screenshot2022-07-01172825.png
  6. el_ferrito

    el_ferrito
    Expand Collapse

    Joined:
    Sep 30, 2020
    Messages:
    414
    I've got a feeling you can pull the info out of the JSON file and put it into the forest.json file format. I'll have a look and see. It might take a bit of tweaking in excel, but check the two file format/styles and see if you can bodge it. I've definitely places forest items just by writing the code before (using Excel to convert xyz input into the right format for BeamNG).
     
  7. nekitu

    nekitu
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 18, 2018
    Messages:
    87
    The tool would be rather specific, so that is why it doesnt exist. Ideally when starting a level, if you think or know you would have many instances of specific meshes, use the forest system to place them.
    Scaling is uniform for forest items, I do not know exactly why, comes from the old, maybe to keep it simple, since there is also min max scale on the forest brush settings, you would need to have per axis. Could also be related to physics, perhaps forest item physics needs uniform scaling. I will create a task for this to be investigated anyway, doesnt hurt, thanks.
     
    • Like Like x 1
  8. ltntai

    ltntai
    Expand Collapse

    Joined:
    Mar 18, 2017
    Messages:
    656
    There are 877 static rocks in Utah map, all positioned in places where you could possibly drive over them. Most are in default XYZ 1,1,1 scale. Those could have been forest items for performance gains.
    Are static objects somehow better than forest ones? Maybe less tire shredding or vehicles sinking in the meshes and getting stuck?
     
  9. nekitu

    nekitu
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 18, 2018
    Messages:
    87
    The physics is the same for all static or forest items, no difference, the static meshes and forest items do use instancing, so they have the same speed, forest items add wind and color info to the instances.

    About scaling the forest items, I think its uniform because usually trees and rocks look better with the uniform scale and shape the artist made that model in, a scaled up tree might look odd, on one axis, even a rock.
     
  10. nekitu

    nekitu
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 18, 2018
    Messages:
    87
    @nachtstiel I think you should be fine without forest items meshes, since it also does instancing, maybe the perf hit is from something else, but it also could be from those meshes, what polycount does it have ?
     
  11. nachtstiel

    nachtstiel
    Expand Collapse

    Joined:
    Dec 10, 2016
    Messages:
    463
    The reason I wanted to use forest items is I was reading through the forums a few years back and one of the team members mentioned that using the forest tool was more performance friendly than individually placed static meshes and I noticed that several repeated meshes such as the barriers were placed using the forest tool. It wasn't really ever a problem for me until now, so I never cared to learn how to place them with the forest tool until this map. On my previous maps just made the barriers one mesh in blender since I couldn't find a tutorial on precisely placing items using the forest tool.

    The polycount is between 9.3 and 12.5 million depending on which part of the map you are on. I did have an increase in fps from 60-ish to my limited 75 by doing this conversion.

    Thank you, by the way, for helping out! I have been out of town for the weekend, so I couldn't respond earlier.

    Would it be more performance friendly if I were to merge them all into one mesh and cut out hidden faces?
     
    #11 nachtstiel, Jul 5, 2022
    Last edited: Jul 5, 2022
  12. nekitu

    nekitu
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 18, 2018
    Messages:
    87
    so how many polys a mesh has ? not the whole level rendering view.
    You could try as a test to merge the meshes, but normally instancing should be faster. So from a tech pov, forest and static meshes are the same, instanced.
     
  13. nachtstiel

    nachtstiel
    Expand Collapse

    Joined:
    Dec 10, 2016
    Messages:
    463
    Sorry, I am using the cliff rocks and boulders from the utah map. So between 300 and 2000.
     
  14. nekitu

    nekitu
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 18, 2018
    Messages:
    87
    well, that's all I know, use whatever technique is faster I guess.
    if the speeds differ, then we will need to check it out, should be the same or similar to small differences.
     
  15. nachtstiel

    nachtstiel
    Expand Collapse

    Joined:
    Dec 10, 2016
    Messages:
    463
    Okay, cool. What I'll do is make a map with a ton of manually placed static meshes, record the performance values, then convert them to forest items and do the same. That way, I can give you accurate data on the performance hit, if one exists.
    --- Post updated ---

    I set up smallgrid and used the twist loop mesh since it was the most complex one there. At 4096 static meshes, the framerate was in the 30s. At 10,196 of the same shape in forest form, I get a comparable framerate drop. Out of the editor the number needed is a lot higher, but I wasn't able to get the number needed to get a drastic framerate drop out of the editor while maintaining an accurate count of meshes due to framerate drops and crashes while in the editor when manipulating too many meshes at one time.

    EDIT: I noticed that the framerate drops more in editor when you make large changes, so the screenshots below are after saving and reloading the map after placing the items

    My pc Specs if it matters:
    CPU: Ryzen 5700G
    GPU: RTX 3060TI
    RAM: 48 GB

    The framerate at 4096 static meshes:
    20220705165326_1.jpg

    at 10196 forest items
    20220705164814_1.jpg
     
  16. nekitu

    nekitu
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 18, 2018
    Messages:
    87
    but 4096 forest items ? to just get a compare with the ones in static form.
    yes, in editor there are other checks and UI stuff happening, even related to objects, raycasts etc., so it will be slower
     
  17. nachtstiel

    nachtstiel
    Expand Collapse

    Joined:
    Dec 10, 2016
    Messages:
    463
    When at 4096 forest items, there was no change to the framerate when none were selected. Due to this, I decided to keep going until the rate drop was the same between the two.
     
  18. nekitu

    nekitu
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 18, 2018
    Messages:
    87
    The best comparison is with editor deactivated, since scene tree might take a toll when static meshes are used, might iterate on them in some cases and show in the tree. Forest items are not shown, just bulk edited.
     
  19. nachtstiel

    nachtstiel
    Expand Collapse

    Joined:
    Dec 10, 2016
    Messages:
    463
    Unfortunately, I was not able to get a good comparison between the two... For both meshes, it took way more than I could reliably place in the editor to see an impact with this system. I'll have to try with my older computer at a later time.

    Another question I have is, do duplicated forest items get cleaned out automatically if they share the same pos, rotation, scale, and mesh? I noticed that the number of overlapping forest items when reloading a map is lower than the number of static meshes when I copy-pasted without moving them. Logically, this would point to that case, but I want to be sure it isn't due to some other quirk in the world editor.
     
  20. nekitu

    nekitu
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 18, 2018
    Messages:
    87
    I will have to check that to see if there is any test for overlaps on load. Normally only when placing there is the radius test to not overlap them.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice