Jump to content

Batching trees together using Flora

Go to solution Solved by Adam,

Recommended Posts

I have a large map, though my batch count is almost 20,000. My FPS is around 60 but I know it can improve if I drop that batch count.


Knowing Flora supports GPU batching, does anyone know how to use Flora to batch together trees instead of terrain details?



Link to comment
Share on other sites

We are currently working on a new flora system. 
The flora system, will be a standalone system but it will handle trees, grass, etc. 
Currently we have an idea but just in case I will say it will release soon hehe. 

Link to comment
Share on other sites

So as it stands right now, there's no way to GPU instance trees using the Flora system? Why does it say you can in Gaia Pro 2021?

"Gaia Pro 2021 - Gaia 2021 PLUS:

Multiple pre-configured biomes
Massive world support with streaming
Additional stamping, erosion & masking operations
Modular design, use as much or as little as you want
HQ Photogrametry Enhanced Biome Assets & Presets
Low-poly-style & impostor mesh terrain conversion
Flora - GPU accelerated grass & tree rendering system
Photo Mode - awesome runtime photo creation system
World Space Masks - world space image and distance masks
Terrain Addition / Deletion support - dynamically grow your world
Biome Based Stamping - shape your terrain as part of your biome
Multiple skies, lighting (including time of day), vfx & sound fx systems
MMO friendly export for client / server (colliders / addressables)
Terrain Stitching - dynamically connect terrains to remove gaps
Weather system with rain and snow support
GAIA API - call Gaia functions within editor."

Link to comment
Share on other sites

  • Solution

Kind of a long story. 

Flora's grass is GPU accelerated. And it also brings grass to HDRP.

When we wrote this, the person who created Flora was still with the company, and we were told that tree acceleration was almost ready - literally, we were talking less than a week. That person left the company unexpectedly due to a personal emergency, and the tree part was never completed.

Flora was something that we did as an unexpected freebie for Gaia Pro 2021 users because HDRP does not support grass rendering, and it never occurred to us until you pointed it out that we still have something out there on the asset store. 

I have now rectified this on the asset store so that nobody else gets caught out with it. It was an innocent mess up on our part due to an unexpected series of events.

We have spent the past six or so months rewriting Flora from the ground up, and will soon be launching it as a stand-alone asset for those that do not need or want Gaia in their projects, and as an upgraded / free plugin for Gaia Pro 2022, which is due in the next month or so.

The new Flora does support trees, and in fact, the ability to inject and render any object this way and it does a whole lot more as well. The new system is also more than twice as fast as the old system and does some amazing things with grass and tree blending into the terrain, kind of like what the breath of the wild does. Even our early example of this at its current state of development is remarkable.

We will not be retrofitting the new Flora back to the old Gaia.

Link to comment
Share on other sites

Well that's good to know. I was really wondering if I was missing something haha, thank you for clearing that up!

For my game I need to GPU instance all of my trees, and when a player gets close to any tree it needs to convert that tree instance on the terrain to a real gameobject so it can be interacted with (destroyed, broken into pieces, etc) and then stored on some sort of server-side data structure which states it was broken.

Would the best route for this be to, during runtime, convert all trees from the terrain trees array into a matrix array, do the graphics instancing, and then work my own magic code to replace any trees with real gameobjects. Then when it's destroyed, make sure to remove it from the matrix array? Something along the lines of that?

Or is there some optimizations I can do to avoid that, and instead keep all trees on the unity tree system and do a similar approach without the manual draw calls (Possibly using terrain scenes for performance boost)?

Which, speaking of, I created a 512x512 resolution 20x20 (400 total terrains) scene setup with Gaia Pro 2021 and it seems to have completely broken haha. The map editor looks good and all the preview works etc, but when I go to generate world it just breaks and gives a lot of errors and it does make all the scenes, but it doesn't properly height or texture the terrain. Main error was (when ran in the editor) about how it couldn't load the generated scenes because they weren't in the build settings, and when I added them to the build settings it just didn't really work at all.

Sorry for all the long issues, but I'm just trying to wrap my head around the best way to tackle this issue. If I could get some help that would be great! 🙂

Thank you!

Link to comment
Share on other sites

4 hours ago, Moddingdudes said:

Would the best route for this be to, during runtime, convert all trees from the terrain trees array into a matrix array, do the graphics instancing, and then work my own magic code to replace any trees with real gameobjects. Then when it's destroyed, make sure to remove it from the matrix array? Something along the lines of that?

