hi everyone,
i there any way to convert a terrain to entity using subscenes ?
if not, is it possible to convert a terrain to a simple GameObject then convert it using subscene ?
Terrains are not supported in subscenes yet.
Is there any workaround ?
Like converting the errain to a mesh and use it with the regular conversion workflow ?
Just put it in a regular scene and load it normally? (or just the parent scene)
Shouldn’t be that hard to write a simple system to load a terrain along with a subscene.
i know but i wanted something pure ^_^.
also for an unknown reason unity freezed like 10 times in 30mn while using the paint tool, do you guys faced this problem before ?
- it never got that much of freezes before using terrains.
What benefit would you gain for having terrain be “pure”? It isn’t like you are going to have a whole bunch of them that performance matters. If necessary, you can use what Unity does with Lights and write your own terrain converter that utilizes a terrain pool for rendering.
actually yes! in my case ill have arround 784 peace of terrain. each peace is 50x50m, and the whole map is 1400x1400m, so iterating over them in a linear + parallel way plus enabling/disabling their renderers will always be better than the normal GO workflow, that’s why ECS is awesome.
50x50m is really small for a terrain. I would expect that you could drop your terrain count by 2 orders of magnitude.
But if you still decide to stick with that many terrains, the challenge is you still need a terrain renderer to render each terrain. So either you need to pool terrains like Unity.Rendering.Hybrid does for lights, or you need to use hybrid.
I can’t think of a use case where this would be a good approach. Are you simply wanting to not render parts of the map? Like if it was a top down game for example?
yep! it’s a Top Down game
and im culling the whole map ( Trees, cars, gras, ground props… ) using a SCD int2 called region.
the map culling system always activates the 9 regions around the player, so when the player changes region the system enable/disable the right entities by querying them using the SCD and add the Disabled CD with a batch operation which is incredibly fast.
Frustum culling is incredibly fast also. So you have to consider your approach on a case by case basis, measured against the complexity involved. Your approach for terrains involved a lot more complexity. And your potential gain was always extremely small. And I’m being gracious there because with how terrains are actually rendered, and your map size, there is just no way your approach would win out.
I don’t understand how my approach can be slow, I juste query for all entities with a SCD (Which is fast) and Add/Remove the Disabled CD using a Batch operation with the EntityQuery it self(which is fast too). So the operation is done by chunk not by entity.
Also this operation is not executed every frame like the Frustum culling, but only when the player reaches the minimum and maximum bounds of his current region, so arround 1op / 15 ~50s (The fastest code is the code which does not run )
Culling System Logic:
yes for the Moment the 50x50 is just a tweakable parametre and will certainly be changed in the future, i try to renderer as less as possible cause it’s a Mobile Game and i try to consider the wide variety of low end devices.
but the player will always have 150x150 active space (9 regions).
the only real problem im facing now is i cant add/remove the Disabled CD to subscene entities when using the StaticEntityOptimization Component, cause all it’s chunks are locked and the renderer system without this component is having poor performance.
Measure the performance of just having a single 1400x1400 terrain vs 9 that are 50x50. The single terrain has a lower total rendering cost.
for Esthetic reasons it’s just impossible for us to use a single peace of terrain for the whole map. ( holes … )