Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

► Terrain to Mesh ◄

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

  1. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Texture tiling is read directly from Terrain asset. Those parameters are used by terrain material itself and are copied to generated T2M material. But you can control tiling scale for each texture inside T2M material editor.



    VacuumShaders - Facebook Twitter YouTube
     
  2. gamesjust007

    gamesjust007

    Joined:
    Jan 3, 2017
    Posts:
    9
    Hi the documentation and API doc isn't there. Can you please submit it again? Need to go through the documentation.

    Thanks.
     
  3. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Updated
    ReadMe and API.



    VacuumShaders - Facebook Twitter YouTube
     
  4. gamesjust007

    gamesjust007

    Joined:
    Jan 3, 2017
    Posts:
    9
    Thanks a lot Arkhivrag :)
     
  5. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    Hello, does anyone have general advices to get better performances on mobile devices using this asset? My fps are lower when using the terrain mesh instead of the standard unity terrain ...what could I do to improve it? Maybe LOD?
     
  6. xsasoftware

    xsasoftware

    Joined:
    Sep 6, 2017
    Posts:
    18
    Hello.
    I can't get the legacy shader to work on my galaxy s7 edge. I receive only a white terrain ( no textured ) ( legacy 7 textures)

    Thank you!
     
  7. zombieguy

    zombieguy

    Joined:
    Mar 4, 2015
    Posts:
    10
    @Arkhivrag Just to double check does this asset work with the new 2018.3 terrain system and in HDRP? Also can it export normal maps and mask maps for HDRP?
     
  8. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Contact me using vacuumshaders@gmail.com with more detail info.


    Compatible with LWRP, but not with HDRP.



    VacuumShaders - Facebook Twitter YouTube
     
  9. zombieguy

    zombieguy

    Joined:
    Mar 4, 2015
    Posts:
    10
    Damn, I will find a way to get some tesselation for my terrain if it kills me lol. Thanks for your help anyway.
     
  10. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    631
    @Arkhivrag

    I've gotten this to work successfully before, with the same version of this asset on 2017.2, but now nothing I do will avoid this error when pressing Generate:

    NullReferenceException: Object reference not set to an instance of an object
    VacuumShaders.TerrainToMesh.TerrainToMesh_EditorWindow.ClearConsole ()
    VacuumShaders.TerrainToMesh.TerrainToMesh_EditorWindow.Draw_GenerateButton (Boolean _isReadyToGenerate)
    VacuumShaders.TerrainToMesh.TerrainToMesh_EditorWindow.OnGUI ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:285)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:278)
    UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:245)
     
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Package has been submitted using Unity 5.6.4, 2017.4.10, 2018.2.5, 2018.3.0, and 2019.1.0

    If you use 2017.2 editor to download package from the store, you automatically get asset for Unity 5.6
    You need exactly same Unity version package is submitted to the store or earlier.

    If you can not upgrade project to Unity 2017.4.10. Try still download asset using that Unity version and import it in your project.



    VacuumShaders - Facebook Twitter YouTube
     
  12. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    631
    Ah, wasn't aware this asset only worked on specific versions. I must have done my previous testing in a different version of Unity then.

    I'll just copy my terrain assets over to a new 2018 project to generate the terrain meshes and then bring those back over to my actual project. Unless the Terrain to Mesh folder is needed in the final build?
     
  13. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Terrain To Mesh asset contains several folders and only files in Script folder are required in run-time and only if performing run-time terrain conversions.



    VacuumShaders - Facebook Twitter YouTube
     
  14. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    631
    Nice. Don't need run-time so should be straightforward.
     
  15. MadAboutPandas3

    MadAboutPandas3

    Joined:
    Jul 3, 2017
    Posts:
    28
    Hello Arkhivrag,

    Your asset works well. We too need grass conversion, this stops us from using it. Sure there will be many thousands of objects created. Sure one can also repaint prefabs manually with tools like PolyBrush. But this is not the same.
    After these grass objects are created one can bake the meshes in chunks or enable instancing or continue working on getting these grass rendered fast. I made a very good experience with assets like GPU Instancer, but this is unfortunately not working on Nintendo Switch right now.
    So I appreciate it very much if you add a conversion for detail grass! I found a couple of requests in this thread for the feature.

    Kind Regards,
    Chris
     
  16. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Added to a wish-list.



    VacuumShaders - Facebook Twitter YouTube
     
  17. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    Code (CSharp):
    1. [Error] 'Assets/(Temporary)/test/Terrain 14 (1) (ID_162976)/.asset' is not a valid asset file name.
    2. UnityEditor.AssetDatabase:CreateAsset(Object, String)
    3. TerrainToMesh_EditorWindow.SaveMeshAsset()
    4.  
    5. TerrainToMesh_EditorWindow.ExportUnityMesh()
    6.  
    7. TerrainToMesh_EditorWindow.Generate()
    8.  
    9. TerrainToMesh_EditorWindow.Draw_GenerateButton()
    10.  
    11. TerrainToMesh_EditorWindow.OnGUI()
    12.  
    13. GUIUtility.ProcessEvent()
    14.  
    Using unity 2019.1.0f2

    This happens whenever I try to "Generate". I don't even muck with the settings, was just wanting to see a test result and nothing happens.

    Note that it also hangs a "Saving Assets" load window that you can't close and no progress
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Seems asset file is created without name.
    Check terrain gameobject name and terrain data asset name used by terrain.



    VacuumShaders - Facebook Twitter YouTube
     
  19. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    Game object was named "Terrain 1,4 (1)"
    Where do I find "Terrain data asset name used by terrain"? I looked around on the terrain options all over and can't find something like that
     
  20. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    By the way, it's not a problem with my version as I can make a blank terrain and it converts.

    What should I look for in my terrain that's causing it to error out and try to give it no name?

    It successfully makes the splatmap etc, just hangs when doing the mesh part.
     
  21. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Here is TerrainData asset. Does it have name?
    upload_2019-5-10_12-48-29.png



    VacuumShaders - Facebook Twitter YouTube
     
  22. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    Thanks for the screenshot! No it doesn't have a name...and if i click the little circle it returns no results

    upload_2019-5-10_9-23-35.png

    How do I actually enter a name there? Sorry if that's a really newbie question :(
     
  23. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Click on the asset itself, not circle. And it will automatically select object in Project window. Now you can rename it.



    VacuumShaders - Facebook Twitter YouTube
     
  24. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    So I used the following code to fix my terrainData issue, if I put this script on my terrain, then press the button, it'll extract the TerrainData as an asset, then reapply it to the collider.

    That works. And then T2M works.

    Except, my mesh is black.
    upload_2019-5-10_16-49-37.png

    I suspect maybe just extracting the TerrainData is not enough? Or maybe it's not saving the terraindata to the terrain too (ie. I shouldn't JUST reapply it to the collider?)

    What do you think? Sorry for the very rusty code. My final version would save the asset in a better spot, probably name the data with a combination of the Scene Name + Game Object name so that it'll be unique (my terrains always have unique names), as I think I need to preserve this asset after I'm done (ie. can't just delete it once it's applied)

    I honestly can't figure out how these terrains got made without this seemingly important data... the terrains were originally generated from Map Magic if that has anything to do with it I wonder...

    Anyway, can you peak at the code below and see if that is somehow not providing enough detail for T2M to work with?

    I THINK I'M ALMOST THERE!!!!!

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEditor;
    5. using UnityEngine;
    6.  
    7. [ExecuteInEditMode]
    8. public class TerrainFixData : MonoBehaviour
    9. {
    10.     [InspectorButton("OnFixData")]
    11.     public bool doFixData;
    12.  
    13.     Terrain terrain;
    14.     TerrainCollider terrainCollider;
    15.  
    16.     void OnFixData()
    17.     {
    18.         terrain = GetComponent<Terrain>();
    19.         AssetDatabase.CreateAsset(GetComponent<Terrain>().terrainData, "Assets/(Temporary)/terrain test.asset");
    20.         AssetDatabase.SaveAssets();
    21.         //Debug.Log(terrain.terrainData.name);
    22.  
    23.         terrainCollider.terrainData = Resources.Load("Assets/(Temporary)/terrain test.asset", typeof(TerrainData)) as TerrainData;
    24.     }
    25. }
    26. #endif
     
  25. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    By now two problems detected with your terrain.
    1) TerrainData asset has no name (have never met such case).
    2) Terrain Splat texture starts with index '2'. Where are are other two splat maps? (have never met such case too o_O).
    upload_2019-5-11_16-44-55.png

    I think T2M material still can be generated but you have to set extracted Splatmaps manually inside material editor later for ControlMap parameter.
    upload_2019-5-11_16-48-38.png

    Note: To bake Basemaps or use T2M material, terrain must be using Unity's built-in terrain shader, not custom.




    VacuumShaders - Facebook Twitter YouTube
     
  26. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    Thank you I will give this a try in a few days
     
  27. HelixNGC7293

    HelixNGC7293

    Joined:
    Oct 26, 2016
    Posts:
    11
    Hello Davit!

    I just got a issue when converting Terrain textures for mobile. The SplatApha map is keep having some noisy boundary at the blending areas (default 4 textures bump shader)... Is there a way to fix this?

    Thx!!

     
  28. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    If using Splatmap in Linear color space, make sure sRGB options is disabled for texture file in TextureImporter.
    Note, T2M can bake only Unity's built-in terrain shaders. Custom shaders can not be baked.



    VacuumShaders - Facebook Twitter YouTube
     
  29. HelixNGC7293

    HelixNGC7293

    Joined:
    Oct 26, 2016
    Posts:
    11
    Thanks for replying!! That's so quick.

    Double checked. sRGB is disabled for the SplatAlpha texture & I'm using "Build In Standard" material as the original Terrain. Is there anything I'm doing wrong?

     
  30. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    It may be texture compression issue, turn off compression inside texture import settings for Splatmap.




    VacuumShaders - Facebook Twitter YouTube
     
  31. HelixNGC7293

    HelixNGC7293

    Joined:
    Oct 26, 2016
    Posts:
    11
    It worked!! Thank you so much!
     
  32. levelappstudios

    levelappstudios

    Joined:
    Nov 7, 2017
    Posts:
    36
    Hello @Arkhivrag , we are using TerrainToMesh for our game since yesterday and it's awesome! Now we can achieve high fps on terrain meshes :)

    We have a request for the TerrainToMesh API if possible. It would be great to have the possibility of selecting which of the chunk meshes are generated using their indices in the "Convert" method. This method by its own is really fast but we are optimizing our game as much as possible and we discard more than 50% of mesh chunks generated by this method because of the game is not using them. I explain it a bit more:

    It's a racing game, the tracks are not looped, they have a start and a finish. We are generating terrain around the track and due to the terrain component restriction of being squared there is a lot of terrain space wasted. This terrain is converted to mesh with TerrainToMesh in runtime, and the unused meshes are discarded because they are never going to be rendered. If these meshes were not built we could save a lot of CPU time in the conversion.

    Here is what I mean:



    Black line is the road track, green rectangles are rendered mesh chunks and red rectangles are discarded mesh chunks.

    It would be awesome if TerrainConvertInfo class has an extra attribute with desired mesh indices.

    Thanks in advance.
     
  33. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Added to wish-list.



    VacuumShaders - Facebook Twitter YouTube
     
  34. levelappstudios

    levelappstudios

    Joined:
    Nov 7, 2017
    Posts:
    36
  35. AtomsInTheVoid

    AtomsInTheVoid

    Joined:
    Jul 27, 2015
    Posts:
    170
    upload_2019-6-6_10-19-21.png

    Ok so I'm figuring things out with this neat little tool, in one of my tests I actually managed to get the coveted 90fps with lush vegetation in VR! Amazing!

    Now I'm trying to do a bigger terrain test, but I have an interesting issue, I wonder if it's a bug?

    Basically, if i convert this terrain to mesh with 1x1 chunks (so, none), it seems to work fine... and chooses the Vaccuum shader for the terrain and thus transmits the splatmap decently. It's quite apparent that the resolution is drastically lower on the conversion, so I figured the solution would be to chunk it up. Also, this way I can increase the bumpiness of the terrain as each chunk can have it's own vert limits, instead of the entire huge terrain being limited to 64k, each chunk can be 64k with it's own independent splats...

    Except not..

    Seems that choosing standard, as I did previously (sorry, not on the screenshot), puts the literal Standard Shader on each chunk, whereas if it's no chunk it will apply the Vacuum standard shader.

    How do I get it so each chunk gets your shader with it's own higher resolution splats?
     
  36. kai_226

    kai_226

    Joined:
    Jul 6, 2017
    Posts:
    50
    Hey there,

    I am getting an error when trying to convert terrain:
    Convertion failed for Terrain (UnityEngine.GameObject)
    UnityEngine.Object UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(UnityEngine.Object)


    It used to work in previous Unity versions. Currently I am using 2019.1.1.f1

    I get this error no matter if I export to OBJ or Unity Asset. It's also independent of terrain size and vertex count. Any ideas?


    EDIT: Fixed by re-importing the asset!
     
    Last edited: Jun 7, 2019
  37. Mandelboxed

    Mandelboxed

    Joined:
    Apr 17, 2015
    Posts:
    47
    Hi. I've purchased Terrain to Mesh and am getting errors in the editor as soon as I open the window.


    GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced.
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)



    TypeLoadException: Could not resolve type with token 01000061 (from typeref, class/assembly UnityEngine.Experimental.Rendering.RenderPipelineAsset, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
    VacuumShaders.TerrainToMesh.TerrainToMesh_EditorWindow.OnGUI () (at <f565071f42314afcbf24821879ee9b13>:0)


    I am using Unity 2019.1.5f

    Based on the screenshots in the documentation it does not look like I have all of the options that I should have and there is no way to set the terrain to convert.

    This is what I am seeing in the Terrain to Mesh window:
    upload_2019-6-25_15-3-8.png

    Any guidance you can offer on getting this working would be much appreciated.
     
  38. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    You are using asset for Unity 2018 inside Unity 2019 - that's the problem.
    Solution: Remove asset from the project, clear Asset Store cache folder and re-download package from the store using Unity 2019.



    VacuumShaders - Facebook Twitter YouTube
     
  39. Mandelboxed

    Mandelboxed

    Joined:
    Apr 17, 2015
    Posts:
    47
    That was it! Thanks. Unity really should handle that better.
     
  40. Shinano

    Shinano

    Joined:
    Mar 11, 2015
    Posts:
    4
    As a result of generating Terrain, I can not find Splatmap.
    Do you know what this reason is? splatmap.jpg
     
  41. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Here are your splatmaps:
    upload_2019-7-3_11-19-58.png


    If they are not automatically assigned to a shader, problem may be in your terrain asset.
    SplatAlpha textures index must start with '0' (zero), in your case it may be '1' or '2'
    upload_2019-7-3_11-21-54.png
    There is only one solution in that case, manually assign Splatmaps textures to the Control Map property inside material editor.



    VacuumShaders - Facebook Twitter YouTube
     
  42. Shinano

    Shinano

    Joined:
    Mar 11, 2015
    Posts:
    4
    Thank you for your reply!
    I understood about SplatAlpha!

    Next, why is the Basemap that is supposed to be set to the material in screenshot not being exported?
     
  43. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Basemap will be exported only if source terrain uses Unity's built-in terrain shader.
    Custom terrain shaders do not generate Basemap.



    VacuumShaders - Facebook Twitter YouTube
     
  44. Shinano

    Shinano

    Joined:
    Mar 11, 2015
    Posts:
    4

    I set "built-in terrain shader" but the Base texture was not output.

    I am using Unity2018.3.8f1.
    Is this version bad?
     
  45. Shinano

    Shinano

    Joined:
    Mar 11, 2015
    Posts:
    4
  46. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Just from an image it is very difficult to understand what the problem may be.
    Send me more info on the support e-mail: vacuumshaders@gmail.com
    1) Terrain asset with all it paint textures (as package)
    2) Build target
    3) OS
    4) Working in Linear or Gamma color spaces?
    5) Is there any other VacuumShaders assets in the project?
    6) Was project updated from previous Unity version?
    7) Will need asset purchase invoice too

    Also, does included example terrain exports Basemap? Or problem is with it too.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Jul 12, 2019
  47. OkeanixTR

    OkeanixTR

    Joined:
    Jan 28, 2017
    Posts:
    41
    Is there Specific Reason for not having 8 Bumped Shader when there is 8 Diffuse Shader.
     
  48. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    Yes, not enough registers.
    Shaders have limit of 16 texture samplers.

    8 bump map shader would need:
    8 diffuse + 8 bump texture samples = 16 (already), additionally 2 control map samplers = 18 (shader compiler fails here), and some additional textures needed by Unity itself like Shadowmaps/Lightmaps/Reflection probes, etc.

    There is not enough texture registers for 8 Bumped Shader.

    Also asset is dedicated for max mobile optimization and does not use features that are not available on most mobile devices, for example TextureArrays.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Aug 20, 2019
  49. lostudo

    lostudo

    Joined:
    Jul 25, 2013
    Posts:
    14
    Hi there, i have a problem with textures. I am sending the screenshot and also the configuration i use. I have no idea about why is that happening. I have very limited time to read other posts so if it is already solved, i am so sorry.
    Left one is unity terrain, right one is terrain to mesh output. As you can see, there is a very big difference between ground texture.
     

    Attached Files:

  50. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,469
    If you are using T2M shader for multiple texture blend, make sure original terrain asset uses Unity built-in terrain shader and paint texture is less then 9.
    T2M shader can blend maximum 8 textures.
    Or you can just bake all paint textures (unlimited count) into one Basemap texture.



    VacuumShaders - Facebook Twitter YouTube
     
    Last edited: Aug 31, 2019
unityunity