Jump to content

How to run custom imposter terrain code on terrains


namusanga
 Share

Go to solution Solved by Peter,

Recommended Posts

Hey we need to create imposters for a very large map, currently since Gaia does not have the ability to create imposter for a certain set of terrains as opposed to all of them, my computer crashes every time I try to do the terrain imposterization. I need to find a way to create imposters for small chunks of the map and have  Gaia treat them like the usual imposter terrains, the easiest way I can think of is to write a custom editor tool for this and use Gaia's functionality underground, I just need some answers to some questions: 

How does the terrain loader know that one scene is an original and another it's imposter? ( I need this to know how to treat my imposter terrains), do I need to put them in a specific folder? or Give them a specific name? I know this usually happens automatically but since I'm gonna be doing it manually through code, I need to be very specific with this. 

What code runs on each scene that makes an imposter copy of it? So is there a function that takes in a scene and returns an imposter scene or something of that sort, or are they numerous functions?  ( I need this to know what functions to call in my editor tool on each scene) 

Is there a place where the list of terrains is passed into the imposterizer via code? ( if so I can just make my list in my editor tool and pass it in)

 

Edited by namusanga
Link to comment
Share on other sites

Why not just remove the  imposters you don't want, you can select the references and delete them.   check your export, imposter scenes.. They will be there, you also can check your terrain loader, it will let you reference them, load and unload them there too. 

 

Just select which ones you don't want, and delete.   ( I do think there should be a way to select terrains direct to load, unload, you can one by one though. but they need to add selection ability for terrains to load , unload and imposters by selection. This is what is missing for sure.    But for now I would just delete the ones you don't want. 

 

( I do this when the terrains are in a scene.)  Then delete imposters I don't want.

Edited by Recon
Link to comment
Share on other sites

I believe this gets you to the impostor information.
Get a reference to TerrainLoaderManager -> TerrainSceneStorage -> m_TerrainScenes -> ImpostorReferences.
You have to tell Gaia to make imposters.
Look at GaiaManager and find the code that generates imposters and lerk in there for what happens to each scene.
I use different tools to generate impostors but its not hard to integrate with Gaia.
Hopefully that helps.

Link to comment
Share on other sites

9 hours ago, Recon said:

Why not just remove the  imposters you don't want, you can select the references and delete them.   check your export, imposter scenes.. They will be there, you also can check your terrain loader, it will let you reference them, load and unload them there too. 

 

Just select which ones you don't want, and delete.   ( I do think there should be a way to select terrains direct to load, unload, you can one by one though. but they need to add selection ability for terrains to load , unload and imposters by selection. This is what is missing for sure.    But for now I would just delete the ones you don't want. 

 

( I do this when the terrains are in a scene.)  Then delete imposters I don't want.

No that's not the problem, the issue is when I'm generating the imposters unity crashes, not when I'm using them or assigning them anywhere 

Link to comment
Share on other sites

8 hours ago, Asset Glue said:

I believe this gets you to the impostor information.
Get a reference to TerrainLoaderManager -> TerrainSceneStorage -> m_TerrainScenes -> ImpostorReferences.
You have to tell Gaia to make imposters.
Look at GaiaManager and find the code that generates imposters and lerk in there for what happens to each scene.
I use different tools to generate impostors but its not hard to integrate with Gaia.
Hopefully that helps.

Thanks mate, let me try what you've said tonight 

Link to comment
Share on other sites

  • Solution

@namusanga To make a code change to only export a selection of terrains rather than all terrains in the scene you would need to look into the script ExportTerrain.cs, in line 365 it splits up between processing a single terrain, all terrains when using terrain loading, and all terrains in the scene when not using terrain loading.
The function  GaiaUtils.CallFunctionOnDynamicLoadedTerrains is used to process the loaded terrains, it takes on a list of terrain names for processing. If you inject a list of terrain names in there, it should only run on a limited number of terrains.

  • Like 2
Link to comment
Share on other sites

6 hours ago, namusanga said:

No that's not the problem, the issue is when I'm generating the imposters unity crashes, not when I'm using them or assigning them anywhere 

My bad, I missed the crashing part.:)

Link to comment
Share on other sites

It's weird that unity is cashing when creating impostors, because shouldn't it be treated the same way as when spawning, to load the terrain and unload it after the impostor is created and placed in a folder ?  Don't understand why PC ram is disappearing and results in a crash.. 

Link to comment
Share on other sites

5 hours ago, Mattis89 said:

It's weird that unity is cashing when creating impostors, because shouldn't it be treated the same way as when spawning, to load the terrain and unload it after the impostor is created and placed in a folder ?

The difference is that the spawner is running in a co-routine and is deliberately making small breaks which allow unity to catch up and remove unused stuff from memory. The terrain mesh exporter was originally only a small script that would export a single terrain into a mesh and has since then further and further expanded but does not run in a co-routine yet, which it should, we will change this soon.

  • Thanks 1
Link to comment
Share on other sites

At 100 terrains / 512 , I get this errors message after creating mesh AND impostor.. NO crash though

 

 

