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. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Ok I've decided to setup a Discord server sometime this week!
     
    fendercodes, DaviDeMo, Bwacky and 2 others like this.
  2. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    Hi just updated to the latest version of Flora, using Unity 2022 Screenshot 2023-08-20 180148.png getting the error:
     
  3. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Sorry about the error! There's an update in queue, should be out later today or tomorrow with a fix. That line should read:

    Code (CSharp):
    1. #if UNITY_2022_2_OR_NEWER
    2.             string sourceCode = ShaderGraphImporter.GetShaderText(assetPath, out List<PropertyCollector.TextureInfo> _, new AssetCollection(), out GraphData _);
    3. #else
    4.             string sourceCode = ShaderGraphImporter.GetShaderText(assetPath, out List<PropertyCollector.TextureInfo> _);
    5. #endif
     
  4. saulmcentee

    saulmcentee

    Joined:
    Jul 7, 2015
    Posts:
    15
    Fixed thank you :)
     
    MA-Rob likes this.
  5. GoldFireStudios

    GoldFireStudios

    Joined:
    Nov 21, 2018
    Posts:
    154
    This was a nice surprise to stumble across, it's looking really great! We're currently using GPU Instancer, but we've been considering switching to Nature Renderer. This is now on our radar as well, but I was curious about on thing. Any plans to add occlusion culling like what GPU Instancer has? In certain instances it can have a really big impact on performance (and supposedly this is coming soon to Nature Renderer as well).
     
    MA-Rob and Lars-Steenhoff like this.
  6. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Thank you! Yes there is a plan to implement something like HZB culling, but I have a few things to finish first. One thing that will be the next few updates is having Flora hook into Unity's static occlusion culling system.
     
  7. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,450
    Congratulations on the getting the new release out.

    I did find a few names were not fully readable in the inspector, please see screenshot.
    ( spawn prefab instances , cull shadows separately , calculate interpolated L , etc)

    Screenshot 2023-08-23 at 18.02.51.png

    The new select prototypes instance window is really cool !
    Screenshot 2023-08-23 at 18.04.27.png
     
    MA-Rob likes this.
  8. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Ah good point! I'll try to figure out why the window isn't resizing properly.

    Thank you, glad you like it!
     
    Last edited: Aug 23, 2023
    Lars-Steenhoff likes this.
  9. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    Hello, loving the asset so far! I just started getting this error when I try adding the Flora Instancing Setup node and Position node to my shader graph and connecting them as shown in the docs. When I save and it compiles the shader, I get:


    [Error] Shader error in 'Shader Graphs/Cel Shaded Flora': undeclared identifier 'unity_SpecCube0_HDR' at Arcade/MA.Flora/ShaderLibrary/FloraInstancing.hlsl(138) (on d3d11)
    Shader Error at /Shaders/Cel Shaded Flora.shadergraph:138
    136: <Color=#FFEB04>"m_SlotId"</Color>: 0
    137: <Color=#808080>}</Color>
    138: <Color=#808080>}</Color>,
    139: <Color=#808080>{</Color>
    140: <Color=#FFEB04>"m_OutputSlot"</Color>: <Color=#808080>{</Color>


    What's odd is the material doesn't render in the scene or game views, but it renders in the preview windows. Thanks ahead for any tips!!
     
    MA-Rob likes this.
  10. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Glad you're enjoying the asset! Ah, unity_SpecCube0_HDR and unity_SpecCube1_HDR don't exist in HDRP. Just now wrapped them in a define and fixed it. If you want a quick fix, just delete the following lines:
    Code (CSharp):
    1. unity_SpecCube0_HDR = flora_SpecCube0_HDR;
    2. unity_SpecCube1_HDR = flora_SpecCube1_HDR;
    I had another update in the queue and was able to quickly update it with this. Should be an update with a fix by the end of day or tomorrow morning.
     
  11. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Fix is live!
     
    Lars-Steenhoff likes this.
  12. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    Thanks so much for such a speedy response and fix!! The shader compile error is gone now, however the material still doesn't render. I've tried recompiling the shader by deleting a node, saving, and then adding it back and saving again, but my vegetation is invisible at the moment. If I disconnect the Flora Instancing Setup node and recompile, the material renders on normal gameobjects, but when I reconnect it, they disappear.

    I'll have a chance a little later today to try importing Flora into a totally new HDRP project, I can't be sure I don't have some asset that's interfering somehow. But I thought I'd see if you had any other ideas! Thanks again!
     
  13. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Odd, is this 2022.3? I just made a new HDRP project with the Flora version from the store and the ShaderGraph node seems to be working. Though I noticed the included sample Flora ShaderGraph gets corrupted by HDRP. Can you double click the Setup node and re-save it? Make sure it doesn't have any errors.
     
  14. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    Yep, 2022.3.
    When I re-save the Setup node I do get an error:


    [Error] Asset import failed, "Assets/Magnetic Arcade/MA.Flora.Demo/Environment/Flora/Flora.shadergraph" > InvalidOperationException: Cannot add a null object : MainAsset
    UnityEditor.ShaderGraph.ShaderGraphImporter.OnImportAsset (UnityEditor.AssetImporters.AssetImportContext ctx) (at ./Library/PackageCache/com.unity.shadergraph@14.0.8/Editor/Importers/ShaderGraphImporter.cs:233)
    UnityEditor.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.AssetImporters.AssetImportContext ctx) (at <97436df440ca462884c5332c1d8ebbe7>:0)
    UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

    EditorApplication.Internal_CallGlobalEventHandler()


    It kinda sounds not like a problem with Flora, but with my project, and that maybe I have to rebuild my Package directory... but not sure.

    EDIT: I deleted the Demo folder and re-saved the Setup node, this time there weren't any errors, but the material is still invisible.
     
    Last edited: Aug 24, 2023
  15. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    Try to repro in a clean new hdrp project.
     
  16. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    I found my issue. My position node was set to World instead of Object!! The material works as expected now!
     
    MA-Rob likes this.
  17. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    I saw this, the example Flora ShaderGraph is pointing at an invalid Diffusion Profile in HDRP and it stalls when you try to open it. I have to fix the reference in an update.

    Nice! Glad you figured it out! By the way, if that's the only node going into the Vertex Position slot, the node doesn't need an input - it will default to the Object Space Position.
     
    sordidlist likes this.
  18. papatoma

    papatoma

    Joined:
    Jan 19, 2021
    Posts:
    3
    Hi, I have a question. Does Flora use billboarding in any case? I have this artisitc style of pixelated "sprites" in 3D environment and I would like them to face the camera all the time. Currently the out of the box terrain editor works for me just fine but it blurres the textures and also I would like to paint on object.
     
    Lars-Steenhoff likes this.
  19. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,450
    Point filtering should provide the pixelated clean look, and mip mapping also would need to use the same type of filtering, did you try that?

    Edit: Yes I see you tried it.
     
  20. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    Hello, long time, no chat!
    When I attempt to change the density of the painter, I get this warning:

    I've tried creating new prototypes and a new container, but I get the same warning. The painter still paints great, but the density doesn't change.

    This happens for me in HDRP.


    EDIT -- Sorry, I should say I'm trying to change the density of the prototype, I realize the painter density is a different control. Is this what I'm doing wrong?
     
  21. sordidlist

    sordidlist

    Joined:
    Sep 2, 2012
    Posts:
    86
    After a little bit, I also started getting this warning - seems like it might be related to the above issue

     
  22. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    190
    @MA-Rob Do you have an ETA on when Flora will support rendering terrain trees/details and also top down projection of instances on meshes like cliffs?
     
  23. Dark-1-Games

    Dark-1-Games

    Joined:
    Mar 26, 2014
    Posts:
    99
    Hi,
    Interested in purchasing Flora, just wondering if the foliage render system renders motion vectors? It's essential for TAA and FSR 2
     
  24. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    There's no builtin billboard option yet, but you can point a quad mesh at the camera with a shader.

    Thank for letting me know! I've fixed the issue, will be in the next update!

    No exact ETA yet, I've been mainly fixing bugs but also laying the ground work in the API for Terrain support. I have a rudimentary version working, but I need to optimize it and create the UI for interacting with it.

    Flora renders motion vectors just fine!
     
    papatoma and Lars-Steenhoff like this.
  25. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,450
    Is there a way to convert already placed Gameobjects ( prefabs or just hierarchy GO ) to instances ?

    For example I have a scene that is a racetrack with a lot of city buildings, what if I wanted to convert those buildings to instances, without losing their placement, and they are not yet Flora objects.


    And also the other way around, sometimes I could see a case for converting placed instances back to normal placed game objects that I can select in the hierarchy.
     
    Last edited: Aug 25, 2023
  26. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Not yet... I need to write an interface that collects the GameObjects, sorts them by prefab, lets you select or create a prototype for them, and then adds them to the container.
     
  27. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    New update is out! Lots of bug fixes and performance improvements.
     
    Lars-Steenhoff likes this.
  28. DaviDeMo

    DaviDeMo

    Joined:
    Nov 13, 2017
    Posts:
    15
    discord server? :D
     
  29. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Haven’t had the time yet, soon though!
     
  30. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    543
    I saw there was a support for instanced indirect added, but the docs dont mention it? What is the way to enable it on the grass for instance ?
     
  31. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Full documentation is coming soon. Indirect instancing is always enabled right now, you don’t need to change anything.
     
    Last edited: Sep 3, 2023
    Bwacky likes this.
  32. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    How's instanced indirect with LODs like? I remember a lot of assets tend to have issues doing LOD when indirect is in use, works with Flora? :0
     
  33. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    I haven't seen any issues with LODs, and honestly there's not a huge difference between the old implementation. Indirect instancing really just lets me call Unity's Graphics pipeline a little less, which shaves off a little time on the CPU. If it becomes problematic for any reason, I'll add a global setting for turning it on and off.

    Right now there's two scenarios where Flora takes advantage of indirect instancing:
    1. This isn't common, but all submeshes of a mesh that share the same material will be a single indirect call.
    2. When submitting a separate shadow pass, all submeshes that share the same shader and alpha test mode will be combined into one indirect call. Here I'm assuming that if these two things are true, the depth output will always be the same.
     
    Bwacky likes this.
  34. Bwacky

    Bwacky

    Joined:
    Nov 2, 2016
    Posts:
    171
    Amazing, can't wait to go take a stab at it.
    Do we have an estimate on terrain support by any chance? Any API planned so we can control, let's say, render range or density in the distance using a component on a camera? :D:D
     
    MA-Rob likes this.
  35. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Terrain support is taking longer than expected, mainly because I've had to redesign a lot of the API to support it efficiently. But I'm almost done with making the core changes. It is coming!

    For render range, the FloraCamera component has its own LODBias that should change the distance instances are rendered dynamically.

    For changing the density in the distance, you can scale instances down using the Flora Instance Fade node in Shader Graph. Scaling the density out in the distance would involve adding a bit of randomness to the fade for each instance - so instances don't all fade out at the same distance.
     
    Last edited: Sep 4, 2023
    Bwacky likes this.
  36. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    GoldFireStudios and Bwacky like this.
  37. emarosagamingco

    emarosagamingco

    Joined:
    Aug 2, 2023
    Posts:
    2
    Hi! I just started used Flora and it certainly looks interesting! However, whenever I create a flora container, it completely disables character movement. This is resolved by deleting the container. Are you able to provide some assistance?
     
  38. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Are you selecting the container when you're playing? Flora creates colliders for meshes without them when you select the container. This is done so you can paint on them. I don't think there's a check for not doing this during Play. Can you disable the "Add Occluders" option in the painting section of the container and see if that fixes the issue?
     
    emarosagamingco likes this.
  39. emarosagamingco

    emarosagamingco

    Joined:
    Aug 2, 2023
    Posts:
    2
    That worked. Apparently "Flora Container" was still highlighted in the hierarchy and prevented controller input. Selecting a different object in the hierarchy resolved it. No need to adjust the occulders. Thanks!

    Also wanted to say that now that I'm able to play with Flora for a bit: wow. Just wow. :)
     
    Last edited: Sep 8, 2023
    MA-Rob likes this.
  40. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Glad that was it! Also thank you, so glad you're enjoying it! :)
     
  41. Bezoro

    Bezoro

    Joined:
    Mar 16, 2015
    Posts:
    129
    I'm probably doing something stupid, but I can't seem to get Flora to actually paint?
    All steps are done according to the documentation but when I try to actually paint I can't even get the sphere cursor to show up.

    Unity: 2022.3.7f1
    URP: 14.0.8
    Flora: 1.0.9

    I'm trying to test the asset on a big plane, scattering thousands of grass instances to ascertain performance and general features and workflow.

    Btw I am assuming I can use prefabs set up with an LOD Group component with the usual LOD0, LOD1, etc... hierarchy.
    And that the Flora Container doesn't require the objects to be painted on to be its children.

    But for a different question. For a usecase where you'd use a single scene with many chunks (prefabs) making up the world, that get LODd and streamed in/out based on the player camera distance to them, could/should I put 1 Flora Container as a child of each chunk and have each Flora Container deal with rendering only the instances for that particular chunk? Or should I just have one Flora Container always loaded and as the prefab chunks get loaded/unloaded Flora handles everything?
    I hope that makes sense.
     
    MA-Rob likes this.
  42. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    You have it right, should work with any LODGroup or MeshRenderer prefab. If the prototypes are added and active on the container (checked and outlined in green). Make sure "Add Occluders" is checked on the container, and also "Static Game Objects Only" isn't turned on if your plane isn't set to static. Generally if you're not seeing the brush, it's not seeing a collider. Flora adds colliders to meshes that don't have them if "Add Occluders" is on and disables dynamic colliders if "Static Game Objects Only" is checked.

    Generally you want one Flora Container per scene and it will manage the cells itself. The container can only paint on objects in the same scene. Right now streaming isn't implemented however, so it loads everything in the container with the scene. Streaming is coming, but isn't implemented yet. It's not far off though. Once it's in I'll have settings for streaming distances.
     
    Bezoro likes this.
  43. Bezoro

    Bezoro

    Joined:
    Mar 16, 2015
    Posts:
    129
    Managed to get it working, but its only allowing painting onto static objects, regardless of Static GameObjects Only being on or off. Not a big deal since that is probably my use case, but it may be a bug, unless again, I am doing something stupid.

    Looking forward to it, so we can stream some big ass maps full of vegetation.
     
    MA-Rob likes this.
  44. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Sounds like a bug! I’ll look into it. And yup, that’s the plan! :)
     
  45. Bezoro

    Bezoro

    Joined:
    Mar 16, 2015
    Posts:
    129
    Sorry, having a weird error.
    Test scene, big plane filled with grass instances. (500k+. Running like a dream might I add)
    Build fails with a couple shader related errors.
    (Shade Graph Shaders being used on the grass)

    Unity_qkTbVzXUKz.png

    Unity: 2022.3.7f1
    URP: 14.0.8
    Flora: 1.0.10

    --------------------------------------------------------------------------------------
    And a couple more issues:
    - Max Render Distance seems to be capped at 120 units.
    - Start Fade Distance is having different results on Scene and Game views.
    https://www.youtube.com/shorts/VrMnFfF21YI
    (I have it set at 60, with Max Render Distance at 120)​
    ---------------------------------------------------------------------------------------
    Nevermind the above, it was related to the LOD Group Culled value, removing it made it work as expected. Although maybe Start Fade working differently in Scene vs Game views when the LOD Group has a Culled value set may be worth taking a look into.

    Oh, and a couple of questions.
    - Why does Flora use the Jobs package? I thought it got replaced by the Collections package?
    - Is there any way to do cross fade for LODs?
    - Coming from GPU Instancer I found it a little jarring that LOD is done per chunk rather than per instance (I assume it’s more performant and I can live with it) but it would be nice if there was the option.
     
    Last edited: Sep 19, 2023
  46. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Ya this one is strange and I can't seem to reproduce it. Any chance you're using DOTS? Curious if the DOTS instancing header is causing an issue.

    The Max Render Distance needs to be clarified. It was really only meant for meshes without an LODGroup. However, right now Flora takes the minimum of either the LODGroup's cull distance, calculated from the screen percentage and camera FOV, or max render distance. I might hide this property when a prefab with an LODGroup is used, as distances and screen percentages don't go well together.

    As for the different results in the scene. I'm guessing this is because Max Render Distance is being overridden by the LODGroup's culled percentage (which is calculated from the camera's FOV), and then the distance is different between the two cameras. Start Fade Distance should really be a percentage and not a distance because of this.

    1. The jobs package is just there for earlier versions of 2021.3 when the collections package was still partially split between the two.
    2. No cross-fade yet, but It's coming.
    3. Ya this is because instances are grouped together in a BVH for culling performance - there's not an easy solution to this unfortunately. However I could expose some of the values for controlling the granularity at which instances are grouped.
     
    Bezoro and Lars-Steenhoff like this.
  47. Bezoro

    Bezoro

    Joined:
    Mar 16, 2015
    Posts:
    129
    No DOTS.
    This is driving me kinda crazy. I cannot reproduce it on a new project (same settings as the original one), and I cannot fix it in the original one either.
    Its the Flora Setup node, disconnecting it builds fine, the moment i connect it it starts acting up again.
    Tried deleting and reimporting Flora and the entire project as well.
    Its probably some obscure reason... I'll keep poking around.

    Edit.: So... deleting everything but Assets and Packages fixed it, I'll see if I can figure out what exactly was causing it. Looks to be something in the Project Settings.
     
    Last edited: Sep 20, 2023
    MA-Rob likes this.
  48. fendercodes

    fendercodes

    Joined:
    Feb 4, 2019
    Posts:
    190
    @MA-Rob Good to see you're still active despite the recent stress in the Unity community! We're still very keen to switch from Nature Renderer over to Flora as the list of issues with NR increases:
    • Only works with terrain instances and doesn't allow us to paint instances on cliff meshes
    • No proper occlusion culling
    • No LOD crossfade support
    • Lack of prompt support (usually takes 2months+ for a reply)
    Looking forward to when you are able to support terrain and LOD crossfade. We'll start testing once that happens. Any ETA?
     
    Lars-Steenhoff, Bwacky and MA-Rob like this.
  49. Jack_Martison

    Jack_Martison

    Joined:
    Jun 24, 2018
    Posts:
    85
    upload_2023-9-20_7-1-41.png

    Having this type of compile errors in 23.2 any fixes?
     
  50. MA-Rob

    MA-Rob

    Joined:
    Sep 10, 2014
    Posts:
    80
    Hmm, maybe there was some kind of shader caching issue with Unity? That's a tough one to figure out. Let me know if it happens again.

    Ya not happy about the recent Unity events, but I'm not going anywhere.

    I've been putting a lot of work into the core API so that the terrain support works well. I'm working on the terrain implementation now though. Hopefully it won't be much longer.

    I haven't tested 2023.2, so I'm guessing those methods have changed on that version. I'll take a look.