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. crowmaster

    crowmaster

    Joined:
    Jul 6, 2012
    Posts:
    42
    This means physically there is no holes? Any plans on fixing this?
     
  2. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Yes, no physical holes.
     
  3. crowmaster

    crowmaster

    Joined:
    Jul 6, 2012
    Posts:
    42
    Why not add real holes support?
     
  4. tgaldi

    tgaldi

    Joined:
    Oct 28, 2015
    Posts:
    96
    Hey, I'm testing this on Unity's HDRP Terrain Demo (using 2021.3.8f1) but not having great results:

    upload_2022-10-20_15-42-28.png
     
  5. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Results depend on settings you use.

    Unity built-in Plane mesh has 121 vertices.
    Unity Terrain HDRP Demo scene consists of 16 high detailed terrains. You expect that entire terrain landscape converted into a mesh with just 625 vertices gives you the "great" results?

    Increase generated mesh vertex count.

    Advice, do not export original amount of detail meshes, scene consist of about 4 million detail meshes and each one has more than 1K vertices.
    Try export only mesh first, then add trees and after that grass and details (with 0.1 or even 0.01 for multiplier).
     
    Last edited: Oct 20, 2022
  6. tgaldi

    tgaldi

    Joined:
    Oct 28, 2015
    Posts:
    96
    The main problem I'm seeing is the material flickers (the blown out bits in the screenshot flicker when you move around in the scene).

    Is there another doc on how to tweak settings in more detail?
     
  7. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    At my side no problems found.

    Can you capture video of that material flickering, it is difficult to see on the screenshot.
    Send me it on the support e-mail (support@amazingassets.world) with asset purchase invoice. I will check it. May be it is not because of material at all, but some other settings for example shadow or post processing.
     
    tgaldi likes this.
  8. tgaldi

    tgaldi

    Joined:
    Oct 28, 2015
    Posts:
    96
    I just wanted to follow up that the developer quickly responded and we were able to fix the issue.
     
  9. Yunittie

    Yunittie

    Joined:
    Jun 27, 2022
    Posts:
    6
    Hello, the description of the asset Terrain to Mesh 2021 says "tool works only with Unity TerrainData object and exports mesh, textures and materials only from it." Does terrain to mesh work with MapMagic 2 terrain? Have someone tried it before? Thanks a lot
     
  10. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    543
    I just purchased Terrain To Mesh, but I'm having problems getting the shaders to compile and run. I'm using Unity 2021.3.11 with URP 12.1.7 and Hybrid Renderer 0.51.1.

    I followed the directions for "Update Splatmap Shader" in the documentation ( https://docs.google.com/document/d/1d-m1U0_ZnErRpfidkCw4bmhf0kdxvsnTvHQFkqjdP_c ). Copied Shader from ShaderGraph and then did right-click on shadergraph and Generate Shader for both Splatmap.shader and Splatmap (Holes).shader.

    At first I was having tons of problems and it crashed unity a couple of times. Now it seems to have calmed down, but I'm stuck in a catch-22.

    In the inspector, I saw the error:
    "SRP Batcher not compatible
    Material property is found in another cbuffer than "UnityPerMaterial" (_T2M_Layer_0_uvScaleOffset)"


    So in Variables.cginc, I put a CBUFFER_START(UnityPerMaterial) around float4 _T2M_Layer_0_uvScaleOffset; and float4 _T2M_Layer_0_ColorTint; That fixed the problem, but then it complained:
    "SRP Batcher not compatible
    Material property is found in another cbuffer than "UnityPerMaterial" (_T2M_Layer_1_uvScaleOffset)"


    So I added float4 _T2M_Layer_1_uvScaleOffset to the same CBUFFER in Variables.cginc as I did the others, but when I did that, I started getting the error:
    "redefinition of '_T2M_Layer_1_uvScaleOffset'".

    So it's a catch-22... If I define it in the cbuffer then it complains that it's being redefined (no idea where the old definition is), and if I don't define it, then it complains that the material property is found in another cbuffer.

    I can't disable SRP Batching because Hybrid Renderer V2 (HRV2) requires it.

    Any ideas?
     
  11. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Compatibility with SRP Batcher will be included in the next week update.
     
    Last edited: Nov 18, 2022
    lclemens likes this.
  12. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    543
    OMG that just made my day!!!
     
  13. Sciallalo

    Sciallalo

    Joined:
    Dec 5, 2021
    Posts:
    1
    I was trying to use your package but this error come up.
    Do you have any clues?

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. VacuumShaders.TerrainToMesh.TerrainToMesh_EditorWindow.ClearConsole () (at <618a058459b344658e15ea370d61bc08>:0)
    3. VacuumShaders.TerrainToMesh.TerrainToMesh_EditorWindow.Generate () (at <618a058459b344658e15ea370d61bc08>:0)
    4. VacuumShaders.TerrainToMesh.TerrainToMesh_EditorWindow.Draw_GenerateButton (System.Boolean _isReadyToGenerate) (at <618a058459b344658e15ea370d61bc08>:0)
    5. VacuumShaders.TerrainToMesh.TerrainToMesh_EditorWindow.OnGUI () (at <618a058459b344658e15ea370d61bc08>:0)
    6. UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <786b546700bc48b68852821de5e46ca9>:0)
    7. UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <786b546700bc48b68852821de5e46ca9>:0)
    8. UnityEditor.DockArea.OldOnGUI () (at <786b546700bc48b68852821de5e46ca9>:0)
    9. UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <c735460d95a241ccbea413909634f410>:0)
    10. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <c735460d95a241ccbea413909634f410>:0)
    11. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <c735460d95a241ccbea413909634f410>:0)
    12. UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <c735460d95a241ccbea413909634f410>:0)
    13. UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <c735460d95a241ccbea413909634f410>:0)
    14. UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <c735460d95a241ccbea413909634f410>:0)
    15. UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <c735460d95a241ccbea413909634f410>:0)
    16. UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <c735460d95a241ccbea413909634f410>:0)
    17. UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <c735460d95a241ccbea413909634f410>:0)
    18. UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <c735460d95a241ccbea413909634f410>:0)
    19. UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <c735460d95a241ccbea413909634f410>:0)
    20. UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <c735460d95a241ccbea413909634f410>:0)
    21. UnityEngine.UIElements.EventDispatcher.OpenGate () (at <c735460d95a241ccbea413909634f410>:0)
    22. UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <c735460d95a241ccbea413909634f410>:0)
    23. UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <c735460d95a241ccbea413909634f410>:0)
    24. UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <c735460d95a241ccbea413909634f410>:0)
    25. UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <c735460d95a241ccbea413909634f410>:0)
    26. UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <c735460d95a241ccbea413909634f410>:0)
    27. UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <c735460d95a241ccbea413909634f410>:0)
    28. UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <c735460d95a241ccbea413909634f410>:0)
    29. UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <c735460d95a241ccbea413909634f410>:0)
    30. UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <681fdbd9389e4d6e8755fe4f632bfbbe>:0)
     
    Last edited: Nov 21, 2022
  14. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    That's very old version you are using.
    Download new one using package manager, but before that clear Asset Store cache folder.
     
  15. ashetynw

    ashetynw

    Joined:
    Feb 25, 2018
    Posts:
    3
    I'm using the 2022.13 (Oct 22, 2022) version of TTM on Unity HDRP 2021.3.9f1. I've followed the instructions in the manual to recompile shaders, but when I build the project i get the following console output. Any ideas how I can resolve this issue?

    Code (CSharp):
    1. Shader error in 'Amazing Assets/Terrain To Mesh/Splatmap (Holes)': Fragment program 'Frag': Unrecognized sampler 'sampler_t2m_layer_0_diffuse' - does not match any texture and is not a recognized inline name (should contain filter and wrap modes).
    2. at line 3580 (on d3d11)
    I'll also note, I have tried a full uninstall, re-download and re-import of the package with the same result.
     
  16. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Can you paste the full error message?
     
  17. ashetynw

    ashetynw

    Joined:
    Feb 25, 2018
    Posts:
    3
    Code (CSharp):
    1. Shader error in 'Amazing Assets/Terrain To Mesh/Splatmap (Holes)': Fragment program 'Frag': Unrecognized sampler 'sampler_t2m_layer_0_diffuse' - does not match any texture and is not a recognized inline name (should contain filter and wrap modes).
    2. at line 3580 (on d3d11)
    3.  
    4. Compiling Subshader: 0, Pass: MotionVectors, Fragment program with WRITE_NORMAL_BUFFER _T2M_LAYER_0_MASK _T2M_LAYER_0_NORMAL _T2M_LAYER_1_NORMAL
    5. Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PASS_MOTIONVECTORS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
    6. Disabled keywords: INSTANCING_ON SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING WRITE_DECAL_BUFFER WRITE_MSAA_DEPTH _ADD_PRECOMPUTED_VELOCITY _ALPHATOMASK_ON _DISABLE_DECALS _DISABLE_SSR _DOUBLESIDED_ON _T2M_LAYER_10_MASK _T2M_LAYER_10_NORMAL _T2M_LAYER_11_MASK _T2M_LAYER_11_NORMAL _T2M_LAYER_12_MASK _T2M_LAYER_12_NORMAL _T2M_LAYER_13_MASK _T2M_LAYER_13_NORMAL _T2M_LAYER_14_MASK _T2M_LAYER_14_NORMAL _T2M_LAYER_15_MASK _T2M_LAYER_15_NORMAL _T2M_LAYER_1_MASK _T2M_LAYER_2_MASK _T2M_LAYER_2_NORMAL _T2M_LAYER_3_MASK _T2M_LAYER_3_NORMAL _T2M_LAYER_4_MASK _T2M_LAYER_4_NORMAL _T2M_LAYER_5_MASK _T2M_LAYER_5_NORMAL _T2M_LAYER_6_MASK _T2M_LAYER_6_NORMAL _T2M_LAYER_7_MASK _T2M_LAYER_7_NORMAL _T2M_LAYER_8_MASK _T2M_LAYER_8_NORMAL _T2M_LAYER_9_MASK _T2M_LAYER_9_NORMAL _T2M_LAYER_COUNT_10 _T2M_LAYER_COUNT_11 _T2M_LAYER_COUNT_12 _T2M_LAYER_COUNT_13 _T2M_LAYER_COUNT_14 _T2M_LAYER_COUNT_15 _T2M_LAYER_COUNT_16 _T2M_LAYER_COUNT_3 _T2M_LAYER_COUNT_4 _T2M_LAYER_COUNT_5 _T2M_LAYER_COUNT_6 _T2M_LAYER_COUNT_7 _T2M_LAYER_COUNT_8 _T2M_LAYER_COUNT_9 _T2M_TEXTURE_SAMPLE_TYPE_ARRAY
    7.  
     
  18. Arkhivrag

    Arkhivrag

    Joined:
    Apr 25, 2012
    Posts:
    2,843
    Should be fixed in tomorrow's update.
     
    lclemens likes this.
  19. lclemens

    lclemens

    Joined:
    Feb 15, 2020
    Posts:
    543
    Today is Friday so I was getting worried that the update wouldn't come this week and I was waiting to see if the fix came because if I couldn't get it to work, I was considering getting a refund.

    But just like you said - the update arrived the next week, and it works with URP and HRV2! Hats off to you sir.

    So for anyone wondering how to use this in a DOTS authoring component (baking in 1.0) such that any changes you make to the terrain automatically get converted to a mesh whenever you convert/bake your subscene:

    Code (CSharp):
    1.  
    2. // Use Amazing Assets to make a mesh from the terrain data.
    3. Mesh mesh = terrain.terrainData.TerrainToMesh().ExportMesh(256, 256, Normal.CalculateFromMesh, null);
    4. // This creates a material that uses the Amazing Assets splat-map shader.
    5. UnityEngine.Material material = terrain.terrainData.TerrainToMesh().ExportSplatmapMaterial(false);
    6. // Use the rendermesh utililty to add the mesh and mesh renderer to the entity.
    7. RenderMeshUtility.AddComponents(entity, dstManager, new RenderMeshDescription(mesh, material, UnityEngine.Rendering.ShadowCastingMode.On, true));
    And wala! 3 lines of code and I now have a fully rendered terrain with splatmaps in the scene as an entity instead of a game-object, and it looks spectacular!