Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

[RELEASED] MapMagic 2 - infinite procedural land generator

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

  1. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    upload_2021-7-28_14-15-9.png would be okay. A layered one would be fancier but we don't need that. I reckon people would want it, if only to tidy up their graphs.
     
  2. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,011
    Do you mean concurrent dictionary of lazy-initialized values? If so, it does - but if a thread is trying to read something that doesn't exist then it's definitely a problem. If you have experienced it in MM - better report on ideainformer when it happened. I guess I won't reproduce it, but at least will keep in mind. It should not occur, and healing it with concurrent dictionaries is still a hack, even though they made for this.

    Errr, what is it? Does it floors several splines at once? Why don't use several floor nodes?
     
    twobob likes this.
  3. ysundawa

    ysundawa

    Joined:
    Mar 2, 2020
    Posts:
    22
    Hello Dennis & team ...
    Thanks for the great asset :)

    I am not new to MM2, but after updating to latest Version 2.1.6, I got this weird error which I don't know where to start digging...
    • My Microsplat Node constantly become greyed like below image.
    • Re-creating the node solve the issue, BUT it won't last for long.
    • Once I run the game,
      • The node become greyed again, and the terrain by default use index 0 of Microsplat texture array
      • If graph is closed : There is no error in console
      • If graph is opened : an error said : Could not find a cell for inlet/outlet. Removing link.
    • Seems like Microsplat only recognized during Edit mode, and disappear in running mode
    • I am using Microsplat Ultimate Collection, as we know since ver 3.8.0, we don't download each module separately, could it be the case it's not recognized?

    upload_2021-7-29_11-25-3.png
     
    Last edited: Jul 29, 2021
  4. ysundawa

    ysundawa

    Joined:
    Mar 2, 2020
    Posts:
    22
    I found out there is one missing asmdef reference in MapMagic.Microsplat.
    What should be the correct reference here?

    Is it r related with the URP setup I have? because I am also using Microsplat URP 2020 support.
    Using 2020.3.f141 LTS.

    upload_2021-7-29_19-40-35.png
     
  5. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    Because it's just tidier. and fits the workflow. if other people don't want custom simplified controls. No worries.
    I'll shut up. In our case upload_2021-7-30_0-8-16.png suited the need so far.
     
  6. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
     
  7. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,011
    Sure, you can create your own generators to organize graphs. As an alternative solution you can use a function for that - it might be more convenient if you prefer graphs over code.

    Oh, here is Vegetation Studio Pro assembly link because of mistake. It's wrong, and MM will work without it. Thanks for pointing that out!

    Thanks for reporting this issue, I will look into it. I will need a graph saved with a grayed out node. I suggest discussing it on ideainformer. Could you please report it here and link the graph?
    It's a special page to report both ideas and issues. Helps to keep things organized, that result in some pluses:
    - You will be able to track your issue/idea and know when it's fixed;
    - This ticket can also provide a communication channel dedicated to this issue;
    - Other users can also see if the issue/idea was reported, add some comments on it or clarify details.
    - And for me it's way more convenient to track issues in tickets, and discuss them per-ticket rather than use email or forum

    If you have a graph and a scene with the reproducible issue it would be great if you could link them in issue description. I will need a scene, a graph, sub-graphs if you are using biomes, and their meta-files. There's no need to send models or other assets. I will appreciate if you don't compile the unity package with the dependencies.
     
  8. ysundawa

    ysundawa

    Joined:
    Mar 2, 2020
    Posts:
    22
    OK Dennis, ...
    I will post it there.
    Thanks for replying.
     
  9. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    95
    I had been waiting to see if you had been able to improve the spline system for creating rivers and such, were you able to accomplish this recently? I have map mapgic 2. I would love to add some splines for lower terrain so that i can add some occasional rivers
     
    Last edited: Aug 2, 2021
  10. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,011
    Unfortunately can't boast with a progress here. Maybe I will add generator creating splines downhill in 2.1.8. For 2.1.7 I've made a combine generator, but it seems to be the only feature for splines added in this version (and still it's rather minor).
     
    rillani and twobob like this.
  11. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    95
    thanks for the reply, ill check back in the future. Thanks for your asset it has been a life saver
     
  12. rillani

    rillani

    Joined:
    Dec 16, 2020
    Posts:
    5
    A downhill spline would be very nice!
     
  13. Artini

    Artini

    Joined:
    Jan 29, 2016
    Posts:
    84
    Sorry, but I could not find it in the documentation.
    How do I save MapMagic2 as a regular terrain?
    Besides, there are some changes in the interface not covered in videos.
    Save Terrain Data and Save As Copy do nothing.
     
  14. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    Hi. If you mean How do I export the heightmaps. Then there is a built in tool in the unity editor.

    If you mean "How do just make a pinned terrain that kinda acts like a regular one" then use Pin.

    If you mean. How do I export the final terrain into a completely new container that doesn't reference mapMagic in anyway, I think you are out of luck. You can probably export the various textures and maps and other bits and reconstruct it? but I don't see a "Remove mapMagic and just make it a normal terrain" code anywhere.
     
  15. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    I SUGGEST: a Discord Subchannel called. SCRIPTS
    http://mm2.idea.informer.com/proj/MM2?ia=136963

    UG: Man make thing people keep asking for. I could have made this better. or more complex. or even not assigned a New TransitionList and the keep Adding() to it (don't do this, size it first - the TOTAL is right there)

    But I wanted people to make it better and how they want it. (select the FIrst N? Last N? random sampling?) so the balls gets rolling

    upload_2021-8-5_15-50-18.png
    This does First /n/ to total of Src.


    EDIT: ATTACHED RIGHT FILE. Doh!
     

    Attached Files:

    Last edited: Aug 7, 2021
    MaximilianPs likes this.
  16. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    Hello there, I need to set a specific texture based on spawned object.

    I'm using Spread to spawn some town, but I need to change the texture all around that areas :\
    upload_2021-8-5_22-36-3.png
    upload_2021-8-5_22-31-41.png
     
    twobob likes this.
  17. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    Perhaps you can use Stamp
     
    MaximilianPs likes this.
  18. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    Unfortunately I can't use just a texture with alpha-maps 'cause Texture object indeed want's a Terrain layer, and it's 100% squared, so maybe someone know hot can I blend it?

    upload_2021-8-6_10-39-30.png

    upload_2021-8-6_10-40-2.png

    Maybe I could mask the texture, but I should serialize the value from Random object, and the size from the Flatten, and set the mask with a Simple Form and set the respective value... sounds a mess!!! :confused:

    [EDIT]
    Nevermind I find the solution :D

    upload_2021-8-6_13-45-28.png
     
    Last edited: Aug 6, 2021
  19. PlayerDev

    PlayerDev

    Joined:
    Mar 15, 2017
    Posts:
    8
    Hi,

    So I just installed map magic 2, it's great and easy to use... so much easier than other terrain assets. Took me just 30 min to generate a decent terrain.

    But I want to generate random terrains at runtime, ie every time the player starts a new game, it generates a random terrain according to certain settings.

    How would I do that with map magic at run time, is it possible? What's the workflow?
     
    MaximilianPs likes this.
  20. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    Basically MM2 is not designed to randomize all objects at runtime, and you'll have to code a bit and find a workaround by yourself.

    I haven't worked on it yet, but I have a plan ;-)
    1) Serialize (make public) all Seeds that you want to randomize.
    2) Make a prefab with your terrain/MM2 object, the idea is to keep all Tile x,x objects disabled in this scene.
    so in the MainMenu scene, or any pre-InGame scene, you will access to the variables, and set all the seeds that you need, randomly or not.
    3) On the InGame scene, you will enable all your tile, and regenerate the terrain by using

    Code (CSharp):
    1. // Randomize the terrain on start
    2.         MMObject.graph.random = new Den.Tools.Noise(Random.Range(1, 99999), permutationCount: 32768);   //32768 is initial permutation number for MM noise. For compatibility with seed 12345
    At least that's what I have understand :oops::D
     
  21. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,011
    Save Terrain Data and Save As Copy activate the tile selection tool, same as all of the other buttons from the menu. It will highlight already existing terrain with a green frame. Clicking it will make the file save dialog to appear, where you can set the file name to store this terrain as a terrain data. Then you can use the saved data as a regular terrain.

    Sure, I've added the the #scripts channel, feel free to ask scripting questions to community and share your custom nodes.

    There is a concept of per-tile basis generate, and there is a concept of tile independence. MM1 was per-tile, and I've received tons of feedback like "I've changed the tile size and all my generate results become absolutely different and ugly". MM2 is less bound to the tile size, but still I had some emails about the Import node scale. Surprisingly, users can ask for diametrically opposite things. Some ask for per-tile basis generators, some don't understand this approach. How to find out where to move? Maybe voting on ideainformer?

    It looks like Stroke is a node you are looking for.

    You can change the seed at starting a game on executing this line in Start/Awake/OnEnable:
    Code (CSharp):
    1. mapMagic.graph.random = new Noise(seed, permutationCount:32768);
    2. //32768 is a default value MM currently using for compatibility purpose
    Keep no tiles pinned (otherwise they won't connect with new tiles with new seed).
    This script is changing your graph (seed value) every start, this value is stored in graph asset.
    Make sure that 'MapMagic' and 'Den.Tools' namespaces are used.
    Here is the example script: https://www.dropbox.com/s/qb7u9wqn8mh6ig8/NewSeedOnStartup.cs?dl=0
     
    twobob and MaximilianPs like this.
  22. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    Also keep in mind that you can't recalculate texture at runtime!
    So if you change any terrain height for some reason, it will not update textures (from grass to rocks, for example) :confused:
     
  23. PlayerDev

    PlayerDev

    Joined:
    Mar 15, 2017
    Posts:
    8
    Thanks for the answers. So if I understand correctly, it's possible to generate a terrain at runtime with a different topology(noise) by having a different seed every time, but it's not possible to generate its textures, grass and trees?
     
  24. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,011
    Changing the seed will affect not only heightmap, but textures, grass and trees as well. It will completely generate the new land.

    I guess MaximilianPs means that you cannot change the seed once the terrain is generated, or while it's being generated. That is true, you've got to assign seed value before actual generate starts, that's why it's better do in Start, Awake or OnEnable.
     
    MaximilianPs, twobob and PlayerDev like this.
  25. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    Exactly :)

    With or Without the "Within Tile" option, the roads won't pass from one tile to another :(
    upload_2021-8-9_18-38-18.png


    Dungeon Architect in his graph have a very useful menu where you can select different objects that are present on the graph.

    You could do something like this for groups or some important node, like Height, or Textures.
    Or adding a TextInput where we can type the node that we are looking for, each time you press [Enter] key will cycle each requested node and will get focused.....
    Ok, I really need something to find nodes on graph 'cause my Graph is becoming a real mess and debugging when something goes wrong is getting more and more complicated :confused::oops:


    ... About advice, would be nice to have a tools to spawn objects on the side of the spline, and also where the roads/spline make a X or T cross ;-)

    -- About Align roads with the town...
    upload_2021-8-9_19-34-22.png

    I have an idea but I need you help.
    When I set the Town's points, would be nice to have an option to set split points in 2.
    upload_2021-8-9_19-38-24.png
     
    Last edited: Aug 9, 2021
  26. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    I pointed out that he can pass positions via the POSITIONS node
     
    MaximilianPs likes this.
  27. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    This is a 2x2 tiles map.
    @Wright you have to fix it, or spline will result useless!

    upload_2021-8-9_21-13-22.png
     
    Last edited: Aug 9, 2021
  28. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    Yeah there are certainly currently "unhandled complications" when it comes to pan-tile road making.

    I for one would welcome any input from the community on how they solved this problem in the past?

    Many thanks
     
    MaximilianPs likes this.
  29. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,011
    When generating each of the tiles, Interlink connects objects on this tile, but it is not aware of objects on the neighbour tiles. Each tile is individual and independent from the others - this is a main requirement to create infinite terrain. However there is still a way. Random node create objects only on this tile. Scatter node create objects within margins - this way it can place objects on the other tiles. So use the Scatter node instead of random, increase Additional Margins, and try not to affect scattered objects too much. Quite limiting, but gives you a way to connect objects from different tiles.
     
    MaximilianPs and twobob like this.
  30. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    @Wright

    I was thinking about MM2 Brush, but I ask before to purchase it, 'cause I'm bored to waste money and it's even cheap, so....
    could I paint roads all around the city, so it will be connected to spline for sure.
    could be possible to spawn a brushed terrain on the Spread's points? :D

    Anyway this is made with SCATTER...
    upload_2021-8-10_15-5-23.png
     
    Last edited: Aug 10, 2021
  31. montyjack

    montyjack

    Joined:
    Jan 10, 2014
    Posts:
    34
    Hi- having an odd problem that matrix assets aren't saving properly. Each time I exit unity and re-open it, all of my matrix assets have switched from texture to RAW and are blank, causing a bunch of errors when I try to run my game. I can re-set them to textures, and that will temporarily fix the issue, but it reoccurs the next time I close the editor.

    Also, I'm noticing massive memory usage, on the scale of about 5-6GB for a 3x3 terrain grid. Is that to be expected?
     
  32. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,011
    Version 2.1.7 is now available at the Asset Store:
    New features:
    - Combine splines node. Unites several spline systems in one, no welding or cuttings intersections.
    - Random node now has a mask input. Determines the probability of spawning objects in some areas, while trying to maintain the same objects count defined in Density
    - Number of objects per iteration variable exposed in Objects output. Decreasing it will make the game smoother, increasing will give faster overall apply.
    Bug fixes:
    - Direct Matrices/Textures disconnect when zooming out fix
    - Clamping Whittaker inputs to 0-1 range
    - Unnecessary assembles removed from compatibility asmdef list
    - Infinite loop protection on Whittaker sub-biome
    - Create graph button on new MapMagic object fix

    If you mean will it paint a road between terrains - it will, it works not per-tile, but per-stamp. And stamp reads data from multiple terrains.
    However I don't get it what do you mean under spawn. Stamp whole set of what you sculpted before? No, Brush is not about that.

    Looks like you are moving or deleting scattered objects after. This could be done for the tile objects, but will not affect objects on neighbour tiles, so they left where they are. And it tries to build a road to them.

    Actually this splines welding issue is the main thing that splines are still not fully released yet. Splines could not be welded perfectly. Unlike maps and objects, splines really require to get access to neighbour tiles. Providing this information will make them depend on tile generate order - and this will ruin all of the deterministic approach.

    I could not reproduce this issue at first glance. I create Import Map, switch it to Texture, assign texture, close Unity, open it again - and still can see imported texture. So I'd like to clarify how exactly you are saving it. Could you please report this issue to ideainformer?
     
    twobob likes this.
  33. montyjack

    montyjack

    Joined:
    Jan 10, 2014
    Posts:
    34
    I'm unable to save it
    I'm unable to save a bug report for some reason - but anyway, if I create a matrix asset, at any time, anywhere and set it to a texture, the next time I open the editor, the asset is there, but it's blank and set to RAW. No errors are generated in the console or in the Unity Editor Logs.
     
  34. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    I was thinking about painting terrain (making a sort of Stamp) for terrain and textures, drawing a circular road all around the town, so when the spline-road will be generated would be connected to the Brush painted road. ... got it?
    But to do that, I need that what I paint with brush get spawned on the same position chosen by Scatterer (or Random) node.

    --
    would be very nice to have a Lock option for Group(s), so when I lock it, it will become unmovable, 'cause terrible things happen when you accidentally move it over another group. ;-)

    ... Also, do we have an option to use Stamp textures?
    I mean something like that to adjust terrain height.
     
    Last edited: Aug 11, 2021
  35. focuslabstudios

    focuslabstudios

    Joined:
    Feb 23, 2018
    Posts:
    20
    Hi, when I update Vegetation Studio Pro to 1.4.5 I get errors indicating it cannot find the namespace of the package.



    Assets\MapMagic\Compatibility\VegetationStudio\Runtime\VSProMapsOut.cs(17,7): error CS0246: The type or namespace name 'AwesomeTechnologies' could not be found (are you missing a using directive or an assembly reference?)



    I'm using the latest MapMagic version
     
  36. montyjack

    montyjack

    Joined:
    Jan 10, 2014
    Posts:
    34
    Have another odd issue - I've got a second camera that renders everything in wireframe using Camera.SetReplacementShader()- for some reason this works fine with normal unity terrain, or with TerrainComposer, but not with MapMagic. I had thought maybe the shader you were using didn't have the RenderType=Opaque tag, but it appears you're using a standard unity shader that does have that tag set. Any idea why the terrain would not work with a replacement shader when everything else does?
     
  37. montyjack

    montyjack

    Joined:
    Jan 10, 2014
    Posts:
    34
    Been looking more into this - the issue seems to be it's impossible to render mapmagic terrains with replacement shaders on the camera - although in theory it should be possible since Mapmagic supports Microsplat, which is itself a replacement shader system?

    Is there any way to do this, or is there a way to create a standard terrain that mimics the geometry of my mapmagic terrain? I really need this as it's an integral part of the game I'm writing. Thanks.
     
  38. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    What I'm doing wrong? from 20 to 768 and those won't be welded :confused:

    upload_2021-8-12_11-51-7.png
     
  39. montyjack

    montyjack

    Joined:
    Jan 10, 2014
    Posts:
    34
    This gets even weirder - when a mapmagic tile is created, any terrain object created before becomes invisible when rendered with a replacement shader, however, terrain objects created AFTER the mapmagic tile are perfectly visible in a camera using a replacement shader. So apparently when a mapmagic tile is created it does something that messes with unity's replacement shader system. I don't know the inner workings of MapMagic, but I do like the results. I have some ideas for workarounds but is there any way to just get the mapmagic terrain objects to show up in a camera using a replacement shader?
     
    twobob likes this.
  40. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    262
    @Wright I know it's a beta, but we have to chat a bit about this....
    upload_2021-8-12_20-56-28.png

    As you can see the spline looks perfect on top view in isometric... but!
    upload_2021-8-12_20-57-30.png
    as you can see it's broken, this happens often, and also the cube is scaled by 50 units on Y.
    So I guess, if X and Z position are inside 2 or less units distance should be blended and gently adapted.
    I guess them could be welded at half way.
    This would fix a bunch of issue with roads.
    Also!
    I guess we need a sort of mask or in pathfinding a way to set also a minimum height, or you risk to have roads on the sea, like here
    upload_2021-8-12_21-0-48.png
     
  41. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,011
    Note that imported map is a usual asset - you've got to perform scene or project save to keep changes. Unity does project save on exit, but it could be skipped for some reason - for example, when Unity crashed.

    Could you please report this issue and height mask idea at ideainformer? I can't promise I will fix it soon, but at least it;s better have it in a backlog.

    The only thing that differ MM terrain rendering from the standard one - is that MM is using instancing by default. Try disabling it in MM object - Terrain Properties - Draw Instanced.

    Yes, seems that the classes names has been changed in VS Pro. Try using the older version if possible. I will look into fixing this for the next version.

    EDIT: add VSP_PACKAGES to Edit - Project Settings - Player - Scripting Define Symbols.
     
    Last edited: Aug 12, 2021
  42. montyjack

    montyjack

    Joined:
    Jan 10, 2014
    Posts:
    34
    That did it with the terrain! Thanks! Tried saving the scene - one of the assets is working, but none of the others.. I suspect I have to hit the reload button to get it to stick.
     
  43. focuslabstudios

    focuslabstudios

    Joined:
    Feb 23, 2018
    Posts:
    20
    I tried adding VSP_PACKAGES but it did not find the namespace.

    EDIT:
    Managed to fix it by changing one of the imports in VSProMapsOut.cs from
    Code (csharp):
    1. VSP_PACKAGES.VegetationSystem
    to
    Code (csharp):
    1. AwesomeTechnologies.VegetationSystem
    And adding VSP_PACKAGES to Edit - Project Settings - Player - Scripting Define Symbols. (like Denis said)
     
    Last edited: Aug 13, 2021
    twobob likes this.
  44. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    Also it would be good to mention the workflow. He has to support HDRP URP built-i and w/e so ... I assume you mean with "built-in"
     
  45. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    upload_2021-8-13_12-16-1.png

    In "big view" I get this. Note the MAP type node.

    but in "little view" I get:

    upload_2021-8-13_12-17-8.png

    All the node reorder and the blue one now disappears?

    Any chance of some notes on /what/ you did to fix this on your custom controls please in the 1.4.7 release?
    Would like to understand how to fix my own issues
     
    Last edited: Aug 14, 2021
  46. montyjack

    montyjack

    Joined:
    Jan 10, 2014
    Posts:
    34
    Yes, built-in. Turns out the issue was I had to uncheck the instanced terrain option.
     
    twobob likes this.
  47. zero1024

    zero1024

    Joined:
    Oct 10, 2018
    Posts:
    11
    Hi, I'm trying to access an exposed value via script but "mmObject.graph.defaults" mentioned in the Wiki doesn't exist.

    The value is properly exposed in the Graph, because I see it in the "Exposed Values" and "Debug.Log(mapMagic.graph.exposed.entries[0].guiName);" in my script actually prints the name.

    But I can't find a way to set or even read the value via script.

    Thank you for the help
     
  48. macube

    macube

    Joined:
    Jul 16, 2017
    Posts:
    19
    Hi,
    i get this error message on Unity 2021.2.0b4 when i open the map magic 2 graph:

    Den.Tools.EditorHacks.SetIconForObject (UnityEngine.Object obj, UnityEngine.Texture2D icon) (at Assets/MapMagic/Tools/Editor/EditorHacks.cs:19)

    i use the latest map magic 2 version..
     
  49. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
  50. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,956
    Hmm thats odd - that refers to an old unity workaround afaik https://forum.unity.com/threads/editor-script-to-set-icons-impossible.187975/#post-7175725. Perhaps the objects package is not installed properly? I dont know tbh
     
unityunity