Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Map Magic World Generator - a node based procedural and infinite game map tool

Discussion in 'Assets and Asset Store' started by Wright, Mar 10, 2016.

  1. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    30
    Hello, im trying to do a road system for mapmagic getting points positions from the new navmesh runtime component, but I dont have idea how put those vector 3 positions to a mapmagic node to them use those vector 3 variables with the Blob node to use it like a mask to paint the terrain. Any one here can help me?
     
  2. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    Yes. Each of the nodes will have it's own preview, showing the color heightmap with the relief shading to make the map readable intuitively (however classic grayscale mode available too). All of the node changes will be displayed at the node's preview:
    Preview3.png
    Two buttons at the bottom will apply preview to terrain and open in a new window. BTW on terrain it looks the same:
    Preview4.jpg

    This video should work. VS node had not changes since time it was recorded - except the Prefab slot. This slot has special use cases, but for beginning it could be disregarded.

    Try using the custom generator. Probably Single or Center are the closest to one you're going to make. However be careful not to create an infinite loop - you are trying to create Vector3 array based on heightmap and change the heightmap to apply this array.
     
  3. bok

    bok

    Joined:
    Feb 24, 2014
    Posts:
    35
    Awesome, can't wait for MM2!!
     
  4. Diego_Graphics

    Diego_Graphics

    Joined:
    Nov 3, 2014
    Posts:
    90

    This looks very promising. i'm really looking forward to map magic 2. i've mentioned it before: if i get into the air with a hot-air baloon or an airplane or whatever, i'd have to see a less and less detailed map but much further. is there anything planned for mm2 ?
     
  5. mmaclaurin

    mmaclaurin

    Joined:
    Dec 18, 2016
    Posts:
    211
    Will MM2 have performance enhancements on iOS? Thinking of erosion but could be others.
     
  6. bok

    bok

    Joined:
    Feb 24, 2014
    Posts:
    35
    How do you guys make sure that objects don't collide? For instance if I want to have trees spawning at random and at the same time I want rocks spawning at random, is there a way to make sure that they don't spawn at the same spot? I'm also curious if this is possible when using the Propagate node.
     
  7. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    definitely bok. You can use blob to create an area around any object output and use that as a mask for other objects. I place all my big stuff first continually adding to the off-limits mask as I add more and more.
     
    bok likes this.
  8. bok

    bok

    Joined:
    Feb 24, 2014
    Posts:
    35
    Thanks for the help malkere! Every time when I think that I now know every node I discover a new one haha. Never used that blob node but it seems to be extremely powerful.
     
    malkere and camta005 like this.
  9. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    Subtract node is what you're looking for. And yes, it should be placed after the propagate or other nodes that create or move objects.

    Not on iOS, unfortunately. At least yet. I'm using C++ code for Windows and Mac, and the main reason is editor performance. Erosion works 3-4 times faster in build than in editor, and it does not even depend on scripting back-end much. So the main problem is to make it work fast in editor, and that's why I'm using C++ for that.

    MM2 will have a terrain "Preview LOD" - a low-resolution terrain that will be generated way faster to be displayed at far distance. As well as for the editor preview.
     
    bok, Diego_Graphics and camta005 like this.
  10. Diego_Graphics

    Diego_Graphics

    Joined:
    Nov 3, 2014
    Posts:
    90
    i cant await mm2, it will be like christmas and easter at the same time! another question. which custom shader (RTP, Megasplat or CTS) can display tesselation in connection with map magic without any problems? i would like to increase the level of detail by tesselation but don't know which custom shader i should buy best here.
     
  11. Abystral

    Abystral

    Joined:
    Sep 20, 2017
    Posts:
    2
    I'm curious. Will MM2.x use the new terrain system in 2018.3?
     
  12. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    I'm sure it will. The new terrain system is mostly just upgrades to the current system, it shouldn't require a rewriting of the code that interacts with it, besides maybe some of the automatic neighboring stuff.
     
  13. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    That's right. The main thing that's changed is the Layers system instead of splatmaps. I've recently updated MM, so current version works fine with 2018.3 terrain layers. Other stuff like brush performance or per-pixel normals is great, and happily it will work with no effort on my side :)

    I'm afraid any of them work only on the pinned terrains. However I also wonder if any of MM users could make them work in infinite mode.
     
    malkere and trilobyteme like this.
  14. Diego_Graphics

    Diego_Graphics

    Joined:
    Nov 3, 2014
    Posts:
    90
    @Wright Oh sad to hear that. especially on rocky slopes and cliffs tessellation would help immensely to enhance the effect of the terrain. but thanks for the info.
     
  15. shedworksdigital

    shedworksdigital

    Joined:
    Nov 7, 2016
    Posts:
    40
    I needed more control over the streaming than the Generate Infinite Terrain toggle gave me, so I've left it false and I'm streaming new chunks using MapMagic.instance.chunks.Create and MapMagic.instance.chunks.Remove. Is this a good way of doing it? It's mostly working fine, except for one problem. I'm subscribing to the OnApplyCompleted event, and occasionally I get an exception inside my callback:

    MissingReferenceException: The object of type 'Terrain' has been destroyed but you are still trying to access it.

    The chunks that I get this error on totally fail to appear. There are plenty of disabled terrain objects hanging around to be reused, so it looks like a problem with the terrain pooling system. Is this problem because I'm using Chunks.Create?

    upload_2018-10-23_11-43-52.png
     
    malkere likes this.
  16. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    I'd love to hear more about that @shedworksdigital Are you initiating terrain placement manually in runtime using that?
     
  17. Nihilus0

    Nihilus0

    Joined:
    Jan 25, 2017
    Posts:
    52
    In my case, if the MapMagic folder is open in the hierarchy, this has happened when a terrain creation or destruction has occurred.
     
    Last edited: Oct 24, 2018
  18. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    As far as I can see it's MapMagicTerrainContainer that gives this error. There's no such script in MapMagic, so I suppose it's your script. Try checking if the terrain is null before using it.

    BTW If you are using Create and Remove then you are actually not using the terrain pool, no matter if you are creating them with the pool script. It is supposed to use ```Deploy (CoordRect createRect, CoordRect removeRect, object parent=null, bool allowMove=true)``` instead. This will create all the terrains needed within createRect, and remove all that are not within removeRect (obviously, it should be bigger than createRect). I suppose you don't want to use the pool, and just want to create and remove the terrains, so set allowMove to false.
     
    malkere likes this.
  19. bok

    bok

    Joined:
    Feb 24, 2014
    Posts:
    35
    Thank you for the help! So if I have 5 different rocks and want to subtract 20 different plants so that they don't collide with the rocks, do I have to create a 5 x 20 subtract nodes? Or am I overthinking something?
     
  20. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    416
    I think you can use the Combine Node to combine all plant outputs first:
    https://gitlab.com/denispahunov/mapmagic/wikis/object_generators/Combine
     
    bok likes this.
  21. shedworksdigital

    shedworksdigital

    Joined:
    Nov 7, 2016
    Posts:
    40
    I tracked the problem down and it wasn't to do with pooling. I wasn't being careful enough about waiting until a chunk is loaded before removing it so it was possible for me to destroy a chunk before it had actually finished generating, causing the Terrain object passed into OnApplyCompleted to be in a semi-destroyed state.
     
    malkere likes this.
  22. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    Manual control over chunk deployment is working well =D
    I did have some problems where it won't let me turn off both generateAroundCamera and generateAroundObject. So I set it to generate around main camera, but then it also seems to still make use of the generate and enable ranges even though I have infinite generation turned off. I just turned it up to 5000 and it works. I'm just running a static camera for now so it didn't matter. Having control over on/off it shouldn't matter if I were moving either.

    I've got it so that I can adjust sliders in a UI in my start menu to define variables on my generators like noise size, scatter density, etc. I added a public string name; to my noise and scatter nodes so I can iterate through them and apply any changes at the start of entering a world. I'm using the above to generate a preview of the world at 1/16th the scale before you go into it =D Lot's of fun!
     
    blacksun666 likes this.
  23. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    I seem to have broken my trees somehow... I only added two lines to my scatter generators, a public string name = "Unnamed"; and layout.Field(ref name, "Name"); I use version control, so there's nothing else changed in there.

    Now it seems that my scatter isn't working on the majority of my terrains....???
    Untitled.jpg
    The density is supposed to be 15, but there are 0 scatter hits on terrains except for X0Z-1
    Untitled2.jpg
    Even if I turn the density up to 80 there are 0 hits. At 81, I get 1 hit on each of the other terrains.
    Untitled3.jpg
    At 15, trees only seems to be spawning in 1/4 directions, except for that terrain in the left...??

    updating: if I change the seed to anything other than 12345 suddenly there are trees everywhere. Way more than there used to be with density 15, to the point of covering all terrains...??? If I go back to 12345 it goes back to zero trees on most terrains...??? But my current version live on Steam using density 15, seed 12345, is just right...? Very strange.
     
    Last edited: Oct 26, 2018
  24. shedworksdigital

    shedworksdigital

    Joined:
    Nov 7, 2016
    Posts:
    40
    I would love to be able to do a 5000 units per chunk low res version of my map, to be used for rendering very far away terrain at a low detail level. What would be the best way to go about this? I know that distances in the generators are measured in map resolution, so increasing the terrain size will just stretch the world. Is there an easy way to add a scale matrix or something to the generators to compensate?
     
  25. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    I guess all 20 plant types have a single (or a few) ancestor node, and then they are split and randomized. So it's better using Subtract node before it. Or, as iddqd said, you can combine all objects before subtracting.

    ```public string name``` hides base the generator value. If you are using VS or Rider it should warn you about it. It should not ruin everything, but it's better to avoid hiding values.
    So this is related with the generator seed? Anyways I'm using a new random for MM2, and Scatter here supports less than 1 object per terrain (it will not spawn on some chunks). In current version it's better use the Cell scatter mode, it gives more predictable results.

    The best way to do it is to join beta :) MM2 is resolution-independent, so the generated result is always the same in world units no matter of chunk size or resolution. If you have a mountain at some position it will always be here no matter what size/resolution values you set.
     
    bok likes this.
  26. sparkwd

    sparkwd

    Joined:
    Aug 12, 2018
    Posts:
    12
    Hey Denis,

    I think I might have come across a MegaSplat glitch in MapMagic. Nothing major, I just wanted to bring it to your attention.

    Aside form this, everything else with MegaSplat integration has been working smoothly. When I go to the Output of any node and click Preview > On Terrain I get a yellow overlay (pictured below) instead of the gradual green > red overlay expected.




    If I go to the Inspector of MapMagic and change the Material Type to Built in Standard it goes back to working as expected.



    Changing Material Type to Built in Standard renders Preview > On Terrain for nodes like the green > red overlay as expected:



    After I’m done testing with how the preview looks on the terrain, to render the MegaSplat materials again, I need to re-enable Custom for Material Type.



    Not a big deal, I just wanted to let you know. By the way, there are no console errors that appear during this.
     
    Wright likes this.
  27. Poxican

    Poxican

    Joined:
    Oct 17, 2012
    Posts:
    37
    Hi @Wright ,

    I updated to Unity 2018.3.0b7, and the latest MapMagic, and I'm experiencing an error I've not seen before.

    With 'Generate Infinite Terrain' enabled, a number of errors and warnings appear in the console, as attached.

    - If I disable MapMagic completely and run the game, the errors do not appear
    - With MapMagic enabled, Generate Infinite Terrain disabled, and any number of terrain chunks pinned (I've tested up to 100), when I run the game there are no errors or warnings
    - With MapMagic enabled and Generate Infinite Terrain enabled, when I run the game the terrain chunks start to appear, and the warnings and errors begin appearing in the console
    - If I start the game with MapMagic enabled, but Generate Infinite Terrain disabled, there are errors. If I then enabled GIT while the game is running, the errors and warnings begin.

    I haven't been able to find any useful information on these errors or warnings at all.

    Are you able to shed any light on this?
     

    Attached Files:

  28. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    691
    Can anyone recommend a link to or a set of steps to have object spawning work within Vegetation Studio while also using MM? VS works perfectly for my needs but now I only get the ground cover and not the associated spawning objects. I use this method for spawning trees that can be individually cut down.
     
  29. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    691
    Is there a way to create masks dynamically that prevent MM from generating a prefab? As mentioned earlier, I am trying to allow trees to be cut down. Currently, when a player cuts down a tree, I generate a mask in Vegetation Studio which prevents the tree from spawning again until the mask goes away (after a period of time.) How would you go about doing this in MM?
     
  30. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    You could setup a custom generator to check your tree database to see if it should or should not be spawned before sending it to VS. The generators are all just scripts. You can intercept their logic with a check so long as it's thread safe. With VS trees for harvesting you only need to make use of the VS OnCreateCollider (or something like that) callback to AddComponent the appropriate script to the collider that VS spawns.
     
    Wright likes this.
  31. shedworksdigital

    shedworksdigital

    Joined:
    Nov 7, 2016
    Posts:
    40
    That sounds perfect! How do I join? Also, will a MM1 graph work in MM2?
     
  32. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    691
    I cannot get VS to spawn prefabs like it normally does. Any ideas as to why?

    **EDIT** Just noticed MM spawns a VS object per map. Did not realize that, doh! Does anyone know how to use VS prefabs with MM?
     
  33. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    Does this happens in a clear project? As far as I can see from those errors it could be hardly related with MM since it does not use neither vertex buffer nor jobs. I've tested MM with Unity 2018.3 (don't remember the beta version), and it seemed to be working fine. Are you sure it isn't caused by the other code?
    However I suppose the first two could be related with a terrain which is not ideal in beta yet.

    Email me your order number and I will provide an access to GitLab repository.
    I will make a tool to update the old graph, but the generate results will not be absolutely the same, since core algorithms have changed.

    If spawning VS objects works as expected you don't need to use the prefab slot.
     
  34. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    691
    It only works with the prefab method and those are not working when using MM.
     
  35. MarceloASG

    MarceloASG

    Joined:
    Jun 15, 2017
    Posts:
    23
    Last edited: Oct 30, 2018
  36. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    Probably I've got it all wrong - could you please describe your use case, clarify what exactly you are going to do?

    When scattering the initial village "centers" objects use a height map (with contrast enhanced by curve) as a probability mask. This way you will prohibit objects spawning below some particular height - in your case it should be a water level. This image use tree model to show the object, but the graph logic is the same:
    ObjectsByHeight1.jpg
     
    MarceloASG likes this.
  37. shedworksdigital

    shedworksdigital

    Joined:
    Nov 7, 2016
    Posts:
    40
    Where can I find your email?
     
  38. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    shedworksdigital likes this.
  39. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    691
    I have VS setup to add prefab trees whenever it comes across a grass object it also generates (this is part of the prefab spawning capability of VS.) When I add VS to MM, it shows the grass settings but I do not see the prefab spawn options which are visible within VS itself. Its as if MM is ignoring them completely. I use the system to spawn trees, rocks, and other things which the player can "farm".

    Make sense?
     
  40. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    691
    Is there a way to limit biomes to the X or Y position of the map? For example, I want snow areas to appear further North than say desert areas. The biomes should be based on where you are in the "global" space. Make sense?
     
    p_hergott likes this.
  41. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    Is this prefab displayed when you select the vegetation package (asset file) itself in Vegetation Items section?

    This is exactly the way I'm blending biomes in this video. I'm using gradients (mixed with noise a bit to avoid straight borders) to place both snow and desert areas.
     
  42. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    VS Pro was released today. Looks like the MM output Vegetation Studio does not recognize it.
     
  43. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    691
    Any chance you can share the MM settings and code path for that? I'd like to copy it and work from it. Thanks!
     
    Diego_Graphics likes this.
  44. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    Sure, it's the different asset.

    The badlands and snow biome graphs could be found at the community graphs page. The forest biome is included in demo. I don't know if the main graph remained somewhere, but if it does I will upload it to community graphs too.
     
    camta005 likes this.
  45. Poxican

    Poxican

    Joined:
    Oct 17, 2012
    Posts:
    37
    @Wright You're right, this eventually turned out to be an obscure culling mask issue on a directional light in the scene. It's somehow related to the terrain, but the issue was not on the MapMagic side of things :)

    One other question I haven't seen asked yet, sorry if I missed it:
    2018.3 features the new Draw Instanced option for terrain, as explained here. That sounds like it should bring significant performance improvements. Is this compatible with MapMagic, and is there a way I can make use of it in MM 1.9.3? Thanks
     
    Last edited: Nov 3, 2018
  46. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    691
    I meant the final project that has the blending and all other things in the video. It would be awesome if you would include several projects such as that in the package.
     
  47. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    Yet on pinned terrains. I will expose this setting for infinite ones with next update, probably on 2018.3 release.

    Yes, I got it. I will search for the main biome graph and upload it if find anything.
     
    mmaclaurin and malkere like this.
  48. Nitrox32

    Nitrox32

    Joined:
    May 9, 2017
    Posts:
    95
    What is this error and why am I getting it?

    MissingReferenceException: The object of type 'Terrain' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    MapMagic.SplatOutput+<Apply>c__Iterator2.MoveNext () (at Assets/MapMagic/Generators/OutputGenerators.cs:552)
    MapMagic.GeneratorsAsset+<Apply>c__Iterator1.MoveNext () (at Assets/MapMagic/Main/GeneratorsAsset.cs:565)
    MapMagic.Chunk+<ApplyRoutine>c__Iterator0.MoveNext () (at Assets/MapMagic/Main/Chunk.cs:242)
    MapMagic.ThreadWorker.CoroutineFn () (at Assets/MapMagic/Main/ThreadWorker.cs:604)
    MapMagic.ThreadWorker.UpdateApply () (at Assets/MapMagic/Main/ThreadWorker.cs:224)
    MapMagic.ThreadWorker.Refresh () (at Assets/MapMagic/Main/ThreadWorker.cs:143)
    MapMagic.MapMagic.Update () (at Assets/MapMagic/Main/MapMagic.cs:272)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:191)
     
  49. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    @Nitrox32 MM uses threading by default which doesn't automatically get shut down when you leave play in the editor, the threads will try to finish what they were doing. In my experience usually this is cause by a thread trying to place an object or do something it wasn't finished doing after you leave play. It shouldn't be a problem outside of the editor unless you are manually destroying your terrains through code somehow.

    On thing I use is:
    Code (CSharp):
    1.             foreach (MapMagic.Chunk chunk in MapMagic.MapMagic.instance.chunks.All()) {
    2.                 chunk.worker.thread.Abort();
    3.             }
     
  50. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,675
    Could you please clarify when you get this error? Is this happens on playmode change or do you remove tiles manually in playmode/editor?

    Using Thread.Abort() is not a good idea, especially when you don't know what happens in the thread. Dispose() and Monitor.Exit() will not be called. The first one will just create a memory leak, while the last can cause a dead lock and will hang your application. The worst thing that it could happen unpredictably - you can run thousands of tests without an error, but for some users on some devices in some cases this could happen quite often.
    If there's an issue with a playmode change could you please describe the steps to reproduce it so I could fix it the right way. I could not find it at glance, but I suppose there;s something I'm doing wrong.
     
unityunity