Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

MapMagic 2 - infinite procedural land generator

Discussion in 'Assets and Asset Store' started by Wright, Apr 24, 2020.

  1. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    168
    For anyone whos chasing something similar down, this is the results of my cross controller tile scaling endeavor :

     
    Wright likes this.
  2. SteenPetersen

    SteenPetersen

    Joined:
    Mar 13, 2016
    Posts:
    103
    I'm not quite sure how you meant for me to use it as a normal graph and not brush, I just placed it in the mapmagic object Graph slot, but I cant paint anything, either with that graph as then the brush, or using something like the 'Add' brush, nothing happens.

    As for going for the 'non-pixelated look', that's in my write up, the final image is me increasing the resolution and avoiding the pixelated look, what seems to happen is although the base material is now high resolution as can be seen from the green area, the slope area which is painted on, using your brush not mine to make sure its correct, gets a much different resolution.

    upload_2024-2-8_8-4-31.png

    This is just me making the simplest MS graph you can imagine and painting a bit with add, and then with slope. How am I supposed to get MS to draw its textures normally?
     
  3. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    Sure, you can disable Use Draft Terrains for both editor and playmode in MM object -> Tile settings.

    It's for the test purpose - so, could MM generate noise terrain and properly paint it?

    To be honest I'm not a big MS expert and can't advise you much, but if you use the same setup for MS-only terrain and manual paint, with no MM involved - is it working?
     
  4. SteenPetersen

    SteenPetersen

    Joined:
    Mar 13, 2016
    Posts:
    103
    I'm sorry I still think it's quite unclear what you're asking me to do, If I place the brush as a graph for mapmagic, how would it generate a noise terrain? the brush doesn't have noise. I am placing the Brush here:
    upload_2024-2-8_21-54-0.png

    And then unpinning and repinning, it is not creating anything but a flat terrain with texture at slot 0. I cannot paint on it or do anything. I don't understand how it would create a terrain when it has not noise or anything, its just a brush using 'Inputs' and 'outputs', since there is no graph (replaced by the brush as far as understand from what you're asking me' there is no input to fetch? I'm confused and may need you to give me a bit more information as to what to do.

    As for the second thing, If I add an Empty terrain and add the MS terrain component with the microsplat material and then add the MM brush to subsequently use the 'Add' and then the 'Slope' brush, I get weird behavior as well ( see video).

    However, if I just make a terrain with MM using the microsplat node, it works fine and paints nicely.



    ===EDIT===

    Ok I made some progress, and can get a better look but only when working on a terrain converted to MicroSplat terrain, still doesn't work if the terrain is generated by Mapmagic.

    --edit-- Ok it seems I can get it to work with Mapmagic if I disable the 'Material Property Serializer', It seems the script conflicts with MicroSplat's dynamic material updates, preventing texture changes from applying during editing. I can see the script serializes and applies specific textures to terrain materials and stores texture assignments in arrays and uses a MaterialPropertyBlock to batch apply these textures to a terrain's material properties. Should I expect bugs in the use of mapmagic if I disable this, or should Microsplat simply take over for this script? as it seems to be doing?



    In the meantime, whats the thinking behind making a brush that when editing the terrain respecting the original rules of a terrain I create. Let's say I have biomes and I want when the brush raises or lowers or flattens terrain, it should repaint the textures with its original rules?
     

    Attached Files:

    Last edited: Feb 9, 2024
  5. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    168
    Not quite suitable for what i am after as a solution, but 100% pointed me in the right direction.

    Thank you :)
     
  6. SteenPetersen

    SteenPetersen

    Joined:
    Mar 13, 2016
    Posts:
    103
    I am having an issue where the I am trying to use brush at runtime and during the setup phase I am getting a weird outcome, I am quite sure that the reason this is happening is because the terrains have 'missing' textures.


    Video shows the difference between the terrain layers of the terrain in editor (they are all there) at runtime (they are 'missing')

    I don't however understand why the textures are missing. It draws the World just fine but when editing it messes up and will only draw with 1 and the wrong, texture. the sand texture. I don't know where it gets that texture from - its not the texture at slot[0] of the material used, that's the green texture, it's actually the terrainlayer/texture at position 5 in my MicroSplat material, the last slot.

    upload_2024-2-12_14-54-49.png

    == edit

    I recreated the entire stuff from scartch with a new material with a different texture in the last spot, and sure enough it uses the texture in the last slot to do the drawing.

    == couple hours later
    tried every single setting I can think of, both on the MS material as well as on the MapMagic object, nothing seems to change. It's as if when a tile is generated with 'pin the new tile' then the terrain layers of the terrain object, are fine, and have the correct texture and normalmap. But if the terrains are generated at runtime, then they either do not have the normal map, just the texture and the incorrect terrain layer. or they are just 'missing' entirely. How could this happen?

    Here is a video showing the result of a tile that was pinned at start, and one generated at runtime:

     

    Attached Files:

    Last edited: Feb 12, 2024
  7. SteenPetersen

    SteenPetersen

    Joined:
    Mar 13, 2016
    Posts:
    103
    I'm back to having this issue, don't know how it started all of a sudden, and creating a brand new material from scratch is not helping, I'm tired of getting all these issues tbh, At this point, I don't think its fair to say that MapMagic 2 has an integration with MicroSplat, it really doesnt. So many things are broken because it hasnt been looked at for so long.

    Very little documentation to go along with. I really hope that the focus atm is better documentation I can put this as an example, no information for the ADD node, but its far from the only one.and making the things that here, i.e. MicroSplat integration actually updated.

    Not the only one having this issue:

    https://forum.unity.com/threads/map...al-land-generator.875470/page-42#post-8510189

    This person did not post a solution, I guess they just gave up as well. Really frustrating, I wouldn't have gone down this road if it didn't say that these two assets where integrated.

    In case you want to look into this at some point; from my own documentation:

     
    Last edited: Feb 12, 2024
  8. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    It would really help if you could find and describe a reliable way to reproduce this issue. As far as I understand you're trying to make the Brush work in runtime, at the same time make it compatible with MicroSplat. You dive deep into modified way to use things, but if you could isolate the problem I could look into it and try to find out why it behaves this way.
     
  9. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    33
    I know that the "Relative Height" option in locks are only in beta, but it seems to work fine in the demo video on YouTube. It doesn't work for me, which is kind of frustrating. The changes in the heightmap are lost, and the lock gameobject position on the Y axis is not changing.

    If the option is not selected, it works well, and the terrain heightmap is "locked" when I modify the graph. But I really want it to follow the general height of the generated terrain. Is there a workaround that could be used to adjust the heighmap and the lock object?

    I'm using 2022 LTS (tested with earlier versions of 2022, and currently using 2022.3.20f). There are no messages in the console.
     
    Last edited: Feb 15, 2024
  10. Draganovaaa

    Draganovaaa

    Joined:
    Nov 18, 2021
    Posts:
    13
    Hello, I have a question about creating roads using the MM brush. I have all modules purchased and this is the way I have the road graph set up. (This is the first time I work with splines so I imagine I have messed something up but I am not sure what). Here is how the graph looks:
    *The foundation function is just a bunch of different noises that I use on top of a heightmap.
    Screenshot 2024-02-15 142509.png Screenshot 2024-02-15 142825.png The effect that I get as seen from the picture is that it draws a square and everything freezes for few seconds, no texture is being applied by the brush (using MicroSplat to paint terrain) and it seems to just be digging in the terrain instead of making a road.
    Screenshot 2024-02-15 143038.png
     
  11. Wuan23

    Wuan23

    Joined:
    Apr 12, 2023
    Posts:
    4
    I had the same problem building for android. I've disabled C++ Native Code however still have issues with infinite terrain where new tiles fail to load. Except for the main map, all other loaded maps are a plane.
     
    Last edited: Feb 15, 2024
  12. Wuan23

    Wuan23

    Joined:
    Apr 12, 2023
    Posts:
    4
    Me too. I also tried disabling multithreading, but still the same thing.
     
  13. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    168
    Sorry in advance, but im not as nice as Dennis....
    You sound like an idiot.

    Your failure to set stuff up right because you feel it should just work how you expect it to is a really bad place to start, but following that up with its broke it sucks whaaa whaaa..... is a worse place to end.

    These things work fine on my project, but thats cause i went through the steps to set it up right....

    Learn Unity...
    Till then i take you as serious as a crying baby.
     
  14. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    168
    Id swear that was pointed to recently as an issue within the last few thread pages by another user,
    and without looking i believe the culprit was how it was being compiled.
     
    Last edited: Feb 15, 2024
  15. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    168
    Ok i dug a little bit -


    same as your error, go read around there - the ultimate issue is that you have 2 seperate compilation flags pointing to the same asset file. find where both are occuring at (amsdef file i think?), and just remove EITHER one. I helped someone else solve this too doing the same thing, cant remember where so im not gonna dig for that answer, but if i stumble across the chat ill post that here for you.
     
  16. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    168
    why the import instead of generating mm native terrain?
     
  17. Draganovaaa

    Draganovaaa

    Joined:
    Nov 18, 2021
    Posts:
    13
    My boss wanted to me design a very specific layout for one of our levels. I liked using the tool so I tried to make it work even tho I am not generating fully procedural terrains! :)
     
    Greviouss likes this.
  18. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    168
    Mark me jelly that with all i can do in unity i dont have a job doing it :oops:
     
  19. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    I'd like to mention that this issue has been fixed (thanks Steen for providing detailed instructions on how to reproduce!). This happens due to more or less recent MicroSplat change, that adds some optimizations to avoid refreshing terrain layers in playmode. I've made a fix to make MM apply layers itself, it will be available in the next version.

    Any errors in the dev console?
    Can you please try switching to super-simple graph (like noise + height out) and low resolution (start with 65). If it generates draft and can't generate main tiles then it might be that the platform has not enough memory for that. Common thing in WebGL that applies strict memory limits, however I haven't heard it happen on Android.


    For all those who get this issue - turn off C++ native code in Window - MapMagic - Settings and remove Assets/MapMagic/Tools/Plugins folder completely.
     
    Wuan23 and Greviouss like this.
  20. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    The Brush has already Road preset - you can start with it to make your own. In short - Import is a wrong node to start with, it applies small copies of all terrain at brush stamp position. You've got to use Brush - Input - Height instead.
     
    Draganovaaa likes this.
  21. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    33
    Here's some images showing the problem...

    First image is showing the locked area with some changes to texture and heightmap, plus a small prefab building.
    Screenshot from 2024-02-19 10-48-03.png

    Second image is the hierarchy view, the lock parent object and the prefab building as a child to it.
    Screenshot from 2024-02-19 10-47-30.png

    Here's the lock itself:
    Screenshot from 2024-02-19 10-48-27.png

    Then I update the graph (the graph itself it irrelevant). The locked terrain works, but the prefab is left (green thing at the bottom of the image).
    Screenshot from 2024-02-19 10-49-38.png

    And a zoomed in image of the lock, showing that the terrain changes (texture and hightmap) follows the lock.
    Screenshot from 2024-02-19 10-49-59.png

    Missing is a screenshot showing the lock parent gameobject transform, which shows the X and Z being correct, but the Y value being zero.
     
  22. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    Are you sure that the pivot (not the center) of the object is located inside the lock? Some prefabs have an offset, you might place them by center, but they officially placed a bit elsewhere.
     
  23. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    33
    Yes, the pivot points are all fully inside the orange ring of the lock.
     
  24. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    43
    Hi, your MapMagic2 is a great tool, i pretty like it and consider buying it.
    Personally i prefer this than Gaia, i have no idea why Gaia is so hot, it should be MapMagic2!
    I want to know whether it's possible to runtime generate spline through scripts?
    It's quite important for my game to have a road always expanding while player moves forwad.
    I checked your tutorials and wikis and get a conclusion that mapmagic2 generates tiles based on pre-defined (or editor created) graphs.
    It seems there's no open api for programmer to dynamically change the graph variables thus runtime generate diverse tiles?
     
  25. Draganovaaa

    Draganovaaa

    Joined:
    Nov 18, 2021
    Posts:
    13
    Hey Wright! I did as you suggested and I understand where my mistake comes from with plugging the imported height instead, thanks for clarifying. I am still stuggling to make the brush work on my terrain. No matter what hardness I set for it it either 1 or nothing so it either makes a deep round hole in terrain or it does nothing when the value is too low. No material is applied to the terrain layer either (I am using microsplat for the textures, is there a different node that I need to use in the graph for that? *to note that the brush with just texture graph also does not pain new textures on the terrain).
    Below I demostrate changing the hardness of the brush and how it works right now (aplogies for the bad quality:()
     

    Attached Files:

    Last edited: Feb 22, 2024
  26. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    It's hard to say for sure without seeing the graph. Could you please make a screenshot?

    You can generate spline infinitely without using script - if you provide points (-10000,500) and (10000,500) to Manual node it will draw straight line along X axis. And then you can add pathfinding to convert this line into a road.

    And of course you can modify nodes values with script - here's how. Theoretically you can even create graph from scratch - that's how template graph is created. But I'd recommend you consider biomes instead.

    Oops, I believe you have an error in the console as well. I could reproduce this issue for manually placed objects. Will look into it soon. Thank you for letting me know!
     
    jpileborg likes this.
  27. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    43
    Thanks i will have a try
     
  28. Draganovaaa

    Draganovaaa

    Joined:
    Nov 18, 2021
    Posts:
    13
    Perhaps its best to start from just the texture brush graph: upload_2024-2-23_9-19-24.png
    I have tried changing the terrain layer to one of the default ones that came with MapMagic but still nothing is being painted on the terrain.
    upload_2024-2-23_9-20-1.png
    In any case here is the graph for the road brush which instead diggs into the terrain: upload_2024-2-23_9-21-53.png
     
  29. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    33
    Is there a way to create a mask or similar for grass, tree or object placement where two textures blend? A kind of logical AND, or set intersection operation?

    My specific use-case is that I want to place a grass node with some reeds along where a beach meets the grass, so where the sand and grass textures are blending together.

    I have tried with all blend-node modes without any luck.
     
  30. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    Logical AND is Multiply:
    if both inputs are 1 it gives 1 (1*1=1),
    if one or both inputs inputs are 0 it gives 0 (1*0=0)

    BTW logical OR is Add: 1+1=1 (clamped), 1+0=1, 0+1=1, 0+0=0

    Well, you are using modified height as Mask's Input A - you've got to either invert Spot or connect modified height to Input B.
    Then you are applying Spot mask modifications with Levels. It is okay, but it makes Hardness behave differently. Probably this is the issue.
     
    Draganovaaa and jpileborg like this.
  31. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    33
    Oh I see my mistake now, I was looking at a part of the world where the blending was just too sharp, probably due to angles. When I looked at other places where the angles between the beach and the meadow was more shallow, and the blending larger, the reeds were there.

    Anyway, thanks for taking your time with a mistake of mine. ;)

    Now I just have to figure out a way to check for that as well.
     
  32. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    33
    I have another problem with splines when using the stamp node. In earlier testing the Before the node set all height to zero, but now to the max height:
    Screenshot from 2024-02-24 17-31-55.png

    The "Paths" enter-/exit-pair goes directly to the graph height output node.

    Hopefully it's a mistake of mine and not another bug.

    Still on Unity 2022.3.20f, URP, Linux system, and using MM2 version 2.1.15 bundle.

    If I'm not using the stamp node, the path is fine but not very flat. ;)
     
    Last edited: Feb 25, 2024
  33. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    It's hard to say without seeing the whole graph. Maybe it's worth trying to use Splines/Floor node before the Stamp?
     
    jpileborg likes this.
  34. SteenPetersen

    SteenPetersen

    Joined:
    Mar 13, 2016
    Posts:
    103
    Hi Denis,

    I have continued work on my project and gotten quite a bit further since resolving the issue with MicroSplat. I am editting terrain just fine and even doing so through networking, it's all working great.



    However, I'd like to place a limit on the maximum amount a player can raise or lower the terrain. And am wondering if you have any ideas as to the best way to do this. Here is what I tried:

    I tried making a TerrainHeightManager that would basically validate if a player is allowed to raise or lower the terrain

    Code (CSharp):
    1. public class TerrainHeightManager : MonoBehaviour
    2.     {
    3.         [SerializeField] private float maxAllowedHeightDifference = 8.0f; // Max allowed height difference
    4.         private Dictionary<Terrain, float[,]> terrainOriginalHeights = new Dictionary<Terrain, float[,]>();
    5.  
    6.         public void AddTerrain(Terrain terrain)
    7.         {
    8.             if (terrainOriginalHeights.ContainsKey(terrain)) return;
    9.          
    10.             float[,] originalHeights = StoreOriginalHeights(terrain);
    11.             terrainOriginalHeights.Add(terrain, originalHeights);
    12.             DebugController.Log("Terrain added with original heights stored.");
    13.         }
    14.  
    15.         public bool ValidateTerrainHeight(Vector3 worldPosition, float newHeight, Terrain terrain)
    16.         {
    17.             if (!terrainOriginalHeights.ContainsKey(terrain))
    18.             {
    19.                 DebugController.LogError("Terrain not managed by TerrainHeightManager.");
    20.                 return false;
    21.             }
    22.  
    23.             int x, y;
    24.             ConvertWorldPositionToHeightMapCoords(terrain, worldPosition, out x, out y);
    25.             float originalHeight = terrainOriginalHeights[terrain][y, x] * terrain.terrainData.size.y;
    26.  
    27.             float currentHeightDifference = Mathf.Abs(newHeight - originalHeight);
    28.             bool isValid = currentHeightDifference <= maxAllowedHeightDifference;
    29.  
    30.             if (!isValid)
    31.             {
    32.                 DebugController.LogError($"Height change at {worldPosition} is too large. Current difference: {currentHeightDifference}, Allowed difference: {maxAllowedHeightDifference}");
    33.             }
    34.  
    35.             return isValid;
    36.         }
    37.  
    38.         private float[,] StoreOriginalHeights(Terrain terrain)
    39.         {
    40.             TerrainData terrainData = terrain.terrainData;
    41.             return terrainData.GetHeights(0, 0, terrainData.heightmapResolution, terrainData.heightmapResolution);
    42.         }
    43.  
    44.         private void ConvertWorldPositionToHeightMapCoords(Terrain terrain, Vector3 worldPosition, out int x, out int y)
    45.         {
    46.             Vector3 terrainLocalPos = worldPosition - terrain.transform.position;
    47.             Vector3 normalizedPosition = new Vector3(
    48.                 terrainLocalPos.x / terrain.terrainData.size.x,
    49.                 terrainLocalPos.y / terrain.terrainData.size.y,
    50.                 terrainLocalPos.z / terrain.terrainData.size.z
    51.             );
    52.  
    53.             x = Mathf.FloorToInt(normalizedPosition.x * terrain.terrainData.heightmapResolution);
    54.             y = Mathf.FloorToInt(normalizedPosition.z * terrain.terrainData.heightmapResolution);
    55.         }
    56.     }

    And although this works "ok", it has some issues due to the fact that the way the mapmagic brush works, I may check a terrain height and get denied in the validation, but nearby I can raise the terrain, and while raising the terrain there, it will inadvertently raise the terrain over the area that is declined as well.

    So my thinking was that I should limit the raise/lower of the terrain in mapmagic itself during the 'ApplyHeights' method of the TerrainCache.cs script. But I don't like editing your code too much as I would like to be able to update the mapmagic asset when you come with new stuff. So before doing that I just wanted to to ask if you have any good ideas as to how I should go about this?

    Someway to store the terrain original height and then validate against them when actually editing the terrain.

    ==== Edit

    Just had the thought that perhaps the brush is the correct place to do this. A custom nodes that limits height perhaps.

    So I have been meddling with the custom nodes and I am wondering how I could get access to one of my scripts from the node itself. Has anyone tried doing something like this?

    Code (CSharp):
    1. using System;
    2. using Den.Tools.Matrices;
    3. using MapMagic.Products;
    4. using MapMagic.Nodes;
    5. using MapMagic.Terrains;
    6.  
    7. [Serializable]
    8. [GeneratorMenu(
    9.     menu = "Custom",
    10.     name = "Height Constraint",
    11.     section = 2,
    12.     colorType = typeof(MatrixWorld),
    13.     iconName = "GeneratorIcons/Height"
    14. )]
    15. public class HeightConstraintGenerator : Generator, IInlet<MatrixWorld>, IOutlet<MatrixWorld>
    16. {
    17.     #if UNITY_EDITOR
    18.     [UnityEditor.InitializeOnLoadMethod]
    19.     static void EnlistInMenu() => MapMagic.Nodes.GUI.CreateRightClick.generatorTypes.Add(typeof(HeightConstraintGenerator));
    20.     #endif
    21.  
    22.     public override void Generate(TileData data, StopToken stop)
    23.     {
    24.         MatrixWorld src = data.ReadInletProduct(this);
    25.         if (src == null) return;
    26.         if (!enabled) { data.StoreProduct(this, src); return; }
    27.         if (stop != null && stop.stop) return;
    28.  
    29.         MatrixWorld result = new MatrixWorld(src);
    30.        
    31.         ApplyHeightConstraints(result, data.area);
    32.  
    33.         data.StoreProduct(this, result);
    34.     }
    35.  
    36.     private void ApplyHeightConstraints(MatrixWorld heights, Area area)
    37.     {
    38.         // somehow get access to the TerrainHeightmanager or something similar
    39.  
    40.         // Loop through the heights in the area and compare them to the original heights
    41.        
    42.         // Validate/decline the terrain modification and clamp the height if necessary
    43.     }
    44. }
     
    Last edited: Mar 1, 2024
  35. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    33
    Adding the Floor node makes it work. As long as I don't try to play the game. When I do I get a lot of errors:
    Code (CSharp):
    1. Thread failed: System.IndexOutOfRangeException: Index was outside the bounds of the array.
    2.   at MapMagic.Nodes.SplinesGenerators.Floor200.Generate (MapMagic.Products.TileData data, MapMagic.Products.StopToken stop) [0x000a2] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Generators/Splines/Runtime/SplinesGenerators.cs:857
    3.   at MapMagic.Nodes.Graph.GenerateRecursive (MapMagic.Nodes.Generator gen, MapMagic.Products.TileData data, MapMagic.Expose.Override ovd, MapMagic.Products.StopToken stop) [0x00262] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Nodes/Graph.cs:953
    4.   at MapMagic.Nodes.Graph.GenerateRecursive (MapMagic.Nodes.Generator gen, MapMagic.Products.TileData data, MapMagic.Expose.Override ovd, MapMagic.Products.StopToken stop) [0x000ac] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Nodes/Graph.cs:917
    5.   at MapMagic.Nodes.Graph.GenerateRecursive (MapMagic.Nodes.Generator gen, MapMagic.Products.TileData data, MapMagic.Expose.Override ovd, MapMagic.Products.StopToken stop) [0x00059] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Nodes/Graph.cs:910
    6.   at MapMagic.Nodes.Graph.GenerateRecursive (MapMagic.Nodes.Generator gen, MapMagic.Products.TileData data, MapMagic.Expose.Override ovd, MapMagic.Products.StopToken stop) [0x00102] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Nodes/Graph.cs:923
    7.   at MapMagic.Nodes.Graph.GenerateRecursive (MapMagic.Nodes.Generator gen, MapMagic.Products.TileData data, MapMagic.Expose.Override ovd, MapMagic.Products.StopToken stop) [0x00059] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Nodes/Graph.cs:910
    8.   at MapMagic.Nodes.Graph.Generate (MapMagic.Products.TileData data, MapMagic.Products.StopToken stop, MapMagic.Expose.Override ovd) [0x00047] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Nodes/Graph.cs:895
    9.   at MapMagic.Nodes.Biomes.BiomesSet200.Generate (MapMagic.Products.TileData data, MapMagic.Products.StopToken stop) [0x00234] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Generators/Biomes/Runtime/BiomesSet.cs:178
    10.   at MapMagic.Nodes.Graph.GenerateRecursive (MapMagic.Nodes.Generator gen, MapMagic.Products.TileData data, MapMagic.Expose.Override ovd, MapMagic.Products.StopToken stop) [0x00262] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Nodes/Graph.cs:953
    11.   at MapMagic.Nodes.Graph.Generate (MapMagic.Products.TileData data, MapMagic.Products.StopToken stop, MapMagic.Expose.Override ovd) [0x00047] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Nodes/Graph.cs:895
    12.   at MapMagic.Terrains.TerrainTile.Generate (MapMagic.Nodes.Graph graph, MapMagic.Terrains.TerrainTile tile, MapMagic.Terrains.TerrainTile+DetailLevel det, MapMagic.Products.StopToken stop) [0x00052] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Terrains/TerrainTile.cs:724
    13.   at MapMagic.Terrains.TerrainTile+<>c__DisplayClass49_0.<EnqueueTask>b__0 () [0x00000] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Terrains/TerrainTile.cs:632
    14.   at Den.Tools.Tasks.ThreadManager.TaskThreadAction (Den.Tools.Tasks.ThreadManager+Task task) [0x00002] in /home/arrow/Media/Unity/Flyga/Flyga_10/Assets/MapMagic/Tools/ThreadManager/ThreadManager.cs:138
    15. #0 GetStacktrace(int)
    16. #1 DebugStringToFile(DebugStringToFileData const&)
    17. #2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
    18. #3  (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
    19.  
    Added the Floor node like this. I don't know if it's correct, since the documentation for it is missing... ;)
    upload_2024-3-1_13-24-53.png
    (Disregard the Avoid node, that's just me playing with other things.)

    HeightFarm
    is the current heightmap, and
    Paths
    will be the new (after flattening) heightmap.

    PS. I know splines is still in beta, but it's a little bit under-documented and lacking tutorials or examples. I hope that will be solved in the future.
     
    Last edited: Mar 1, 2024
  36. rakyatmiskin

    rakyatmiskin

    Joined:
    May 19, 2013
    Posts:
    6
    Hello,

    I have problem using the MapMagic 2 free to collaborate using git.
    I create a scene using 3 by 3 grid terrain generated by MapMagic, I use MapMagic only for the initial terrain generation and I do customization (reshape) the terrain using unity built in terrain system. I push my progress to git and my friend tried to clone the project (all MapMagic imported folder and my new scene). The clone process don't have any issue but when my friend open the project there will be error that state unknown error when opening scene that happen to all the scene from the MapMagic imported folder and my new scene with terrain I created using MapMagic.

    Is there certain approach to use MapMagic with git? (another notes, when I tried to commit the progress for the first time, I do put some item to LFS some of it from the MapMagic folder)
     
  37. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    Could you please check - if you unpin all the tiles, will your friend will able to load the scene with no terrains in it? If so, it's worth trying to save terrains as separate terrainData assets: in MM object, Tiles use button Save Terrain Data for each of the tiles.

    Yep, it's still in Beta. That's why there is debug code here and there. And it seems that his debug causes an error - just remove or comment out lines 856, 857, 858 of SplineGenerators.cs
    Sorry for that. Removing debug here for next release.

    There's TerrainTile.OnTileApplied event. It's called right after MM has finished applying heights and all the other terrain data, and you can make your custom modifications here.

    So, you want to get per-pixel height delta between original terrain brush reads, and the height it generates, and clamp it?

    If so you've got to provide two maps for your custom node - make it IMultiInlet, like Blend200. Don't forget to use IEnumerable<IInlet<object>> Inlets() here to register inlets.

    Then you've got to iterate matrix with simple for 0 to count loop - see Matrix.Add as an example. It adds two matrices together, but you can perform more complex math here. Matrix.Add is in C++ for performance reasons, but there's still C# code in Matrix.cs that is turned off by default with MM_NATIVE define.
     
    jpileborg likes this.
  38. rakyatmiskin

    rakyatmiskin

    Joined:
    May 19, 2013
    Posts:
    6
    Thank you for your answer. I'll try to save the terrain data first.
     
  39. MrFoxmanGaming

    MrFoxmanGaming

    Joined:
    Sep 2, 2018
    Posts:
    3
    Any know of guides or have any tips/tricks for implementing roads?

    I’ve been tinkering with this and I can’t seem to get proper roads, let alone getting them to actually level out. They’ll pass over weird peaks or become peaks along the path where there wouldn’t be before. I tried analyzing some of the nodes from this dev on YouTube


    But couldn’t really see enough to help with the issues I was having. His also seems to have some nice rolling hills and flat(er) grasslands and I just can’t seem to get something that looks half as nice..
     
  40. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    Wow, I'm on TV!

    Have you checked demo scenes included with MM? Tutorial Splines scene that makes roads avoid mountains and steep slopes with Pathfinding node, and Hills scene, which, well, shows hills.
     
  41. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    33
    To increase performance I want to use a third-party vegetation renderer. I have tried both VSP-B and the new Foliage Renderer.

    With VSP-B I don't get vegetation everywhere, only along half the terrain (cut along a straight line). Only tried for a single tree though, since I need to add a lot of VSP nodes.

    With FR all the grass disappears when I enable FR, and comes back when I disable FR.

    There's also another problem with FR, and that is the terrain-component needed by FR doesn't handle the copying to the generated terrain tiles very well. First of all it doesn't like being a component of a non-terrain object, like the MapMagic copy-component toggle seems to require. Then it somehow gets upset that it's added to a terrain that doesn't quite exist yet, as the tiles are created. This feel more like a FR problem, even though the use-case might be too small for them to change.

    While it may be harder for the FR issues, have anyone experienced it? Have anyone else tried using FR with MM2? Then how about the VSP-B problem, is it something unique to VSP-B? Have anyone seen it with the old VSP? Is it the VSP-B integration, a problem with the VSP node, or with VSP-B itself?

    PS.
    I have tried GPUInstancer, and while it works it actually gives me much less performance. In-editor FPS drops from around 30-40 to around 1-5. I also haven't tried Nature Renderer yet, will do that tomorrow.

    ---

    Update: In the FR Indirect Renderer object, I disabled "Distance Check Updates", and the grass renders fine now.

    I will look into what events I can get from MM2, to perhaps add/remove the FR terrain component myself.
     
    Last edited: Mar 10, 2024
  42. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    Something's wrong with my provider. As far as I understand site and email are currently not working. Try to fix it ASAP. Sorry for this. Feel free to write here in this thread.

    Interesting finding. So you could make MM work with FR? If so may I add this to FAQ?

    There is a way to copy component assigned to MM to each of the terrain tiles: you have to enable Copy Components to Terrains in MM object Terrain Properties.
     
  43. jpileborg

    jpileborg

    Joined:
    Jan 5, 2013
    Posts:
    33
    Well... I kind of got it to work... ;)

    I use TVE for the vegetation, and then it works fine with the way I mentioned before. But if I don't use TVE there were some shader problems. It could be specific to the Synty assets I use, I don't know. I can do some testing with the sample assets that comes with MM2 if you'd like?

    Yes I know, but unfortunately it doesn't work. Foliage Renderer gives me errors if I try to use it. Either because the MM object doesn't have an actual terrain component (which the Foliage Renderer component requires), or some other errors when a disabled component is copied to the terrains at generation.

    It shouldn't be too hard to use the
    OnTileApplied
    event to add the component when needed. :)
     
  44. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    168
    since VSP-B is the subject -
    I am working on fixing vsp-b compatible vsmaps that work with multiple biomes...
    Heres the working shot of this on a tile in the editor with 3 biomes (sorry about the lighting) :
    upload_2024-3-12_6-50-36.png

    (and one with better lighting and the waterline off to make it more apparent)
    Unity_ksIgd9sYVp.png
     
    Last edited: Mar 12, 2024
    Wright likes this.
  45. o888Roses

    o888Roses

    Joined:
    Nov 27, 2019
    Posts:
    21
    Hello! I've been trying to get infinite roads to work in my game as well, but whenever I connect a Pathfinding node to a Manual node as you said, it throws an exception:
    Code (CSharp):
    1. Thread failed: System.Exception: Line points number is <= 1
    2.   at Den.Tools.GUI.PolyLine.SetPointsThread (UnityEngine.Vector3[][] points, System.Int32 numPoints) [0x0003d] in ___\Assets\MapMagic\Tools\SceneEdit\Editor\PolyLine.cs:59
    3.   at MapMagic.Previews.SplinePreview.ExecuteInThread () [0x000cc] in ___\Assets\MapMagic\Preview\Editor\SplinePreview.cs:94
    4.   at Den.Tools.Tasks.ThreadManager.TaskThreadAction (Den.Tools.Tasks.ThreadManager+Task task) [0x00002] in ___\Assets\MapMagic\Tools\ThreadManager\ThreadManager.cs:138
    5. UnityEngine.Debug:LogError (object)
    6. Den.Tools.Tasks.ThreadManager:TaskThreadAction (Den.Tools.Tasks.ThreadManager/Task) (at Assets/MapMagic/Tools/ThreadManager/ThreadManager.cs:144)
    7. System.Threading.ThreadHelper:ThreadStart ()
    Here is the graph:
    upload_2024-3-12_14-58-48.png

    I have been trying using both Positions and Manual nodes and both of them throw this exception. Any idea about how I could solve this?

    Thanks in advance,
    Rose
     
  46. o888Roses

    o888Roses

    Joined:
    Nov 27, 2019
    Posts:
    21
    After some tweaking around, I found that like the error said, the problem was coming from the preview GUI. Simply closing the preview will solve the issue all together. In the end, here is how the graph looks like for the ones interested:

    upload_2024-3-12_16-8-57.png

    The result could look a lot better but now that it actually works, I can tweak it to look great ^^

    upload_2024-3-12_16-11-3.png
    (result when using the graph provided above)
     
    Swyfft and hopeful like this.
  47. Tim-Wiese

    Tim-Wiese

    Joined:
    Jul 7, 2012
    Posts:
    77
    Hi @Wright
    If anyone from 2021 LTS or earlier jumps into 2022 LTS with their mapgraph they'll notice their details (grass) will be non-existent unless you crank the density to an absurd level and even then it won't match the previous look.
    Digging into this thread we saw @TheSniperFan @protopop seemed to run into similar issues.

    Anyways, we were able to make a quick fix that works for us (and hopefully anyone else!)

    Go to terraintile.cs
    Add this code:

    terrainData.SetDetailScatterMode(DetailScatterMode.InstanceCountMode);

    At line 434 under

    terrainData.size = (Vector3)mapMagic.tileSize;

    Now the grass node should work as it was prior to the newer 2022 Detail default settings. Dennis was this something you were looking into addressing. Maybe you did already?
    Hope this helps!
     
  48. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,271
    To be honest I don't even know what these assets are :D But I believe other users might find it really useful.

    Probably it requires some specific initializing. Yes, OnTileApplied is the right place to add component then.

    Thank you for finding this! Will try to find out why the preview gives an error.

    It surely will! Will test it and include in next update if that's why grass looses density.

    @All: One of the benefits of making a tool for other devs - is very constructive feedback, sometimes even bugfixing. I really like it, and I greatly appreciate it. I cannot put into words how grateful I am to you for such responsiveness. It's a pleasure to work with you!
     
  49. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    168
    MM does use a standard terrain component - its a child object of TerrainTile, theres one for draft and main...
     
  50. valentinwinkelmann

    valentinwinkelmann

    Joined:
    Nov 3, 2014
    Posts:
    190
    @Wright If I have an infinite number of islands in a procedural MapMagic world, can I use splines at a fixed height (sea level) to output the contours of the islands as unity splines to spawn certain objects around an island (e.g. particle emitters for waves moving towards land)? Is that what the Isoline Node is for? it doesn't seem to have any input parameters.