Exporting Unity Terrain to PlayCanvas

Hello,

I was wondering if there is any way to export unity’s terrain with grass and trees already.

I tried to turning the terrain to obj but it only comes with the terrain itself and the grass and trees disappeared.

Thanks

Hi @chris_xigega and welcome,

There isn’t an automatic way of doing that, but if you are feeling comfortable in coding in Unity you can write a small exporter that:

  1. Exports the terrain as a mesh object that can be imported in Playcanvas, or export the heightmap and use the following example to import it in Playcanvas:

https://developer.playcanvas.com/en/tutorials/terrain-generation/

  1. Export a JSON structure that contains all translation info for detail objects, import it in Playcanvas and use it to position Playcanvas entities for each object in place.

Make sure to use batching if you spawn a lot of objects to avoid major performance drops.

2 Likes

I have a different question, how to put multiple materials in the generated terrain? because I can only put one material it’s just dirt or grass, do I have to use the procedural gradient tutorial?

Yes you need a custom shader that supports multiple diffuse maps on a single material. Two common ways for sorting those are either using a splatmap or based on height.

For the splatmap case, I’ve built a script that does that here:

And here is an example shader for height based terrain texturing, it’s for Three.js but you can adapt it for Playcanvas:

1 Like

Thank you very much