Error while processing multiple dynamic loaded Terrains, Exception: Out of memory  Stack Trace:   at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_array_new_specific(intptr,int)
  at UnityMeshSimplifierGaia.ResizableArray`1[T].IncreaseCapacity (System.Int32 capacity) [0x00000] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Mesh Simplifier\Runtime\Utility\ResizableArray.cs:135
  at UnityMeshSimplifierGaia.ResizableArray`1[T].Resize (System.Int32 length, System.Boolean trimExess, System.Boolean clearMemory) [0x0001a] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Mesh Simplifier\Runtime\Utility\ResizableArray.cs:164
  at UnityMeshSimplifierGaia.MeshSimplifier.set_Vertices (UnityEngine.Vector3[] value) [0x00015] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Mesh Simplifier\Runtime\MeshSimplifier.cs:240
  at UnityMeshSimplifierGaia.MeshSimplifier.Initialize (UnityEngine.Mesh mesh) [0x00040] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Mesh Simplifier\Runtime\MeshSimplifier.cs:2010
  at Gaia.ExportTerrainUtility.SetupGameObject (System.Collections.Generic.List`1[T] LODSettingsList, System.Int32 index, UnityEngine.Terrain terrain, System.String objFileName, System.String textureFileName, UnityEngine.Material material, System.Boolean isFinalLOD, System.Boolean isImpostor) [0x00194] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Editor\ExportTerrain.cs:544
  at Gaia.ExportTerrainUtility.ExportSingleTerrain (UnityEngine.Terrain terrain, UnityEngine.SceneManagement.Scene originalScene, System.Collections.Generic.List`1[T] LODSettingsList, System.Int32 index, System.Int32 maxTerrainCount, System.Boolean isFinalLOD, System.Boolean isImpostorScenes) [0x0029c] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Editor\ExportTerrain.cs:1812
  at Gaia.ExportTerrainUtility+<>c__DisplayClass23_0.<Export>b__0 (UnityEngine.Terrain t) [0x00000] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Editor\ExportTerrain.cs:383
  at Gaia.GaiaUtils.CallFunctionOnDynamicLoadedTerrains (System.Action`1[T] terrainAction, System.Boolean dirtyScenes, System.Collections.Generic.List`1[T] terrainNames, System.String progressBarText) [0x000f9] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Utils\GaiaUtils.cs:207
