Jump to content

Spawn single trees based on masks


Recommended Posts


I'm currently building my home town based on GIS dataset and Gaia is used to solve the foliage part, since it is a huge area.  So I have to automate it as much as possible.

I've exported GIS data of single trees (normally as points) to a polygon of a cicle at around 100 cm (1 unity unit)  The area is 1x1 km and the mask image is a black/white png in 16K (in order to obtain a good resolution based on the large area)

I got the spawner working. Created a custom Biome and added a spawn rule to spawn trees based on a image mask.  Works like a charme, but I always spawn multiple trees in one area.  If I make the circle smaller (50 cm) it doesn't spawn the trees and I have to set the "Location Increment to below 1 in order to get it working)  But the issue is still the same.

My question is:

Is it possible to make i only spawn a tree within a certain radius, so they don't tough each other.  Some kind of collionsion detection within the spawner?

Other suggestions are welcome as well.




Link to comment
Share on other sites

I would take a look at this. 
However, the short and sweet version. 
I think you should be able to decrease the spawn probability rate. 
Then increase the location increment. 
Maybe adjust the Min Fitness as well. 

We do have a collision mask: 

This should help you. 


Link to comment
Share on other sites

Thanks for the answer Bryan.  I've looked into the manual as you posted and I can see there is a lot of options I have to look into.

However I tried to simplify my options and I still can't seem to figure out why it spawns the at diffent distances from the masked areas. See below.  I added the mask and switched the prefab to a simple cube.

Everything is set to 0, so it doesn't do any offsets and I made it highlight the masks with green (and added the mask as the texture to the terrain.

The image is the terrain area seen from above with no perspective.  As you can see on the image - the cubes are randomly placed - some closer to the center and some outside the masked area.

Any suggestions on how I can get them to fit more in the center of the circle?

Could be something regarding the console error
IndexOutOfRangeException: Index was outside the bounds of the array.
Gaia.SpawnerEditor.DrawSpawnRuleCollisionMaskListHeader (UnityEngine.Rect rect) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/SpawnerEditor.cs:468)
UnityEditorInternal.ReorderableList.DoListHeader (UnityEngine.Rect headerRect) (at <434908727417408abd02bbd1a0835ef8>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at <434908727417408abd02bbd1a0835ef8>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect) (at <434908727417408abd02bbd1a0835ef8>:0)
Gaia.CollisionMaskListEditor.DrawMaskList (System.Boolean& listExpanded, UnityEditorInternal.ReorderableList list, PWCommon5.EditorUtils editorUtils, UnityEngine.Rect rect) (at Assets/Procedural Worlds/Gaia/Scripts/MaskSystem/Editor/CollisionMaskListEditor.cs:75)
Gaia.ImageMaskListEditor.DrawMaskListElement (UnityEngine.Rect rect, System.Int32 index, Gaia.ImageMask[] imageMasks, Gaia.CollisionMask[]& collisionMaskListBeingDrawn, PWCommon5.EditorUtils m_editorUtils, UnityEngine.Terrain currentTerrain, System.Boolean isStampOperation, Gaia.ImageMask copiedMask, UnityEngine.Texture2D headerBGTexture, UnityEngine.Texture2D errorTexture, Gaia.GaiaSettings gaiaSettings, Gaia.GaiaSessionManager gaiaSessionManager) (at Assets/Procedural Worlds/Gaia/Scripts/MaskSystem/Editor/ImageMaskListEditor.cs:856)
Gaia.SpawnerEditor.DrawSpawnRuleMaskListElement (UnityEngine.Rect rect, System.Int32 index, System.Boolean isActive, System.Boolean isFocused) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/SpawnerEditor.cs:608)
UnityEditorInternal.ReorderableList.DoListElements (UnityEngine.Rect listRect, UnityEngine.Rect visibleRect) (at <434908727417408abd02bbd1a0835ef8>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at <434908727417408abd02bbd1a0835ef8>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect) (at <434908727417408abd02bbd1a0835ef8>:0)
Gaia.ImageMaskListEditor.DrawMaskList (System.Boolean& listExpanded, UnityEditorInternal.ReorderableList list, PWCommon5.EditorUtils editorUtils, System.Boolean helpEnabled) (at Assets/Procedural Worlds/Gaia/Scripts/MaskSystem/Editor/ImageMaskListEditor.cs:256)
Gaia.SpawnerEditor.DrawSingleRule (Gaia.SpawnRule rule, System.Int32 spawnRuleID, System.Boolean helpEnabled) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/SpawnerEditor.cs:5489)
Gaia.SpawnerEditor.DrawSingleRulePanel (Gaia.SpawnRule rule, System.Int32 ruleIdx) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/SpawnerEditor.cs:4752)
Gaia.SpawnerEditor.DrawRegularSpawnRules (System.Boolean helpEnabled) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/SpawnerEditor.cs:4469)
Gaia.SpawnerEditor.DrawSpawnRulesPanel (System.String nameKey, System.Action`1[T] contentMethod, System.Boolean& toggleAllState, System.Boolean unfolded) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/SpawnerEditor.cs:4237)
Gaia.SpawnerEditor.OnInspectorGUI () (at Assets/Procedural Worlds/Gaia/Scripts/Editor/SpawnerEditor.cs:1565)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <ff89fb38964845c29edc50ca2bfe23af>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)



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