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.

MapMagic 2 - infinite procedural land generator

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

  1. Liminal-Ridges

    Liminal-Ridges

    Joined:
    Oct 21, 2015
    Posts:
    237
    @Wright in the grass node the density only works up to 10. after that nothing changes, any idea why?
     
  2. SoDynamic_

    SoDynamic_

    Joined:
    Mar 5, 2014
    Posts:
    3


    Thanks for the reply! In case it's helpful to you I want to highlight the fact that the FAQ suggests it happens in Unity 2021.2 or later, but I'm seeing this issue on Unity 2020.3. It also mentions that "According to users feedback the issue doesn't occur in URP and HDRP." I'm using URP in this project and also still seeing this issue. I'm going to continue digging to see if I can't find a work-around and will try and report back if I find anything.
     
  3. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    Will see what I can do. Probably it will be the other node, not Move. It should work differently. Maybe Local Move or something.

    Well there are drafts that can have lesser resolution. Yes, there is only one level of drafts, but it's made for a reason. Each detail level - like 1000, 2000, 6000, 18000, 54000, etc. - requires generating from scratch. So terrain should be generated 5 times, maybe more.

    Using terrains of size 54000 don't actually makes sense. You've got to use completely different technology to display it, like impostor background. There's no reason to set the camera far plane that far. So it will take time to generate 4 tiles of this huge size (4 because player can be spawned at intersection) that won't be visible.

    Could you please describe exact steps you are making and what you want to achieve at the end?

    As far as I remember Unity has it's own limitations on grass density. More precisely, on combination of density and resolution per patch. At reaching some level it just don't display any grass in a patch at all. At least it was this way in older Unity versions, need to check if this is still relevant.

    I suppose 2020.3 is LTS version of Unity, it probably didn't exist at that moment and was released after 2021.2 - however not sure that I remember this correctly. I have not checked if it's relevant in URP or HDRP myself, but got reports that it was okay. Probably will add "according to others, it does" :)
     
    Liminal-Ridges likes this.
  4. Astrobinary

    Astrobinary

    Joined:
    Aug 20, 2013
    Posts:
    4
  5. Gildar76

    Gildar76

    Joined:
    Oct 6, 2015
    Posts:
    20
    Hi,

    I'm new to MM2 and I'm trying to create a biome set. THe tiles work fine individually, but I can't make them work together. I've tried with leves, curves and now selectors, but I end up with the same result. I'm using imported maps, which I suspect is related in some way because I have the recently mentioned problem of import maps not saving properly. (saved project, saved all sxenes and so on using red channel 4k pngs).

    On the attached image is my main graph at the top with the biomes loaded.
    The second row contains the same graphs loaded as separate maps. They all have the same resoulution and height.

    I made the transitions absurd just to show the isue clearly.




    Thanks
     
    Last edited: Dec 10, 2022
  6. delany

    delany

    Joined:
    Nov 20, 2013
    Posts:
    10
    MM2 Doesn't seem to work at all on Apple Silicon versions of Unity (using latest MM2 version 2.1.12). Just gives a bunch of:

    Thread failed: System.DllNotFoundException: NativePlugins assembly:<unknown assembly> type:<unknown type> member:(null)

    This happens if I try creating a terrain from scratch or if I convert an already existing one.

    I've tried reaching out via email, reporting the bug on the bug report page (there is already a bug report of this from April with no response) - but no response. Is there a workaround for this? A fix in the pipeline? Thanks for any help.
     
  7. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    Sure, adding to my to-do list!

    Sorry, but I could not get what the issue is. I'm missing the first step. It would be helpful if you could make a screenshot of your result, without special adjustments like removing transitions - it's hard to say what was made specifically and what is the issue. And highlight on this screenshot what is wrong.

    Screenshot of your graph will come in handy as well. Probably you have it in second image, but it's not loading.

    You can disable Native Code in Window -> MapMagic -> Settings.
    However this will make MM slower (especially in editor). Alternatively you can try using this native plugins bundle.
     
  8. Gildar76

    Gildar76

    Joined:
    Oct 6, 2015
    Posts:
    20
    I made the screenshot to show the issue.
    The three tiles at the bottom are the biomes dragged in separately.

    The three tiles at the top are generated from a single graph, using tthe three biomes shown in the bottom row. As you can see in the image, the first tile to the left looks pretty much the same both as a separate terrain and in the bomes set graph. The other two tiles however are missing all the topography except for the noise (I think). My guess is that imported heightmaps are ignored completely.

    I restarted Unity just now and my "Imported map" assets has now lost their textures, but I did the setup again.

    Here's the screenshot of the main graph.


    And here is one of the subgraph (the one to the right in the above screenshot.
     
  9. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    Are you dragging your "demo" tiles manually, not pinning them? If so they all have initial tile coordinate, at 0,0. While biomes use different coordinates 0,0 0,1 and 0,2. You are using Import map with zero offset, that is why it's visible on the initial tile only. If you pin any other tile in your non-biome graph you will get the same "import ignored" result.

    You can either adjust the offset in import nodes (in world units) or just switch Import node Wrap Mode to Tile to make the map[ repeatable.
     
  10. Gildar76

    Gildar76

    Joined:
    Oct 6, 2015
    Posts:
    20
    THanks, the clap setting solved the problem. Now I have a different issue cause I use scale < 1 on one of the maps to place it on a specific part on a tile, but I think I can figure out a way around that (I can always merge the maps to one heightmap).

    I thought each tile was treated individually, with relative position when used in a biome set. So, to answer your question. WHen I wanted to show the individual tiles I dragged them in as separate terrains, but for the maingraph I used pin as new tile.

    Now my only problem is the bug which I've seen other people mention. Maybe this is not the right place to post it, but I'll do it while I'm writing this. All maps loose their settings on Unity restart. This is easy to reproduce.

    1. Create a new project (('m using 2021.3.15f).
    2. Import Mapmagic 2 bundle.
    3. Import some stamps (just reproduced with Stampit collection examples from the store).
    4. Make sure the stamps are read/write enabled (most of them, but not all are)
    5. Create an imported map asset (create->Mapmagic->imported map) andset the map.These maps are pngs using the red channel, so set that as well.
    6. Save project
    7. Restart Unity and check the imported map asset. It's now empty and reset to RAW.

    I assume this works with any PNG heightmap, but haven't tried to reproduce it with other heightmaps.

    Thanks again for explaining the Biome positioning.
     
  11. Liminal-Ridges

    Liminal-Ridges

    Joined:
    Oct 21, 2015
    Posts:
    237
    @Wright grass suddenly died today after changing the heightmap in the import node. tried everything but no grass
     
  12. delany

    delany

    Joined:
    Nov 20, 2013
    Posts:
    10
    This worked to solve that apple silicon issue - thank you! (I replaced the NativeCode bundle in the Package Manager downloaded MM2 with the one you linked to).

    However, this has exposed a wider issue. It seems MM2 doesn't work with the latest few Unity LTS releases (up to current 2021.3.15f1). I've tried it on both Apple Silicon and Windows versions and get the same issue.

    When I create a new MM2 GameObject->3D Object->MapMagic, I immediately get a error:

    Exception: MapMagic: Graph data is not assigned
    MapMagic.Core.MapMagicObject.StartGenerateNonReady () (at Assets/MapMagic/Core/MapMagicObject.cs:360)
    MapMagic.Core.MapMagicObject.OnEnable () (at Assets/MapMagic/Core/MapMagicObject.cs:120)
    UnityEngine.GameObject:SetActive(GameObject, Boolean)
    MapMagic.Core.GUI.MapMagicInspector:CreateMapMagic(Graph) (at Assets/MapMagic/Core/Editor/MapMagicInspector.cs:658)
    MapMagic.Core.GUI.MapMagicInspector:CreateMapMagic() (at Assets/MapMagic/Core/Editor/MapMagicInspector.cs:647)

    I can assign, say, a pre-made graph to that object (say the Badlands demo graph) - and it will render the terrain for that graph. However, the graph does not appear in the MM2 editor - so I can't edit the graph. This is true for empty graphs creating one from scratch - so you essentially can't create graphs in these versions of Unity as far as I can tell.

    Like I say, I get the same issue in both Apple Silicon and Windows versions.

    If I upgrade a pre-made MM2 object to this version, it works fine, with the graph continuing to appear in the editor. It's just I can't create new MM2 objects.

    Any thoughts? Thanks again.
     
  13. Erlend1

    Erlend1

    Joined:
    Dec 18, 2019
    Posts:
    20
    Hello,

    My primary issue is that grass from third parties with custom shaders won't generate with the Grass Node (Map > Output > Grass). I would like to test grass from other assets like FAE (Fantasy Adventure Environment by Staggart Creations). To make matters more complicated, I'd like to use TVE (The Vegetation Engine), which converts those shaders again.
    mm2-fae-no-grass-on-output-small.png
    There is a documentation page for Grass, but I still don't know how to convert or modify the grass prefabs to make them work with the Grass Output Node. As for the Mode, since it's a prefab and not just a texture, I thought it should use Mesh Unlit.

    Initially, I asked on Discord, but didn't get a response.
     
  14. Kesarium

    Kesarium

    Joined:
    Dec 3, 2014
    Posts:
    36
    Hi, I'm just starting out using Map Magic 2 and I'm using URP 12.1.18 with Unity 2021.3.15f1 and when I click on a node on the graph and try to display its preview on the terrain, my selected preview terrain just turns invisible. How can I get the heatmap preview to show up on the terrain?
     
  15. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    314
    Hi, I want to use the brush to paint multiple textures on my terrain at once using different rules.

    I managed to do it one by one for each texture with the rules and it works quite well. For example:
    upload_2022-12-14_1-8-29.png

    Now I got 4 layers total. one being the main texture, then a variation that uses noise to paint some different spots over it, and then a 3rd for hills and a last one for cliffs.

    I can't seem to understand how to combine them into one graph that paints the 4 textures at once. How do I do that?

    Thanks
     
  16. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    314
    This is the best attempt I've tried, but nothing happens.
    upload_2022-12-14_20-50-49.png
     
    Last edited: Dec 15, 2022
  17. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    314
    Well nevermind, I found my solution :) For any future reader looking for a solution:
    upload_2022-12-14_22-35-58.png
     
  18. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    Could you please paste a screenshot of your graph? Does it work if you drag-and-drop it in an empty scene?

    Thanks for providing such a detailed steps to reproduce the issue! Will try to look into it soon.

    I have not tried these assets and I'm not aware how they work and what grass data they accept. So unfortunately I can't help you with this.

    However it's just a server where users share their own knowledge, screenshot, advises, etc. I'm not a frequent guest here, so I can't recommend using it as a support channel.

    Do you have any error in the console? Is it a new clear project (or you moved MM from other, or updated current project)?

    Try using Add node for all new terrain layers one by one instead of Combine, the way it's done in Erosion or SlopeCavity:
    upload_2022-12-16_18-21-35.png
     
  19. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    314
    Hi again

    We're working on a quite big world so we sometimes need to paint on hundreds of terrains using mapmagic brush. It gets very slow when trying to paint with a large brush. I'm talking up to 30 seconds of editor stalling for every brush stroke. Are there any settings that could help speed it up, like draw instanced for example?

    Thanks.
     
  20. tgaldi

    tgaldi

    Joined:
    Oct 28, 2015
    Posts:
    102
    Hi, how can I use MapMagic to modify an existing terrain created outside of its generation system? I don't see the pin existing terrain button from the video.
     
  21. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    The bigger the brush - the more terrain pixels it edits. More pixels - more calculations needed to be done for processing them. And it follows square law - if you have just 314 pixels for radius 10 you will have 1256 pixels for radius 20. For hundreds of terrains it really should take a lot of time to apply single brush stroke.

    MapMagic can't modify already existing terrains - with each generate it will change terrain, and on next generate will read changed data. I've tried to experiment storing data, but gave up because of it's instability and inability to serialize. However, I don't remember recording a video of this feature - what video are you talking about?
     
  22. tgaldi

    tgaldi

    Joined:
    Oct 28, 2015
    Posts:
    102

    In the quickstart video there is a button on the MapMagic Object component that says "Pin Existing Terrain". Its also mentioned briefly in the manual but I don't see it when using MapMagic and I didn't know if it worked on an existing terrain that's been modified. I'm working with Houdini/HoudiniEngine to generate the terrain and wanted to use MapMagic afterwards.
     
  23. NestorVG

    NestorVG

    Joined:
    Feb 12, 2019
    Posts:
    22
    What would be the best way to allow objects (especially those that have rigid bodies) to be "moved" from one chunk to another? I'm making a game similar to Rust and obviously, I have to attach the structures built to the chunk they are placed in, but with rigid bodies (vehicles, dropped items, or even NPCs) this is a little more difficult, has anyone done that before?
     
  24. JohnnyRobert

    JohnnyRobert

    Joined:
    Dec 8, 2022
    Posts:
    10
    Do you guys know why Digger Pro only allows digging on the pre-generated chunk but not on the other chunks generated by MapMagic 2 during runtime (in play mode) ? The runtime example scripts they provide do not seem to work with MapMagic 2 during runtime.
     
  25. JohnnyRobert

    JohnnyRobert

    Joined:
    Dec 8, 2022
    Posts:
    10
    I've managed to have them work together with the help of the developer. Hooray!
     
  26. Reign_of_Light

    Reign_of_Light

    Joined:
    Oct 15, 2014
    Posts:
    38
    For what it's worth, I am also on Apple Silicon using Unity 2021.3.14f1 with URP (formerly LTS) and I do not have those issues. As with you, the NativeCode bundle linked above fixed the NullReference exception for me.

    But I'm just starting out. Let's see how far I get!
     
    Last edited: Dec 23, 2022
  27. khushalkhan

    khushalkhan

    Joined:
    Aug 6, 2016
    Posts:
    102
    @Wright any plan for adding addressables asset support to map magic 2 objects module?
     
  28. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    Possibly I will add support for reading terrain data that is not written afterwards - like reading height data for texturing and placing grass only (with no height modifications). Can't guarantee, but at least I will consider this option.

    Once spawned, objects don't have to be bound to some specific tile. You can spawn NPCs that will walk through all the land, for example. It should work with physics objects as well. The only limitation here might be if you move objects in editor (not playmode) - for example, if object will be moved to locked area it won't be changed or erased anymore.

    Yay! It will help others who stuck with the same problem if you could share some info on how you managed this.

    Honestly I was not aware of addressables until this moment, but it seems to be a useful package. I will think what I can do about that.
     
    khushalkhan likes this.
  29. JohnnyRobert

    JohnnyRobert

    Joined:
    Dec 8, 2022
    Posts:
    10
    My Unity project is now crashing everytime I click play @Wright and I have no idea what is the issue but it is Map Magic that is causing the crash according to the logs, I have sent you the logs in private if you'd be able to take a look at the issue it'd be great.

    Edit: I followed your suggestion of disabling the Native C++ Code and it does not crash anymore. If there is a better workaround this issue please let me know, for now this fix does the trick.
     
    Last edited: Dec 25, 2022
  30. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    You didn't specify your platform, but anyways - you can download native source code here and compile it yourself. I will appreciate if you could share compiled version here to help others who are using the same platform.
     
  31. JohnnyRobert

    JohnnyRobert

    Joined:
    Dec 8, 2022
    Posts:
    10
    Hey Denis! I did not specify it as I sent you the log in private and it displays the platform there but for (if) anyone wondering the platform is Mac Os.
     
  32. NestorVG

    NestorVG

    Joined:
    Feb 12, 2019
    Posts:
    22

    If NPCs or rigid bodies get into chunks in the draft mode they might get inside things with collisions, like buildings, trees, rocks, etc. They can also fall off the tile. Just letting them be is not a solution, if a player leaves a vehicle in one place, goes far away and comes back, the vehicle would have fallen through the ground when the tile is unloaded.
     
  33. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    Actually it won't - when tile is removed all of it's child objects are removed as well. So the car will be removed when you walk from it, and then spawned again at it's original location when you get back to the tile.

    But I understand your use case. You've got to make some scripts to make the changes persistent. First the object player interacts with should be unparented from tile - this way it makes it independent from tile it was spawned on. Then yes, this interactive object should be switched to kinematic if it has no terrain underneath. Then, there might be some difficulty on serializing these objects for saving the game. Possibly there are some other questions you'll need to solve with scripts - but the thing is that MM supports moving objects, it won't crash or display error, there are no strict requirements for objects positions.

    Have you tried compiling code?
     
  34. NestorVG

    NestorVG

    Joined:
    Feb 12, 2019
    Posts:
    22
    Humm, understood, right now I think I would be entering a more "feature request" field... In a future update, would it be possible to have a "mode" when generating the world at runtime, that would not delete the tile (and its objects) when unloaded so that it also doesn't have to reconstruct the "chunk" from scratch when these tiles that have already been generated? I think I might be able to manage the part dedicated to moving the rigid bodies from one tile to another, most likely using collision and trigger events in the tile itself.
     
  35. JohnnyRobert

    JohnnyRobert

    Joined:
    Dec 8, 2022
    Posts:
    10
    Hi Denis, I did manage to compile it for the latest Mac Os version (Ventura) as target. It's the first time I used Xcode to build anything (not a programmer) so I don't know if it was supposed to also output a unitypackage file, I've only got it to output the NativePlugins.bundle file but I've tested it and it seems to be working so far.

    If anyone else needs it this is the compiled output.
    If there are any issues with the file I will post an update here, if you guys have any issues with it you can do the same.

    Also Denis if you need any assistance with testing/building your packages for this platform I can help with that if necessary as much as I can.
     

    Attached Files:

    Wright likes this.
  36. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    I'm afraid this will create a huge performance impact, and will end up crashing because of insufficient memory. Each tile takes a significant amount of memory. It will be way more efficient to keep only the change in tiles than all tiles themselves.

    Thank you for making a build and sharing it! I really appreciate doing this, and pretty sure that will help other users!
     
    JohnnyRobert likes this.
  37. NestorVG

    NestorVG

    Joined:
    Feb 12, 2019
    Posts:
    22
    That's actually a pretty good idea, will that be part of a future update?
     
  38. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    Probably that won't be released as un update at all since it's more related with the world's serialization for game save/load, and greatly depends on the type of changes made. So there could not be a universal solution that fits all users. But I will think about the way to make the life easier at least by adding some functions and events to use with scripting.
     
  39. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    63
    does map magic have a internal function to return distance from one cell in a neighbor or further tile and the current cell point on the current tile?

    I see alot of functions for distance between just two tiles

    I feel like im overlooking something simple
     
  40. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    63
    iterating the grid will take longer on a larger terrain, theres no getting around that.
    The real solution I think is smaller terrains.
     
  41. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    It's not clear what exactly do you mean under cell and cell point - could you please describe your use case?
     
  42. alfredbaudisch

    alfredbaudisch

    Joined:
    Dec 13, 2010
    Posts:
    40
    Hi, I see in the FAQ there is a mention to grass not appearing in builds, but in my case, following your tutorial 2, I cannot see grass in the Editor either (neither in Standard nor URP, as I tried with the 2 RP). I didn't do anything differently from the tutorial.

    Is there any active issue? Unity 2022.2.0

    upload_2023-1-4_9-19-11.png

    UPDATE 1: if I put the intensity to like 800 or 2000, grass appear, but then everywhere, including the cliffs, etc.
     
    Last edited: Jan 4, 2023
    avidwriter likes this.
  43. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    Could you please send me the graph or attach it here? It might be a problem in compatibility with Unity Beta version, but I'd rather to look into it if not.
     
  44. alfredbaudisch

    alfredbaudisch

    Joined:
    Dec 13, 2010
    Posts:
    40
    Attached here!

    Version:
    upload_2023-1-4_12-24-51.png
     

    Attached Files:

  45. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    alfredbaudisch, maybe grass mask is so weak that it makes grass barely noticable:
    upload_2023-1-8_10-43-37.png

    However I'm using stable Unity version (2021.3.4), so maybe it's something with Unity Beta that makes it inisible.
     
  46. Erlend1

    Erlend1

    Joined:
    Dec 18, 2019
    Posts:
    20
    Hello, I have a few questions about generating grass with MM2.

    Do you have any advice on what I should do to use multiple grass/vegetation prefabs? It sort of works to use several grass output nodes, but I wonder if there's a better way. Another thing I'm trying is to use object/tree output, which doesn't seem appropriate as I need to generate tens of thousands of points, though it gives me a bit more flexibility (ex. to use Spread, Rarefy, Split).
    mm2-how-should-I-use-multiple-grass-prefabs2.jpg
    In the included screenshots, I use the mode Mesh Unlit and prefabs from NatureManufacture's Mountain Environment.

    Also, I was wondering whether it's possible to preserve the original colors of the grass prefab when generating with the grass output node? Various color tints appear to be added - like 'Healthy' and 'Dry'.

    Lastly, do you have any advice on how to do deal with 'floating' grass parts over uneven terrain? If the prefab consists of a single model, it's fine, but if it consists of multiple models over a small area, some of the outlying models tend to float above the ground.
    mm2-advice-for-grass-prefab-part-not-aligned-to-terrain.jpg
     
  47. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    Using multiple grass output nodes is the right way to place different types of grass or detail meshes. Objects and trees outputs have a different purpose, and I can't recommend using them for grass - mainly because of performance reasons.

    MM does not bring anything new to Unity's grass system - it just generates masks and creates prototypes, but still it's usual Unity grass/detail system under the hood. It uses dry and healthy color variation, and creates floating grass for billboards (and probably grass meshes in general). As far as I remember, disabling dry/healthy color could be done with setting these colors to white. And preventing floaing grass might be done with a texture where the grass grows from the middle bottom point only.
     
    Erlend1 likes this.
  48. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    63
    OK, I got it to work :
    nearly flawless current point to nearest water data map :

    upload_2023-1-10_1-25-26.png


    that only took me SIX MONTHS to figure out lol

    does not do well over 256 res FACT.
    but the water data renders out in under 4 minutes on 256
    just over one minute on 129 res

    for the whole planet!
     
  49. JohnnyRobert

    JohnnyRobert

    Joined:
    Dec 8, 2022
    Posts:
    10
    Are there any tutorials about how to procedurally generate caves and tunnels that connect to those caves ? I remember seeing some suggestions by Denis in one of his tutorials about caves but the tutorial wasn't focused on that subject in particular.
     
  50. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,167
    MM2 generates standard Unity terrain, which does not support caves or tunnels. MM1 could work with Voxeland, but it's a different asset and completely different terrain type.