UnityEngine.Debug:LogError (object)
Gaia.GaiaUtils:CallFunctionOnDynamicLoadedTerrains (System.Action`1<UnityEngine.Terrain>,bool,System.Collections.Generic.List`1<string>,string) (at Assets/Procedural Worlds/Gaia/Scripts/Utils/GaiaUtils.cs:234)
Gaia.ExportTerrainUtility:Export (System.Collections.Generic.List`1<Gaia.ExportTerrainLODSettings>,int,UnityEngine.SceneManagement.Scene,bool,bool) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:384)
Gaia.ExportTerrainUtility:ExportWithLODSettings (System.Collections.Generic.List`1<Gaia.ExportTerrainLODSettings>,bool) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:453)
Gaia.ExportTerrainUtility:ExportTerrain (Gaia.ExportTerrainSettings,string) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:2114)
Gaia.ExportTerrain:ExportButton () (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:3182)
Gaia.ExportTerrain:ExportTerrainPanel (bool) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:3073)
PWCommon5.EditorUtils:Panel (UnityEngine.GUIContent,string,System.Action`1<bool>,UnityEngine.GUIStyle,bool,bool,bool,UnityEngine.GUILayoutOption[])
PWCommon5.EditorUtils:Panel (UnityEngine.GUIContent,string,System.Action`1<bool>,bool,bool,bool,UnityEngine.GUILayoutOption[])
PWCommon5.EditorUtils:Panel (string,System.Action`1<bool>,bool,UnityEngine.GUILayoutOption[])
Gaia.ExportTerrain:OnGUI () (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:2338)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Link to comment
Share on other sites

Just now, Mattis89 said:

At 100 terrains / 512 , I get this errors message after creating mesh AND impostor.. NO crash though

 

 

Error while processing multiple dynamic loaded Terrains, Exception: Out of memory  Stack Trace:   at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_array_new_specific(intptr,int)
  at UnityMeshSimplifierGaia.ResizableArray`1[T].IncreaseCapacity (System.Int32 capacity) [0x00000] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Mesh Simplifier\Runtime\Utility\ResizableArray.cs:135
  at UnityMeshSimplifierGaia.ResizableArray`1[T].Resize (System.Int32 length, System.Boolean trimExess, System.Boolean clearMemory) [0x0001a] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Mesh Simplifier\Runtime\Utility\ResizableArray.cs:164
  at UnityMeshSimplifierGaia.MeshSimplifier.set_Vertices (UnityEngine.Vector3[] value) [0x00015] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Mesh Simplifier\Runtime\MeshSimplifier.cs:240
  at UnityMeshSimplifierGaia.MeshSimplifier.Initialize (UnityEngine.Mesh mesh) [0x00040] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Mesh Simplifier\Runtime\MeshSimplifier.cs:2010
  at Gaia.ExportTerrainUtility.SetupGameObject (System.Collections.Generic.List`1[T] LODSettingsList, System.Int32 index, UnityEngine.Terrain terrain, System.String objFileName, System.String textureFileName, UnityEngine.Material material, System.Boolean isFinalLOD, System.Boolean isImpostor) [0x00194] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Editor\ExportTerrain.cs:544
  at Gaia.ExportTerrainUtility.ExportSingleTerrain (UnityEngine.Terrain terrain, UnityEngine.SceneManagement.Scene originalScene, System.Collections.Generic.List`1[T] LODSettingsList, System.Int32 index, System.Int32 maxTerrainCount, System.Boolean isFinalLOD, System.Boolean isImpostorScenes) [0x0029c] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Editor\ExportTerrain.cs:1812
  at Gaia.ExportTerrainUtility+<>c__DisplayClass23_0.<Export>b__0 (UnityEngine.Terrain t) [0x00000] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Editor\ExportTerrain.cs:383
  at Gaia.GaiaUtils.CallFunctionOnDynamicLoadedTerrains (System.Action`1[T] terrainAction, System.Boolean dirtyScenes, System.Collections.Generic.List`1[T] terrainNames, System.String progressBarText) [0x000f9] in Q:\Unity Projects\Gaia_Gena_Streaming_Test\Assets\Procedural Worlds\Gaia\Scripts\Utils\GaiaUtils.cs:207
UnityEngine.Debug:LogError (object)
Gaia.GaiaUtils:CallFunctionOnDynamicLoadedTerrains (System.Action`1<UnityEngine.Terrain>,bool,System.Collections.Generic.List`1<string>,string) (at Assets/Procedural Worlds/Gaia/Scripts/Utils/GaiaUtils.cs:234)
Gaia.ExportTerrainUtility:Export (System.Collections.Generic.List`1<Gaia.ExportTerrainLODSettings>,int,UnityEngine.SceneManagement.Scene,bool,bool) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:384)
Gaia.ExportTerrainUtility:ExportWithLODSettings (System.Collections.Generic.List`1<Gaia.ExportTerrainLODSettings>,bool) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:453)
Gaia.ExportTerrainUtility:ExportTerrain (Gaia.ExportTerrainSettings,string) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:2114)
Gaia.ExportTerrain:ExportButton () (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:3182)
Gaia.ExportTerrain:ExportTerrainPanel (bool) (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:3073)
PWCommon5.EditorUtils:Panel (UnityEngine.GUIContent,string,System.Action`1<bool>,UnityEngine.GUIStyle,bool,bool,bool,UnityEngine.GUILayoutOption[])
PWCommon5.EditorUtils:Panel (UnityEngine.GUIContent,string,System.Action`1<bool>,bool,bool,bool,UnityEngine.GUILayoutOption[])
PWCommon5.EditorUtils:Panel (string,System.Action`1<bool>,bool,UnityEngine.GUILayoutOption[])
Gaia.ExportTerrain:OnGUI () (at Assets/Procedural Worlds/Gaia/Scripts/Editor/ExportTerrain.cs:2338)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

all terrains was unloaded when the opreation started.

Link to comment
Share on other sites

A few got good.,.. Rest is blash.. I cant post screenshot... but half of them is sqaure and streched and hollow

Link to comment
Share on other sites

I tried 5 " x 5 / 512 terrains. Worked. I see them as they should.. but unity crash then after creating runtime and blames weather VFX 

Link to comment
Share on other sites

Got 5 x 5 / 512 (total 25 , 512 terrains) to work with impostor, and they look great. But at start both terrain and impostor of that terrain is loaded near player.. also 2 errors about moonlight bool? 

Link to comment
Share on other sites

On 1/11/2022 at 1:39 PM, Mattis89 said:

Got 5 x 5 / 512 (total 25 , 512 terrains) to work with impostor, and they look great. But at start both terrain and impostor of that terrain is loaded near player.. also 2 errors about moonlight bool? 

For the Moonlight issues. Drag the moonlight GO into your Gaia Lighting GO and/or child it to your Directional Light GO under Gaia Lighting.  Will resolve that issue. It did for me at least

For the terrain and impostor loading, check your loading ranges on any/all terrain loaders you have (camera, character, etc..) make sure they are matching if that the effect you are going for.  Additionally, check the camera vs world origin loading setting.  Try setting it to Camera View and it should prevent the impostors from loading within that view, if your impostor range is high enough. 

Link to comment
Share on other sites

Thank you very much ☺️ you don't happen to know where I can find Aura 2 intergration?

Edited by Mattis89
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
 Share

  • Tell a friend

    Love Unity 3D World & Game Creation Tools - Canopy - Procedural Worlds? Tell a friend!
  • Interesting Articles

    1. 8

      Errors from Gaia 2021 after updating to Unity 2021.3.2 LTS

    2. 7

      Problems with latest Gaia Update

    3. 7

      Problems with latest Gaia Update

    4. 0

      Ambient sounds issues

    5. 7

      Scene Optimizer

×
×
  • Create New...