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

Flora - Advanced Foliage System

Discussion in 'Assets and Asset Store' started by MA-Rob, Jul 21, 2023.

  1. Neiyra

    Neiyra

    Joined:
    Apr 19, 2016
    Posts:
    28
    Thanks for the answers. :)
    I bought Flora yesterday and give it a try. Looking forward to the Updates, especially the converter.
    Thanks a lot!
     
    MA-Rob likes this.
  2. Jack_Martison

    Jack_Martison

    Joined:
    Jun 24, 2018
    Posts:
    85
    Does anyone having HDRP FPS metrics? URP and BiRP is great, but HDRP is pretty heavy from the very start, would be event better comparing Flora to MV
     
  3. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    FPS with HDRP will be highly dependent on what HDRP features are enabled and how complicated your meshes are.

    As for MV, do you mean MicroVerse? If so, they aren't really competitive solutions - MV is for procedural terrain modifications and instance placement, while Flora is for rendering and manual placement. Flora will work with MV soon.
     
    Lars-Steenhoff likes this.
  4. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    543
    URP 2022.3.5LTS I assume its a known issue?

    upload_2023-8-1_15-33-24.png
     
  5. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    I’ve gotten this error before, it’s something to do with Burst. I need to reach out to Unity about the error. Right now, restarting Unity should fix the error.
     
    Rastapastor likes this.
  6. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    Grabbed Flora a while ago and started fiddling around with it but I can't seem to be able to paint instances in the example scene using 2022.3.5f1 with URP. It throws an error when attempting to paint, seems it's related to either jobs or collections.
    https://www.dropbox.com/scl/fi/m9wv...L4e.webm?rlkey=jgckb2gqpwshiko7ketra76zj&dl=0

    A restart does not help, sadly. There's also this error popping in on every startup:


    After a restart, I randomly get different errors. When it works without any errors and the gizmos do display properly, trying to paint anything just doesn't produce any instances on the terrain.

    Here's a vid after restarting: https://www.dropbox.com/scl/fi/iann...hzd.webm?rlkey=kss4rpulnben4riht4d61iecj&dl=0

    Any ideas for 2022.3? :D
     
  7. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    Additionally, what helps clear the errors is reloading a layout (Window>Layouts>Default) but then it still does not add/remove any instances.

    Unity_QHpV4T0D9m.webm (dropbox.com)

    The only thing that actually works for me, is the mesh fill option :)
     
  8. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    Try updating the unity collections package in the package manager to the latest?
     
  9. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    Up on the latest available for 2022.3 :(

    2.1.4
     
  10. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    Yes I just imported the latest version of Flora and have the same now, cannot paint only fill.
    This seems to be a bug in this version of Flora, as before I used it in unity 2022.3.5 with URP ( on MAC and PC )
     
    Bwacky likes this.
  11. DaviDeMo

    DaviDeMo

    Joined:
    Nov 13, 2017
    Posts:
    15
    Hi! Just bought your asset! Waiting for the support of terrain details so I don't need to convert everything and redo manually :D
     
    sirleto and MA-Rob like this.
  12. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Sorry it hasn't been working! The last update had an error in the brush tool. I just submitted an update that fixes the tool and the errors/warnings you were getting.
     
    Bwacky and Lars-Steenhoff like this.
  13. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Bwacky and Lars-Steenhoff like this.
  14. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    Already painting and works like a charm!
    The only remaining issue I see is Collections losing its mind. Nature Renderer had that issue in the past, albeit not sure how they fixed it. It's quite common for some reason :D

    If you don't mind some minor QOL suggestions for a roadmap (if you have/plan to make one):
    1. Rename Prototypes (once I add/replace an instance in a container I can't change the name of it, need to fully remove and re-add (can and deffo will get confusing once you replace prefabs over time).
    2. Duplicate entry option.
    3. Copy-paste option for prototype settings would be neat too.

     
  15. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Okay think I found the collections issue. Did you notice an order of events where this error always occurs or is it seemingly random?

    Roadmap suggestions is something we'll definitely think about for our website when we get it going.

    1. The name in the prototypes is just based on the filename of the prototype. Or are you talking about prefab instances not updating with the name of the prototype?
    2. Currently you can only have one of each prototype in a container, are you asking to be able to duplicate the prototype file from the container inspector?
    3. Currently you can save presets of the prototypes and use that to copy settings around, or do you want more specific copy options?
     
  16. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    Just updated too and have no errors for collections on Mac.

    - Add a preview when using single instance mode with the paint tool.
    Awesome!
    ( does not work yet with wacom only shows when using the mouse)

    - Add event pressure for tablet support with the brush tools in 2022.1+. Currently only works with density (more options to come).

    Would scale be a possible option? or is that not allowed for instancing?

    And I have idea about a feature related to pressure, that is to allow for different objects per pressure level to be painted. for example low pressure is grass, medium is flowers and strong is trees. may need some good UI to make it easy to setup.

    And a thing that is a bit tedious is that if no prototype is active in the flora container and you want to paint, it selects the object under the mouse and deselects the flora container. while this may be the desired behaviour it still confuses me sometimes why the flora container is deselected when I turn off all paintable prototypes and I tried to paint or delete something.
     
    Last edited: Aug 4, 2023
  17. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    It's a bit hidden right now, I'm considering just moving single instance mode to its own tool so it's more visible. Preview for the sphere/circle mode will take more time and thought.



    Ya this will definitely be an option, but I need to design a nice UI for it; so it will take a bit longer.

    That makes sense, I'll ensure you can't select anything else unless you hit Esc or deselect.
     
    Lars-Steenhoff likes this.
  18. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    1. Once you replace a prefab in the prototype entry, it keeps the old name it had. So if you replace the grass with a fern later, it'll still be called grass and you gotta remember. Small issue ofc, but figured it's worth a mention.

    2. Simply put, right-click> duplicate as an option here, to have the same instance below so I can just swap a different prefab in/out :)

    3. Presets are great to know about, just haven't realized they exist. Gonna search for them later :D
     
  19. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    Also there's this happening when I open a project with a scene running Flora now.

    Loading it takes about 60 seconds, once it loads there's a console error popping up.

    Despite all that, Flora seems to work as expected.
     
  20. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    The reason for this is the prototype doesn't necessarily represent the prefab 1:1. For instance in the demo, the Grass and GrassTall prototypes are using the same prefab. The difference is in their density, radius, and their scale values (the tall grass elongates on the Y axis). I don't necessarily want to restrict the naming of the prototype to the prefab's name. I could see it maybe being part of some kind of validation... e.g. if an option is enabled, warn the user if the prototype name doesn't contain the prefab name.

    Another example would be having Grass (Dense) or Grass (Sparse), with differing density values.

    One thing I could add is a way to actually replace the prototype on a container, so you could actually swap out prototypes while keeping the instance positions.

    I think I've found this and the above errors. Should have an update out by Monday.
     
    Last edited: Aug 4, 2023
    Lars-Steenhoff and Bwacky like this.
  21. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    This sounds very useful!
     
    MA-Rob likes this.
  22. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    Sorry if this is a stupid question but how do I do the following : "you must include the Flora Instancing Setup node in your ShaderGraph." I have no clue what I'm doing with regards to ShaderGraph ? an explanation for Dummies would be good.. Thanks for your help.
     
  23. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Sure thing. All it means is you need to add the `Flora Instance Setup` node you your ShaderGraph so that a Position (Object Space) node connects to the input, and its output goes into the Vertex Position:



    This node doesn't do anything except ensure the Flora header files are included, and instancing is enabled with the ShaderGraph so you can use the shader's materials with Flora.

    In the next update, having the input connected will be optional and will default to the Vertex Position.
     
    Last edited: Aug 5, 2023
  24. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    Thanks but still confused what do I add this node to ?? is it the URP shader? I am using The Vegetation Engine so is it a shader from that ?? Can you please be a bit more specific. Thanks for your time..
     
  25. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    The vegetation engine added support for Flora, no need to do it manually in a shader, and also the vegetation engine is not using shader graph, it's made with amplify.

    If what you are asking is how to make Flora work with Vegetation engine then read more, if not then please ignore.

    You need to have the latest version of the vegetation engine and go to:
    Window > BOXOPHOBIC > The vegetation Engine > Shader Manager.
    Here you can choose Flora from the render engine support.

    Screenshot 2023-08-06 at 00.19.30.png

    Please keep in mind that I did not yet test it myself, but this should work.
     
    emarosagamingco and MA-Rob like this.
  26. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    Oh thank you thats exactly what i was looking for. :D
     
    MA-Rob and Lars-Steenhoff like this.
  27. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    Ok after hours of trying still cant get this to work properly.. I've tried 3 different Unity versions, I've tried with The Vegetation Shaders (Can only use fill). Tried in a blank URP project with Synty Nature Assets and Dreamworld assets too. I cannot seem to now create a Flora Prototype with out the following errors.... (SAD FACE).. Maybe you should do a video tutorial for beginners. Thanks. image_2023-08-08_163608110.png
     
  28. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Can you post a screenshot showing the prefab you're trying to assign to the prototype?
     
  29. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    ok here it is : image_2023-08-08_170619176.png
     
  30. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    I meant the model, the "SM_Tree_Birch_01 1", this is the Flora prototype (which you would add to the Flora Container).

    That error is just an inspector error, probably just a bug with the inspector (it won't affect running Flora). I'll make sure it's fixed in the next version.

    To me, it looks like everything is fine on this end. Have you added it to your "Flora Container" in the scene? Can I see what happens when you actually try to paint with it?

    Select the "Flora Container" and make sure the prototype is added under the Prototypes section. Then click the checkbox next to it (to activate it for painting), and make sure the Paint tool is selected in the scene toolbar.
     
    Last edited: Aug 8, 2023
  31. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    ok there you go : when I try to paint I get the Green dome but pressing the left mouse button does nothing ? image_2023-08-08_172643198.png
     
  32. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Okay that looks like a legitimate problem. Let me look into it.
     
  33. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    ok thanks
     
  34. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Ok, found the bug. When you create a new container, it's not processing the new instances right away. If you hit play, and then start painting again - they should show up. I'm going to try to get a patch out tonight. Hopefully it'll be approved in the morning and you should be good to go.
     
    Last edited: Aug 8, 2023
    Lars-Steenhoff likes this.
  35. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    @Bwacky
    @saulmcentee

    Patch is live, please let me know if you two are still running into issues.
     
    Bwacky likes this.
  36. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    Works great now. Thanks for the Patch.
     
    MA-Rob likes this.
  37. onefoxstudio

    onefoxstudio

    Joined:
    Sep 28, 2016
    Posts:
    191
    Hi ! Quick question (before purchase); on the way flora works; so if I get it correctly it works mainly on meshes; so if I have another asset that manages terrain they 'can' work together - I saw above that Lars mentioned TVE was working with it good. But on the way it works; I can for example take my cliff prefab; paint grass over it with Flora and then save it to re-instantiate it elsewhere in the scene ? Is it bound per-object or there's some other manager of some kind that stores the data ?

    Using Mac; does it work with Metal - have you seen any issues so far ?

    Too bad I missed the launch sale :(

    Thx!
     
    MA-Rob likes this.
  38. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Flora will work with the terrain or meshes, but it stores and tracks its instances outside of the terrain system. You create a `Flora Container` GameObject, and then paint on any static meshes, or terrains, and the container keeps track of them for you; including if a parent object moves, or the terrain changes.

    Currently, instances are tied to the Flora Container which keeps track of their parents in the scene. For duplicating an object with instances: that's not implemented yet, but it actually wouldn't be too hard to do. I could definitely look into that.

    I'm also working on a renderer component that will render Unity's standard Terrain instances with the Flora render system, so you'll be able to use both systems in the future.

    As for Metal, there should be no problems - if you run into any problems just let me know!
     
  39. onefoxstudio

    onefoxstudio

    Joined:
    Sep 28, 2016
    Posts:
    191
    Thanks for the very quick reply ! I'll wait for your terrain integration (and the next sale) to jump in. At my stage of development it's not yet absolute must but in the future it will and I will purchase it for sure. Cheers!
     
    MA-Rob and Lars-Steenhoff like this.
  40. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,449
    Just a confirmation that it's working fine on mac m1 for me.
     
    onefoxstudio and MA-Rob like this.
  41. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Auto shader generator update is live!

    To create an AutoShader asset right click on any Shader or ShaderGraph: Create > Flora > Flora Auto Shader



    This will create a new AutoShader asset. This asset will create an internal shader that inserts the required code for Flora to work.

    Anytime changes are detected in the parent shader, the AutoShader is automatically patched, so you can continue working on the original shader without having to ever modify it for Flora.

    So, if you're using this on a shader from the AssetStore, the AutoShader will update the shader whenever you install an update from the asset store.

    The shader name is always the original shader name + (Flora).



    In the inspector for the AutoShader, you can always change the source shader or view the generated code in case of any issues.



    This hasn't been tested a lot yet, so please let me know if you run into any errors!
     
    Last edited: Aug 11, 2023
    Bwacky and Lars-Steenhoff like this.
  42. Yurij-Chirkov

    Yurij-Chirkov

    Joined:
    Aug 17, 2013
    Posts:
    8
    Hello @MA-Rob

    Please consider adding public API for loading instances directly from a Compute Buffer.

    Across industry, procedural generation packages, such as MicroVerse, Vista, Gaia, all use Compute Shaders to generate geometry and vegetation instances on the GPU.

    It would prove very useful to have a public API to upload instances with a Compute Buffer, without burying it deep in the system.

    I really appreciate the rendering capabilities of Flora. It's the best in my opinion for vegetation instancing. Even better than GPU Instancer.

    Hope you'll consider this! Huge thank for the amazing work you've done already to establish a solid instancing engine.
     
    MA-Rob likes this.
  43. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Unfortunately, it actually wouldn't be possible to upload instances directly via a compute buffer due to the way Flora stores and manages instances.

    Flora's rendering system uses one large compute buffer for all instances in the scene, and sub-allocates regions of it for each instance renderer. It really wouldn't be nice to work with directly as you would need to know what cell you're in, the instance offset, the size of each instance, etc.

    Flora's culling also happens on the CPU - it builds a BVH for each instance renderer. It's why Flora's culling is fast, it's traversing a tree instead of testing every instance individually. The build process for the tree is Burst optimized, but it generally takes longer than a frame, and this process modifies the order of instances in the GPU buffer.

    MicroVerse, Vista, etc. can work directly on the GPU because Unity's terrain system stores height and details in textures. So you can easily access that data on the GPU. The exception to this is trees, which seem to be just a list of transforms. Vista for instance, generates tree instances in a compute buffer, and then copies them back to the CPU and assigns them to the Terrain system.

    So you could generate instance positions on the GPU, but after you'd have to copy that data back to the CPU (buffer.GetData()) and then add them to the Flora container after.

    However, I am working on a conversion tool that will move foliage from a Terrain to a FloraContainer. So after you've used a tool that relies on the terrain system, you can just convert them.

    I'm also going to add a Terrain rendering component that you can just add to a Terrain and benefit from Flora's instancing system. You won't be able to use Flora's instance attribute system since a Terrain stores the instance data differently, but at least you'll be able to use these generation tools easily and later you can even convert them to a FloraContainer.

    Thank you! A lot of work has gone into Flora and I promise it'll just get better with time. Please leave a review if you can, it really helps!
     
    Last edited: Aug 13, 2023
    fendercodes and Lars-Steenhoff like this.
  44. Yurij-Chirkov

    Yurij-Chirkov

    Joined:
    Aug 17, 2013
    Posts:
    8
    Hello @MA-Rob

    Thank you for a very detailed explanation

    When I’ve attempted to integrate Flora within my procedural solution, I’ve used Job system, entirely parallel and bursted and that still was too slow to process data from the terrain to the CPU, performed Cell Segmentation and then had to upload instances on the main thread to Flora.

    Perhaps the segmentation could be done in a Compute Shader, but then still, there’s a main-threaded bottleneck of adding instances to Flora using cpu-bound public API.

    Perhaps the performance could be improved somehow.

    Considering that the bottleneck is adding instances on main thread, maybe AddInstances API could be thread-safe and Bursted, if it’s unavoidable to make the CPU round trip?

    Thanks for considering the possibility. It really could be optimised. Since uploading millions of instances on the GPU takes only a fraction of a second.

    Have a great day!
     
    MA-Rob and Lars-Steenhoff like this.
  45. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Any chance you can show me the code of how you're adding instances?

    The slowest part right now is uploading instances (not necessarily just adding them to the container/renderer). Flora copies all the instance data to a GPU format, then copies them into a smaller GPU buffers, and then writes each buffer into the final instance buffer on the GPU. I still need to streamline the first copy as it shouldn't be necessary.

    There's also overhead in tracking instances, which you wouldn't necessarily need or want when adding and removing instances procedurally. The tracking is mainly there for manually editing instances with the paint tools and tracking their parent GameObjects in case they change. I need to make this optional.

    The terrain fill tool does something like this. It generates the instances in a compute shader, copies them back to the CPU, and then adds them to the container. I had to break the terrain up into tiles and limit the amount per frame. It's definitely something I want to improve.
     
  46. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    Dropped a review just now :D

    I got some terrain renderer questions!
    1. Any estimate of when we could see terrain rendering support?
    2. Will we get both tree and detail rendering?
    3. Will it support LOD Crossfade for URP? That's the biggest issue with Nature Renderer for me right now and I would love to see it in Flora.

    I'll probably have a few suggestions for features related to it once it's out.
     
    MA-Rob likes this.
  47. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Thank you, it's very much appreciated!

    1. Should be about two weeks, I'm almost done with the conversion tool and that's my next task after that.
    2. Both will work, though it will only handle details with prefabs (no grass textures).
    3. Will definitely happen after the terrain renderer update.
     
  48. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    190
    Do you have a Discord server for Flora?
     
    MA-Rob likes this.
  49. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Not yet, but I'm considering it!
     
  50. DaviDeMo

    DaviDeMo

    Joined:
    Nov 13, 2017
    Posts:
    15
    waiting for it, so I don't have to check the forum if there is any update :-(
     
    MA-Rob likes this.