[SOLVED] World Generation

Dear PC Developers,

I’ve been trying to have a Playable world generated. I have a Mesh with the topology of the level and want to spawn trees/forests aswell as grass on the level. Now the level is really big (5km x 5km) and fairly flat. I’ve been working with the templates feature (thanks for adding that!) and spawing random instances of templates in certain areas.

Now to fill just a simple view I generate thousands of elements with textures (Trees and grass .png) on the world layer and therefore my performance is affected. I’ve tried using Batch Groups where each template (so every different texture) has it’s own batch-group (tree1, tree2, tree3, tree4 and grass1, grass2, grass3). This improved performance perfectly but now I am facing graphical issues. Now the batch groups seem to always render infront of other objects of other batch groups. (all Tree 4s are infront of Tree 3, Tree3 is always infront of Tree2 etc.)

you can see an example here: https://playcanv.as/p/6ElSFD6U/

Has anyone got an idea on how I can fix this, so every object is rendered correctly depending distance from the camery on the world layer ? Or maybe have an alternative. I’ve tried it with texture atlas and sprites but that was even less perfmant than image-elements.

Thank you and kind regards,

Bruno

Hi @Bfischlin,

I think you’ve made most of the steps right, the issue you are facing most likely is due to the very large AABB you define for each batch group.

For big distances it will make it hard for the batched model to get it’s z-distance properly calculated. Try putting smaller values like 100, you will get slightly more draw calls but it will still be quite performant.

Let me know if that fixes your issue.

1 Like

@Leonidas much better! Like always thanks for the quick and accurate reply!

1 Like

also, to keep the code simpler … use single batching group for all these - internally the code separates them by material, so you don’t need to create a batch group for each material type.

2 Likes