Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

► Terrain to Mesh ◄

Discussion in 'Assets and Asset Store' started by Arkhivrag, Oct 1, 2015.

  1. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    788
    Understood, but seems crazy given the nature of the asset and how simple would be to implement since you can generate different res so easily and lod is just a component of unity already in place. But whatever.
     
    jaydnwlsn likes this.
  2. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    650
    It would be a nice feature to have for sure but I also it like when assets are simple and do one thing and one thing only. I always try NOT to use assets in a project when I can because they also bring in plenty of headaches with them. What I love about this asset is its simplicity, that it is very predictable and works perfectly every time.

    In any case, what you describe can be done very easily by yourself too with a script. Here's a general idea. Generate the first set of tiles and make sure to use set postfix as LOD0. Then you set the postfix as LOD1 and you generate the next low-quality set of tiles. Your script will find all the tiles (either using the names or type) in the scene. Then it will create a game object and add a LOD group per set and include corresponding LOD0 and LOD1 (or more).

    I should point out, at least in my case, I haven't had the need for LODs yet as these are already far more performant than Unity terrains. I May however need them if I decide to go for higher detail though.
     
  3. RealitySims

    RealitySims

    Joined:
    Mar 4, 2014
    Posts:
    28
    Actually I've been playing with a LOD workflow and Terrain to Mesh convertor. I plan to convert the following workflow into a script, but for now this is what I'm doing manually:

    1) Break the terrain into reasonable number of chunks so you can switch around the LOD's as you're traversing the grid relatively accurately.

    2) Create LOD per chunk. I'm using Unity's AutoLOD which is simple to get & setup. You select all the cunks, right click, AutoLod->Generate LODs. Don't forget to tick "Preserve edges" in the AutoLOD settings, so that each chunk preserves its borders correctly, instead you'd get triangular holes at the chunk seams.

    upload_2021-9-15_17-59-17.png

    3) You'll get something like this, which already looks promising:

    upload_2021-9-15_17-59-46.png

    4) The slight issue is that all of the chunks have their pivot at 0,0,0. I don't understand why the tool doesn't offer to set the pivot wherever we want. Like: center of chunk, world origin, custom. That's why you need to fix the pivots.

    5) Again, I'm not using scripts, just ProBuilder to fix the pivots. Select all chunks, Probuilerize (say Yes to include children). Then, select all chunks *including* the LODs (ctrl and right arrow to expand all chunks once you select them). Once everything is selected, click on Probuilder's "Center Pivot" to center pivot in the middle of each chunk.

    You might want to fine tune this so the pivot is closer to the actual surface (again, something the tool should do...).

    upload_2021-9-15_18-4-19.png

    6) Almost there. Now, each chunk has a pivot in the center, like this upload_2021-9-15_18-5-6.png

    7) But it still doesn't work, because...we forgot to recalculate the bounds of each LOD Group. This is currently the biggest pain and will benefit mostly from script automation. You literally need to click on each chunk, scroll to the "LOD GRoup" component and click "Recalculate Bounds" button.

    8) Finally, it works!
    lod_animation.gif
     
  4. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    788
    certainly looking good.

    I've purchased the asset, can´t wait to mess around. In my case I don´t plan to chunk any further my tiles are 2kmx2km already and I've about 2k tiles, for this specific dataset.

    I was notn aware of unity's auto LOD, looks really interesting.
     
  5. RealitySims

    RealitySims

    Joined:
    Mar 4, 2014
    Posts:
    28
    @TokyoWarfareProject Whoa yeah thats quite massive! I didn't test this workflow in live build yet, hopefully it works for you :) When I tried Unity terrain with similar effect (playing with pixel error etc) I achieved "LOD-like" behavior but the performance wasn't great on mobile. This works at 60fps and also the vertex counts are lower of course. Finally, I used occlusion culling. I think that helps with the vertex count and mainly overdraw(probably should hide chunks behind a hill etc.). But I'm quite new to Unity myself so don't take my word for it.
     
  6. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    788
    I will likely not use AutoLod but add it a postfix LOD0 LOD1 and have the lod more manually setup. Later to recalculate lod distances and unity theese it can be done with this script:
    Batch set lod distances script. - Unity Forum
     
    RealitySims likes this.
  7. RealitySims

    RealitySims

    Joined:
    Mar 4, 2014
    Posts:
    28
    Attached is the automation script, use at your own risk. It requires AutoLOD & Probuilder imported.

    • Move it into "Editor" folder somewhere in the project. Then, it should make itself comfortable inside VacuumShader's folder :)

    upload_2021-9-20_13-48-29.png

    • Here's how the terrain looks just after exporting. I selected one chunk on purpose to show the pivot is nowhere to be seen.

    upload_2021-9-20_13-48-58.png

    • Just drag the terrain parent object into the tool's single input field and click "Create LODs". After some processing, this should be the result:

    upload_2021-9-20_13-50-37.png

    It goes through each chunk, probuilderizes, centers pivot(as seen on screenshot), hijacks AutoLOD to generate LODs (I needed to use reflection). You might need to play with AutoLOD settings to prevent holes around chunks - it works great then, the LOD's are less optimized however.
     

    Attached Files:

  8. rob11

    rob11

    Joined:
    Mar 7, 2017
    Posts:
    42
    Hello ! I have been trying to use your asset, but I can't get it to work with a splatmap, it seems like there is some shaders issue. I did do the reimport step from the manual. It was pink and now it is all black. I also tried your Export Mesh and Splatmap scene and the terrain is also all black.

    upload_2021-9-22_21-59-50.png

    I am using Unity 2021.2.0b11 and URP 12.0

    Thank you ! :)
     
  9. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Unity alpha and beta versions can not be supported. Waiting for official release.



    Amazing Assets - YouTube Facebook Twitter
     
  10. Zimnel

    Zimnel

    Joined:
    Apr 23, 2015
    Posts:
    83
    Does Terrain to Mesh 2020.5 work with Unity 2020 LTS?
     
    Last edited: Sep 27, 2021
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    v2020.5 - old deprecated version? Not sure, have not tested.



    Amazing Assets - YouTube Facebook Twitter
     
  12. greenlightstudios

    greenlightstudios

    Joined:
    Mar 30, 2021
    Posts:
    1
    I just purchased it and got to know it only supports 16 layers maximum so any way around it? and also the png texture it's creating cant be open in any other Applications(it becomes blank in others?
     
  13. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Splatmap shader imitating Unity's built-in terrain shader supports maximum 16 layers. Increasing this limit currently is not planed.

    PNG textures use default encoding method and cannot know why you have problems with it. Try TGA format instead.

    [Edit]
    PNG format may be blank in some photo editors, as by default RGB channel in PNG is alpha premultiplied and if image has zero in alpha, photo editors just do not see RGB channels.



    Amazing Assets - YouTube Facebook Twitter
     
  14. manfromspace

    manfromspace

    Joined:
    Jul 21, 2020
    Posts:
    3
    Ok yes TGA and JPEG works..but even exporting in 8k resolution the textures become little blurry and that make a top view game looks blurry, So any thoughts on that?
    PS- This is my other account
     
    Last edited: Oct 1, 2021
  15. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    1) Use splatmap shader imitating Unity's builtin terrain shader. Textures here are rendered in original resolution.
    2) Bake all textures into one Basemap texture. Texture has default limitation of 8K.
    3) Split generated terrain mesh into chunks and for each one generate Basemap texture.



    Amazing Assets - YouTube Facebook Twitter
     
  16. Fancisco_Greco

    Fancisco_Greco

    Joined:
    Jan 26, 2021
    Posts:
    16
    Does this correctly convert the color tint (TerrainLayer.diffuseRemapMax) on each terrain layer?
     
  17. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Yes.
    And if for some reason it doesn't, report it and it will be fixed.



    Amazing Assets - YouTube Facebook Twitter
     
  18. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    690
    Hi @Arkhivrag !!!
    I have a little question.

    Is the "All Terrain Textures" tool included in Terrain to Mesh 2021?

    If not, what features / enhancements does "All Terrain Textures" add over the features of "Terrain to Mesh 2021"?

    I'm a little confused

    Greetings
     
  19. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    All Terrain Textures is not included into Terrain To Mesh.

    All Terrain Textures exports all kind and type maps and textures from Unity terrain asset that is possible.
    Terrain To Mesh exports only those maps and textures that are used by included shader used for rendering converted meshes.


    upload_2021-10-18_12-55-14.png



    Amazing Assets - YouTube Facebook Twitter
     
    ftejada likes this.
  20. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    690
    I do not know if I have understood it well...

    Would All Terrain Textures create the textures (normal, etc) on export if the terrain didn't have them?

    On the other hand in the description of Terrain to Mesh 2021 it comes that "Tree, grass and detail mesh exporter". I don't know what exactly you mean by "Object Placement maps" in the feature table you have shown me. Can you clarify it for me?

    Greetings
     
  21. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    All Terrain Textures exports all maps and textures used by Unity terrain asset. If normal maps are not used, they are not exported.

    Terrain To Mesh exports trees, grass and detail mesh objects used by Unity terrain assets and makes them part of the exported mesh.

    All Terrain Textures exports trees, grass and detail mesh placement maps (not objects).
    Here is example of the trees placement map:
    upload_2021-10-18_14-25-31.png



    Amazing Assets - YouTube Facebook Twitter
     
    ftejada likes this.
  22. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,602
    Does this asset create holes in the mesh from the terrain holes? It would be awesome, because creating them manually is a pain.
     
  23. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Generated mesh has no holes.



    Amazing Assets - YouTube Facebook Twitter
     
  24. biggoron88

    biggoron88

    Joined:
    Nov 7, 2017
    Posts:
    8
    Hi! Is it this asset (package) compatible with URP 2021.2? I am working with 2021.2 and I would like to know this
     
  25. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Unity 2021.2 was released just a few days ago and I have not tested it enough yet. So at this moment I can not guarantee that asset is fully compatible with 2021.2



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Nov 1, 2021
  26. gustjr6735

    gustjr6735

    Joined:
    Jun 17, 2021
    Posts:
    1
    Hi I have purchased Terrain to Mesh and Terrain to Texture, but low resolution image maps are extracted. I want to extract a terrain image with a terrain material applied. Increasing the base map dist value or reducing the map size does not solve the problem. Is there any other way to extract the desired high-quality resolution image?
     
  27. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    When converting terrain into a mesh, inside exported material choose Splatmap. This will create material imitating Unity's built-in terrain shader where painted textures are used in their original resolution.
    If you are baking painted textures (exporting Basemap), then you have to choose file resolution.



    Amazing Assets - YouTube Facebook Twitter
     
  28. Kolja_Lubitz

    Kolja_Lubitz

    Joined:
    Aug 2, 2021
    Posts:
    4
  29. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,602
  30. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    275
    Hi. I'm wondering about the Object export for trees. What does it actually do? You'll get all the prefabs of the trees that were in the original terrain? And what does the rotation setting do? Wouldn't the trees already be rotated on the terrain?

    Also All Terrain Textures exports the paint data, I'm assuming this is the location of threes (for example). How is that later used to place the trees at those locations?
     
    Last edited: Nov 16, 2021
  31. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Exported trees are original tree prefabs used by source terrain and have same position/rotation/scale as they had in terrain system. But without terrain LOD and billboard systems.

    As for All Terrain Textures, here is example of trees placement on terrain:


    Each pixel here represents tree location. How you use this map, is up to you. TTM does not use it.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Nov 16, 2021
  32. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    275
    Just so I'm clear. If you have say a 100 trees then 100 prefabs will be exported each with the unique position/rotation?
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    yes



    Amazing Assets - YouTube Facebook Twitter
     
  34. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    275
    I've read the documentation for Terrain To Mesh, and from my understanding after the conversion the intended shader to use is the splat shader that will accept the up to 16 generated textures. Another option is to use the Basemap which can take other shaders (not sure if unlit with light maps would work). So is the idea of using a mesh instead of terrain mainly performance? If so would then Basemap be more performant, why would one want to use splat shader at all? I appreciate any opinion you might have in this area.
     
  35. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Compared to the Splatmap material, Basemap can be used on any device with any shader. But baked textures are limited to 8K resolution per-chunk.
    Splatmap material does not bake anything and uses terrain paint textures in original resolution, but layers count is limited to 16 and used textures count depends on a target device GPU (Manual file, page 9).



    Amazing Assets - YouTube Facebook Twitter
     
  36. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    275
    I see. Thank You.
     
  37. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    275
    I used to own Mesh Materializer, do you know why that was deprecated?
     
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Mesh Materializer was developed six years ago for Unity 4 and it is not possible to update and support it any more.
    You can use 50$ price off to update it to the Amazing Tools Bundle.



    Amazing Assets - YouTube Facebook Twitter
     
  39. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    275
  40. xsasoftware

    xsasoftware

    Joined:
    Sep 6, 2017
    Posts:
    24
    Hello. I have a problem. I can't convert any terrain. I also tried the one in the demo and I'm getting this error:

    upload_2021-11-29_14-38-31.png
     
  41. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    You are using very old version, that was designed for Unity 5.6 - 2017 - 2018 - 2019.2. It is deprecated now and is not supported any more. Update to the new one.



    Amazing Assets - YouTube Facebook Twitter
     
  42. xsasoftware

    xsasoftware

    Joined:
    Sep 6, 2017
    Posts:
    24
    What should I update? I just recently downloaded the plugin.
     
  43. xsasoftware

    xsasoftware

    Joined:
    Sep 6, 2017
    Posts:
    24
    I checked again and it looks like this.

    upload_2021-11-29_18-52-55.png
     
  44. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
  45. xsasoftware

    xsasoftware

    Joined:
    Sep 6, 2017
    Posts:
    24
    I will try, but is on a new laptop. So no history about downloads.
     
  46. xsasoftware

    xsasoftware

    Joined:
    Sep 6, 2017
    Posts:
    24
    Maybe the upload version is the same with the old one? I had the old one purchased ~ 1 year ago and never used on this new laptop. Today, I wanted to download the new plugin, and I saw an updated version, and i had to pay for it. I paid, and downloaded the plugin. But it seems to install the old version.Maybe you made a mistake when you uploaded the upload version and uploaded an old version?
     
    Last edited: Nov 29, 2021
  47. lethbridgestart

    lethbridgestart

    Joined:
    Apr 1, 2020
    Posts:
    3
    When trying to use splatmat shader in URP, we get pink shaders and a

    Shader error in 'Hidden/Splatmap': unrecognized identifier 'UNITY_DECLARE_TEX2D' at Mesh/Shaders/cginc/Variables.cginc(229) (on d3d11)

    error on the shader. When we remove URP, it looks fine. How can this be fixed? upload_2021-12-15_12-30-4.png
    upload_2021-12-15_12-30-4.png
     
  48. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    And what is Unity version?
    2021.2 is not supported yet. If using previous versions, recompile shaders as explained in Manual file, page 13.



    Amazing Assets - YouTube Facebook Twitter
     
    Last edited: Dec 15, 2021
  49. lethbridgestart

    lethbridgestart

    Joined:
    Apr 1, 2020
    Posts:
    3
    Unity 2020.3.12. I tried the recompile process and the error didn't remove and the shaders remained pink.
     
  50. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    If you have switched project from Built-in to Universal RP, then you have to completely remove TTM from project and import appropriate Universal RP package from the TTM installer folder. It contains 3 packaged designed for each render pipeline.



    Amazing Assets - YouTube Facebook Twitter