Yes, that is roughly how that would work. Note though that if you just have a big matrix of trees and ask unity to render them GPU instanced in one go, there would be no frustum, occlusion or distance culling taking place, you would need to implement that as well else I would assume you would not get a performance benefit from the instanced rendering anymore.

5 hours ago, Moddingdudes said:

when I go to generate world it just breaks and gives a lot of errors

Could you please post the full error messages from the lower part of the console window? I just tested 20 by 20 @512 and I did not run into any errors, if we have the error message we might be able to tell what is disturbing the generation process.

Link to comment
Share on other sites

Okay I'll write my own culling and batching system. It would be easier this way anyways since it has to be multiplayer and I need to ID all the trees so I think it's for the best.

I retried the 20x20 terrain at 512 size and I didn't get any errors during world generation or biome spawning and it worked well. However, when I go into runtime I get null reference errors and scene load errors. Errors are posted below with my settings.

Any help is appreciated. Thanks! 🙂


World size - Custom

X tiles - 20 Y tiles - 20

Tile size - 512 meters Sq

Tile Height - 2048

Create terrain scenes - True

Unload terrain scenes - True

Floating Point Fix - True

Recenter on Update - False

Target platform - Desktop

Target Biome - Giant Forest

Workflow - World Designer (Random Generation)



Null reference error referring to Fly Camera.

NullReferenceException: Object reference not set to an instance of an object
Gaia.TerrainScene.LoadScene (UnityEngine.SceneManagement.Scene scene, System.Boolean& loadRequested, Gaia.LoadState& loadState, System.Boolean isImpostor) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainScene.cs:441)
Gaia.TerrainScene.UpdateLoadState (System.Collections.Generic.List`1[T] referenceList, Gaia.LoadState& loadState, System.Boolean& loadRequested, System.Boolean& unLoadRequested, System.Boolean isImpostor) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainScene.cs:303)
Gaia.TerrainScene.AddRegularReference (UnityEngine.GameObject gameObject) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainScene.cs:144)
Gaia.TerrainLoaderManager.UpdateTerrainLoadState (Gaia.BoundsDouble loadingBoundsRegular, Gaia.BoundsDouble loadingBoundsImpostor, UnityEngine.GameObject requestingObject, System.Single minDistance, System.Single maxDistance, System.Single minThresholdMS, System.Single maxThresholdMS) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainLoaderManager.cs:1030)
Gaia.TerrainLoader.UpdateTerrains () (at Assets/Procedural Worlds/Gaia/Gaia Pro/Scripts/MultiTerrainSystem/TerrainLoader.cs:190)
Gaia.TerrainLoader.Update () (at Assets/Procedural Worlds/Gaia/Gaia Pro/Scripts/MultiTerrainSystem/TerrainLoader.cs:103)
Scene 'Assets/Gaia User Data/Sessions/GS-20220709 - 002348/Terrain Scenes/Terrain_9_11-20220709 - 002827.unity' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
To add a scene to the build settings use the menu File->Build Settings...
UnityEngine.SceneManagement.SceneManager:LoadSceneAsync (string,UnityEngine.SceneManagement.LoadSceneMode)
Gaia.TerrainScene:LoadScene (UnityEngine.SceneManagement.Scene,bool&,Gaia.LoadState&,bool) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainScene.cs:432)
Gaia.TerrainScene:UpdateLoadState (System.Collections.Generic.List`1<UnityEngine.GameObject>,Gaia.LoadState&,bool&,bool&,bool) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainScene.cs:303)
Gaia.TerrainScene:AddRegularReference (UnityEngine.GameObject) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainScene.cs:144)
Gaia.TerrainLoaderManager:UpdateTerrainLoadState (Gaia.BoundsDouble,Gaia.BoundsDouble,UnityEngine.GameObject,single,single,single,single) (at Assets/Procedural Worlds/Gaia/Scripts/MultiTerrainSystem/TerrainLoaderManager.cs:1030)
Gaia.TerrainLoader:UpdateTerrains () (at Assets/Procedural Worlds/Gaia/Gaia Pro/Scripts/MultiTerrainSystem/TerrainLoader.cs:190)
Gaia.TerrainLoader:Update () (at Assets/Procedural Worlds/Gaia/Gaia Pro/Scripts/MultiTerrainSystem/TerrainLoader.cs:103)

*Note: I generated Runtime using the Gaia Manager. Settings were default

Link to comment
Share on other sites

Closing this ticket. All I had to do was click the "Load scenes into build settings" button on the Terrain Loading Manager. Simple fix 🙂 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

  • Create New...