Search Unity

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

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    Hey Wright

    I find a bug in 2018.3.6.
    Lets say I have a graph and save it.
    If I reopen Unity there is an error:

    InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
    UnityEngine.Object.EnsureRunningOnMainThread () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:153)
    UnityEngine.Object.GetInstanceID () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:73)
    UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:182)
    UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:140)
    UnityEngine.Object.op_Inequality (UnityEngine.Object x, UnityEngine.Object y) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:405)
    MapMagic.CustomSerialization.ReadClass (System.Int32 slotNum, System.Collections.Generic.List`1[T] classes, System.Collections.Generic.List`1[T] objects, System.Collections.Generic.List`1[T] floats, System.Collections.Generic.List`1[T] references) (at Assets/MapMagic/Main/CustomSerialization.cs:409)
    MapMagic.CustomSerialization.ReadClass (System.Int32 slotNum, System.Collections.Generic.List`1[T] classes, System.Collections.Generic.List`1[T] objects, System.Collections.Generic.List`1[T] floats, System.Collections.Generic.List`1[T] references) (at Assets/MapMagic/Main/CustomSerialization.cs:398)
    MapMagic.GeneratorsAsset.OnAfterDeserialize () (at Assets/MapMagic/Main/GeneratorsAsset.cs:1148)

    And the graph is disappeared. I have to redo the graph again.
    It happens when I upgrade to 2018.3.6.
     
    iddqd likes this.
  2. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    I have the same issue.
     
  3. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Could you send me the graph on that stage when the error is about to appear on loading it? So I could load it and get this error too to debug it.
    Ruonan, iddqd, probably I will need graphs from both of you just to make sure this issue has the same reason.
     
  4. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53

    PM your the graph
     
    Wright and iddqd like this.
  5. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Code (CSharp):
    1. EnsureRunningOnMainThread can only be called from the main thread
    Wait, what?! o_O

    Why should one check the main thread if it could be checked from the main thread only? Guess EnsureRunningOnMainThread has 'return true' inside :)

    BTW it's Unity 2018.3.6 issue, in Unity 2018.3.3 everything works as expected.

    I will make a project to reproduce this issue and send it to Unity since I'm pretty sure it shouldn't work this way. For now here is a hack fix. Will submit it in a new version if Unity won't fix this before.
     
    camta005 likes this.
  6. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    By the way, the new MM version (1.9.7) is available at the Asset Store:
    - It brings the new Textures Output for 2018.3 texture layers (they could be assigned as the assets)
    - Doesn't require demo folder anymore.
     
  7. Deleted User

    Deleted User

    Guest

    Hey,
    We are using Map Magic and we are really happy with it.

    The thing is we want use a second Map Magic Terrain to have some kind of LOD setup with lower map resolution and no grass and trees/objects for a wide distance view.

    Question 1:
    Is there some settings for this in the Map magic Inspector?

    Question 2:
    If not how could we create a second map magic object and generate the low resolution terrain like we want via script?
    We just have to get the coordinates of the Main Map and generate around this coordinates the Low resolution terrain, the transition does not need to be good because the player will never reach this low resolution terrain when the main map keep generating.
    I already try it out but map magic does not allow to use multiple map magic objects in one scene also the question is how we stop the low resolution map generating automatically at the main camera so that it's only visible in the background.
     
    Last edited by a moderator: Mar 9, 2019
  8. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    It's not built-in, but you can do it. MapMagic uses threading via a singleton so you CANNOT use two at the same time. You can swap between two in runtime though just fine, that's how I do it. Just make sure all the threads are finished in one before you turn it off, then turn the other one on. You can also specify chunks for it to draw instead of using the main camera, though it can be useful to leave the camera reference with a super high on/off distance so it doesn't automatically disable the terrains. Or you can have it generate around specific objects and place the objects yourself to represent which terrains you want it to draw.
     
  9. Liminal-Ridges

    Liminal-Ridges

    Joined:
    Oct 21, 2015
    Posts:
    256
    I have some workflow problems with MM and i think its the terrain update that causes them. What is the last Unity version without problems?
     
  10. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    If you are using a limited terrain then it's probably better generate the low-resolution chunks beforehand, and then use only one MapMagic fore details in runtime. Using low-res terrains will not take much space, and you will not have to switch between two MM objects.

    I have to admit that using singleton isn't a good practice in this case. MM2 avoids this disadvantage, though I had to redesign it greatly.

    The most recent MM available at the Asset Store (v.1.9.7) was tested in Unity 2018.3.3.
    If you are using a later version and have an `EnsureRunningOnMainThread can only be called from the main thread` issue take a look at this fix.
    Feel free to email me any problems you encounter using MM.
     
    syscrusher likes this.
  11. Deleted User

    Deleted User

    Guest


    Thank you for the response i will try to create my system probably in way 1 because we are working with a infinite terrain.

    I updated Map magic to 1.9.7 and found out that something strange happens with my grass textures.
    Im currently at Unity Version 2019.1.b6, and i can't downgrade because unity uses some other logic in it's packages, how ever i get this bug:
    2019-03-11 13_56_23-Stone Reverie.png
    2019-03-11 15_46_04-Stone Reverie.png
    It's only happens when you explore the world and walk to a chunk terrain which was not pinned and generated in the editor before so only at runtime generation, the default pinned terrain works without problems, also it only happens in a Build version not in the editor.

    Is there something i have to take care from the textures settings?

    Usually it looks like this:
    2019-03-11 14_23_33-Unity 2019.1.0b6-.png

    Thanks for your general help.
     
    Last edited by a moderator: Mar 11, 2019
  12. SylphWorks

    SylphWorks

    Joined:
    Jul 13, 2011
    Posts:
    8
    I create new scene and new Map Magic object.
    And I want to create it to prefab, so drag Map Magic object to Project view.
    But terrain is disappered.
    Maybe warning "Terrain Asset Missing" in "Terrain 0,0" object under the Map Magic object is causing,
    Is there any solution?
    Map Magic Version is 1.9.7
    Unity Version is 2018.3.0f2
    Thanks!
     
  13. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    I tried your fix but it didn't work - I got an error about object not being a texture 2d. I also now installed 2018.3.8f1, but the error is still there.
     
  14. valentinwinkelmann

    valentinwinkelmann

    Joined:
    Nov 3, 2014
    Posts:
    191
    Any eta for Vegetation Studio Pro support ?
     
    Kaen_SG and Djayp like this.
  15. Kaen_SG

    Kaen_SG

    Joined:
    Apr 7, 2017
    Posts:
    206
    Really hoping for VS Pro support/integration as well. It's at the top of my wish list.
     
  16. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    It would help a lot if you could run the same scene in a stable Unity version. I'm not talking about the whole project, but you can export the graph and create MM object with the same settings in 2018.3, so no of the game logic will be used.

    BTW was it working fine with the older MM version?

    It's the standard behavior when you try to create a prefab of a terrain - any terrain, not only MM one. You've got to use TerrainData asset in case of a standard terrain, and MapMagic Data (graph) in case of MM.

    Could you please email me the graph that causes the error?

    It's planned for v1.10, but I can look into it tomorrow. Hope it's the matter of days, but I'm NOT promising that, it's just a plan.
    Will look into MicroSplat integration too.
     
  17. Kaen_SG

    Kaen_SG

    Joined:
    Apr 7, 2017
    Posts:
    206
    Thanks @Wright ! I love MM and VS Pro... and it's difficult to live without either of them in my project.
     
  18. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Thanks @Wright - MicroSplat integration would be amazing!
     
  19. Deleted User

    Deleted User

    Guest

    I tested different Unity versions, 2018.3 works, 2019.1.0b5 works, 2019.1.0b6 don't works.
    Probably they forget something or changed something in this version, it's only effecting the Build Version and not the Editor.

    In the demo scene build the bug behaves a little different, the grass texture is just not existing anymore in the new runtime generated chunk.
    2019-03-12 16_31_39-Stone Reverie.png


    I don't know i just made a general function test and then i notice it.
     
  20. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    It seems Unity will not have any update on this bug soon. Already Patch the fix. Thanks a lot.

    For now I am trying to integrate VS. I read a tutorial here: https://www.awesometech.no/index.php/set-up-with-map-magic-infinite-terrain/ . But this will break my workflow because I need all terrain to generate when game start. This method has to leave at least one terrain in scene.

    I think Vegetation Studio Node in MM Graph will do this job, am I right? and I failed to find any tutorials about this node.

    upload_2019-3-13_17-35-9.png

    It seems need drag VS package in the Packge. But I don't know what should I put in the Prefab input.

    Do you have any instruction on this node?
     
  21. akuptsov

    akuptsov

    Joined:
    Jul 12, 2015
    Posts:
    6
    Denis, it would be so nice to use less Resource named folder in further versions, because the files inside are include in build which is obviously leads to increased build size) Thanks in advance
     
  22. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    Any update on when MM2 will released? And what features will be in it vs MM1?
     
  23. cmart

    cmart

    Joined:
    Jul 10, 2012
    Posts:
    121
    Hello,

    I recently updated MM before reading the patch notes (my mistake, I know) and I am using 2017 for a project. How do we use texture output if we aren't using 2018.3? If not, is there somewhere to download an older version of MM?

    Thanks
     
  24. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    If it works with 2019.1.0b5 then there should be something on Unity side. Don't know if they are going to fix it. If not I will try add some workaround on the release version.

    Yes, this node will create VS objects on the dynamic terrains. Dragging the package would be enough, you need the prefab only when VS is used as a prefab. You can leave it None. In fact I will bring it to advanced settings to prevent confusing in further versions.

    I concur. They are mainly an editor icons, so they will be moved to Editor folder and will use EditorGUIUtility.Load to be loaded.

    There's no mistake, you can still use the 2017 terrain splats with the Splats Output.
     
  25. cmart

    cmart

    Joined:
    Jul 10, 2012
    Posts:
    121
    Thanks for the response Denis, I appreciate it.

    Now I have a stranger problem though, I took a terrain I made with map magic to edit by hand, and the grass/detail brush no longer works. Height, trees and textures work fine, just grass/detail. I thought it might have something to do with the terrain data or collider, so I used the script you had on your wiki to export the data, dragged that in a new scene and its the same problem, everything works (including collider, at least in play mode) except the grass/detail.

    Have you heard of this before, have any tips to fix this? I am stumped, its quite odd. Thanks for any advice

    edit: so I fixed this by exporting the height map, then importing it on a new terrain. Then I used world machines splat swapper tool to get my paint in. Really strange, but its all working now.
     
    Last edited: Mar 15, 2019
  26. Deleted User

    Deleted User

    Guest

    Ah okay, just a info the bug is also existing in the unity 2019.2 alpha version, i stay on 2019.1.0b5 now and wait for some updates on your side.

    Unity want implement Holes for the Terrain in v2019 is for this topic some new Nodes planed, would be amazing to create dungeons with map magic, i also own Voxeland and there is also a Holes generator for map magic which is also amazing.
     
  27. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Nope, have not heard this before. Tried to reproduce, but it seems to be working. The grass could be edited with the standard terrain tools, both added and removed. New grass types could be created and painted as well. I'm using 2018.3, though, will test with 2017.3 soon.

    I have not looked into 2019 yet, so can't say what are those holes and the way they will be done. So it's too early to speak about holes nodes yet.
     
  28. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    In version 1.9.7 the Cliff_n normal map is imported with the wrap mode set to clamp instead of repeat, which is causing a seam between terrains and other visual glitches in the Island demo. Just changing the wrap mode to repeat fixes the issue.
     
  29. Aress28

    Aress28

    Joined:
    Dec 12, 2015
    Posts:
    100
    Vegetation Studio PRO compatible with MapMagic?
     
  30. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    For me - mostly yes :) I'm working on it right now, at the current moment. Still have some issues. Once they are fixed I will submit a new version. Plan to finish it this week, and then look into MicroSplat. Once it all done I will submit v1.10.
    (Note that these are my plans, I can't promise that everything will happen as I expect. Current v 1.9 has no VS PRO support, so if it's the key feature for you consider waiting v1.10 release).

    Thanks!

    I'd like to share the video on of MM users linked. One of the examples of a great MM use (their own spline nodes are shown too):
     
    Dwight_Everhart, iddqd and camta005 like this.
  31. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    It's great to see MM being used in a commercial game. I had even seen the trailer before but didn't realise it was using MM.
     
  32. Lumos

    Lumos

    Joined:
    Feb 11, 2013
    Posts:
    49
    Hey Denis, we spoke briefly over emails yesterday, just dropping in to once again state how awesome MapMagic is.

    One quick question: Can one "upscale" stuff such as Voronoi output? I want larger patches, but there's no parameter for that, and there doesn't seem to be a map that does that sort of thing.

    EDIT: Never mind, I threw together one really quickly, and I can now control both "horizontal" as well as "vertical" scaling right in the Voronoi output. Believe it or not, I spent pretty much half a day writing generators for this thing. It's addicting! Aside from the scaling Voronoi, I added support for labels to write comments on, and added a "Slice" generator as well (allows you to partition a map into several maps based on intensity, because sod fiddling with boring (and imprecise) staircase curves). I've got at least a "Multiplex" and a "Stratify" in mind for tomorrow. Oh, and I need to upgrade the trees output to allow for colour gradients and perhaps the "random colour variation" option that built-in terrains have. Damn, Denis! I never would've thought I'd have so much fun! I wish I'd discovered this years ago!
     
    Last edited: Mar 20, 2019
  33. maniak_001

    maniak_001

    Joined:
    Jun 13, 2016
    Posts:
    31
    Hi Lumos

    These sound awesome, would you consider sharing them?
     
  34. Lumos

    Lumos

    Joined:
    Feb 11, 2013
    Posts:
    49
    We'll see. I hope I'll be able to do so, with a bunch of other useful generators added on top. But first I'd rather make sure everything's in order. :)
     
    maniak_001 and Willbkool_FPCS like this.
  35. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
  36. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Done! (for v1.10)

    I know there are some users that are submitting their generators to the Asset Store now. Feel free to do the same!

    PS
    Should be the Cell Count
     
    Djayp likes this.
  37. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    Thanks!
     
  38. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    How can I access the terrain from within Generate?
    In the legacy system it was possible to use chunk.terrain

    Thanks
     
  39. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    I wrote a simple integration between Map Magic and Vegetation Studio Pro. It allows you to use VS Pro to add vegetation to Map Magic terrains. It does not add a Map Magic node to generate VS Pro vegetation. If you want that, you'll need to wait for an official integration, but, if you want to use VS Pro's rules to place the vegetation, this script will do the job. Just attach it to the VegetationSystemPro object.

    Code (CSharp):
    1. using AwesomeTechnologies.VegetationSystem;
    2. using UnityEngine;
    3.  
    4. public class MapMagicVSProIntegration : MonoBehaviour {
    5.     private void Awake() {
    6. #if MAPMAGIC
    7.         MapMagic.MapMagic.OnApplyCompleted += OnApplyCompleted;
    8. #endif
    9.     }
    10.  
    11.     private void OnApplyCompleted(Terrain terrain) {
    12.         var unityTerrain = terrain.gameObject.GetComponent<UnityTerrain>();
    13.         if (!unityTerrain) {
    14.             unityTerrain = terrain.gameObject.AddComponent<UnityTerrain>();
    15.         }
    16.  
    17.         unityTerrain.TerrainPosition = terrain.GetPosition();
    18.         var vs = GetComponent<VegetationSystemPro>();
    19.         vs.AddTerrain(terrain.gameObject);
    20.     }
    21. }
     
    Nihilus0, camta005 and malkere like this.
  40. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    You can get the terrain size, resolution and height using the Chunk.Size class in each Generate function (usually called terrainSize). It's not a good idea to use the terrain itself since it's a unity component and cannot work in non-main thread, and thus it's not used anywhere in Generate (only in output generators in Apply, which is called in main thread).

    Thanks for sharing the code! BTW, haven't you seen any problems with grass flickering on adding UnityTerrain component? As far as I understand it should be added after VS Update, so if script execution order is equal in 50% cases it can cause the grass disappear for one frame. Lennart said it should work fine in Update if the script execution order is +100, but I haven't checked it, just using OnRenderObject instead.
     
    Dwight_Everhart and iddqd like this.
  41. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
  42. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Vegetation Studio Pro integration is coming!
     
  43. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    214
    superb, is it the same workflow for infinite terrains?
     
  44. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Yes, it works on the infinite terrains
     
    Djayp and blacksun666 like this.
  45. baaleos

    baaleos

    Joined:
    May 12, 2018
    Posts:
    12
    @Wright - is it possible to generate infinite terrains, with included water bodies?
    Eg: In your videos, you use a lake/ocean asset to create an ocean around an island. What if I want to create infinite terrain, but want to have some lakes occurring randomly. I know I can use the shore generator, but how do I get the water assets / water surfaces to appear spawn in - or how do I get the effect of oceans appearing between landmasses? Any tips on procedural waterfalls / rivers? These seem too complex to procedurally generate.
     
  46. ElevenGame

    ElevenGame

    Joined:
    Jun 13, 2016
    Posts:
    146
    @baaleos yes, infinite water is definitely possible, there is an example for placing something like AQUAS waterplanes at the bottom of the following page: https://gitlab.com/denispahunov/mapmagic/wikis/Scripting_faq
    Rivers and waterfalls are not quite as easy, but I am personally looking forward to the Spline Tools for Map Magic by Arctium Studios, which should be released in the next few days. (https://twitter.com/ArctiumStudios) It is meant mainly for roads for now, but rivers are a planned feature..

    @Wright The Vegetation Studio Pro Integration planned for the upcoming version looks very nice! :) I just wanted to let you know that I also encountered the Animation Curve serialization issue in 2018.3 (https://gitlab.com/denispahunov/mapmagic/issues/287)
     
    Nihilus0 and camta005 like this.
  47. truesightprojects

    truesightprojects

    Joined:
    Aug 19, 2018
    Posts:
    1
    Hey Wright.

    I've been wanting to pull the trigger on your MapMagic asset for abit, although I have some questions regarding it's use case and what's possible:

    Is it possible to export terrains made with MapMagic to normal unity terrains?
    Is it possible to disable tiling?
    Are terrains able to be static from scene to scene since they're randomly generated?
    Is it possible to make islands?

    Best regards,

    William Pfaffe
     
  48. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Thanks, will look into it before submitting the new version.

    If you are going to create some lakes with no water plane underneath all the terrain (for the performance reasons, I guess) you can place them in just like usual objects. Personally I would rather scatter them in lowlands (using the scatter mask), deepen the ground under them (with blob + subtract blending), and output in water planes:
    ScatterLakes.jpg
    EDIT: Scene attached
     

    Attached Files:

    Last edited: Mar 28, 2019
    Nunez-Torrijos likes this.
  49. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Hi William, glad to hear you are interested in MM.

    MapMagic terrains are actually normal Unity terrains. Yes, you can export their data to use in other scenes.

    MM use the deterministic algorithms, so it will generate exactly the same terrain each time. As long as the graph and seed numbers are the same MM will create same terrains indifferent scenes.

    Sure, why not?
    Island5.jpg
    Island here is pretty simple, but it's made just of 4 nodes + output

    It's a bit unclear what do you mean under tiling, so could you please clarify what are you going to make?
     
  50. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    It is worth mentioning that Aquas water will have infinite water using world space UV mapping soon which will work nicely with MapMagic. The details of the update can be found on the Aquas forum thread.
     
    syscrusher likes this.