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

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    349
    Thanks, but we'll still wait for Wright to get his splines out too :)
     
  2. Mnlk

    Mnlk

    Joined:
    Jun 2, 2017
    Posts:
    3
    You would currently just define the area in which the splines are generated, the generation of MM itself isn't affected by that.

    But i just checked the code and while it's not possible to prevent the generation of out-of-bounds chunks completely without changing MM code, it seems to be possible to skip most of the generation, leaving an empty terrain object. I'll consider adding this as an option.

    For explanation: you should be able to use something like this in any custom generator to skip further generation:
    Code (CSharp):
    1. var coord = new Coord(rect.offset.x / terrainSize.resolution, rect.offset.z / terrainSize.resolution);
    2. MapMagic.instance.chunks[coord].worker.Stop();
    Disclaimer: I haven't yet checked if there are any side effects when doing this!
     
    camta005 likes this.
  3. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Thanks for correcting me and sorry for not getting it right.

    Yes, that might work. But depending on the graph complexity and frame rate it still can create a chunk (if generate thread win the thread race). IMHO the best solution would be creating a mask from a Simple Form and just let mm create empty terrains when out of range.
     
    protopop likes this.
  4. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    I have VS Pro integration in plans, but no ETA yet, and it does not mean that it will be 100% released.
     
    Djayp and Andreas12345 like this.
  5. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    Could you add the ability to limit the size of the world to MapMagic (eg. 10 x 10 chunks), so it doesn't even create the un-needed terrains? To me it seems like a logical feature.
     
  6. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
  7. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Only if it would be handy to do along with something else. There are plenty of other ways to limit the player movement, like collision or script. The terrain is generated in a background and, for an empty terrain with no objects, trees or grass is applied quite fast. As for we it wouldn't be nice if the player will be able to see the terrain edge. What is the main purpose to create it?

    It's version number 1.9.4, a couple of versions back from the one on the AS. It should work with the new terrain system and generate the terrains properly, however will spam error to console. Do you have any problem with the evaluation version?
     
    Ziplock9000 likes this.
  8. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    Like in the Island tutorial I have created my world as an Island / continent surrounded by water, and it creates unnecessary terrains out at sea that are not visible. It seems like a feature that would make sense, to be able to limit the size of the world.
     
  9. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Still not clear why you need to avoid generating those terrains since they don't require much overhead, but anyways, I will keep this feature in mind if will have to change terrain tile manager and will try to implement this feature if it would be handy.
     
    camta005 likes this.
  10. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    Wright and camta005 like this.
  11. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    is there somewhere to download the datas you used in the screenshots? for some reason when importing i only get the island data?

    hmm, i found where you can download the assets on the community download page. i understand you can't add the textures but..where did they come from? reference the author?
     
    Last edited: Feb 13, 2019
  12. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    So i am starting to see the major limitation where i am stuck maybe gurus with map magic can help on this. It seems like every solution i come across creates a cookie cutter biome system. It's not dynamic or random at all. It's quite static. How can you have random results in random locations?
    The tutorial i got working is:

    The biomes don't really matter but here is the node i am using which does work perfectly evenly among the biomes, problem is i don't just want to ping pong the entire world how do i slice this up more?
    https://imgur.com/a/RXpiGVG
     
  13. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    It's just a matter of what you use for your biome mask, check this tutorial:

     
    ftejada and blacksun666 like this.
  14. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    Is there a good workflow for editing a map once it's been created with MM? Obviously any manual edits that are performed are lost if you regenerate the map. But are there any tools out there where you can re-apply your edits?
    I know path tools that use splines would fall into this category, what about the same thing for removing and adding patches of trees or objects, or changing the height and painting?

    Which are compatible with MM (including path tools)?

    Thanks.
     
  15. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    214
    treshold and Ziplock9000 like this.
  16. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
  17. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    It's from an ancient project I've worked on years ago, even before MM was released. Could find almost nothing about it, except this.

    You are not bound to use a Simple Form as a biome mask. Using Noise or Voronoi instead can give the random result all across the land.
     
  18. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    315
    I reported this crash in a prior forum post and it hasn't been fixed as of today
    Reported in https://forum.unity.com/threads/map...nfinite-map-generator-for-asset-store.344440/

    Issue: This code crashes crashes if the camera is in a different scene, or there is no camera

    if (mainCam==null) mainCam = GameObject.FindObjectOfType<Camera>(); //in case it was destroyed or something

    // Addition
    if (mainCam == null)
    return camPoses;
     
  19. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    How do you create an entry point? Only 2 exist, simple form and constants
    I also don't know of any other way to handle biomes without using the normalize with layers option.
    If you figure out how to have a truly randomized biome system without massive bleed blending problems and make it similar to Minecraft style I'd be amazed.

    The best way I have thought of so far:
    Make a probability system somehow that must = 1 in total. Example: Small hills probability=0.2 desert=0.8
    I just have no clue how to do something like that
     
    Last edited: Feb 14, 2019
  20. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    hey Wright,

    It seems 2018.3 has a GPU Terrain solution and it support HDRP. So will there be a HDRP compatible update?
     
  21. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Happily, it already works in a current version. HD terrains use a special DefaultHDTerrainMaterial material from the HDRP package. If you switch MM material to custom in terrain settings, and assign this material as a template terrains will render properly.

    Here is the example of the graph that will blend two biomes infinitely based on a noise pattern:
    NoiseBiomes.png

    That is exactly how the Normalize node works. It makes the sum of all the values for each pixel equal to 1. If it gets 1 from Constant and say 0.5 from Noise it will make both 0.5 in Layers mode.

    Well, the infinite terrain in playmode is actually not infinite - it just takes some marker objects like the main camera or other objects with a specific tag, and generates some terrain chunks around them. When these objects are moved the new chunks are generated. The infinite terrain is not possible when there are no marker objects in all of the loaded scenes. I can suppress the error and just leave MM generating nothing, but I'm afraid it will confuse user by not letting him know that something went wrong.

    BTW just checked that when the scene with the main camera is loaded additively MM still generates terrains around it. Do you get the other behavior?
     
    protopop likes this.
  22. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    upload_2019-2-15_0-6-35.png
    i don't get it, pure desert everywhere, it never recognizes anything else

    it looks like this is a misunderstanding. i don't want to blend at all. this needs to be actual separate biomes randomly generated

    this is what i'm talking about:
    https://minecraft.gamepedia.com/File:River_through_Mesa.png
     
    Last edited: Feb 15, 2019
  23. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    i guess let's just scratch that because i don't think it will be possible with this system.........an entirely different algorithm needs to be used. Anyway, how about saving changes on application quit? I have the player and enemies setup correctly but the terrain isn't generated and people are just floating until it's created. How can i save what's currently loaded(ie: pin what's loaded on application quit)?
     
  24. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Oops, I've mixed up the layer order. This graph will lead to the noise-based biome mixing:
    NoiseBiomes2.png

    All of the scene changes should be serialized using your game's serialization system (if any). It's a bit out of the scope of world generator.
    In the described use case it's better to wait until MM finishes generating chunks by checking if mapMagic.IsWorking is false and only then start the scene (note that the first frame can return IsWorking false depending on the script execution order, so either use LateUpdate or call mapMagic.Update() manually before check).
     
  25. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Hi @Wright

    Is there a way to do something inside a Node that needs to be done in the main thread?
    I'm trying to use Graphics.Blit.

    Many thanks
     
  26. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    You can use
    OnPrepareStarted (Terrain terrain)
    event to do something in a main thread. It's called per-terrain though, so you will have to keep your custom node link in a graph (like
    graph.list[x]
    ), or iterate all graph nodes of this type
    foreach (MyNode node in graph.GeneratorsOfType<MyNode>())
    .
     
    kilik128 likes this.
  27. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Great, I'll give it a try. Thanks
     
  28. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    Hey Wright

    Try to create dynamic desert world. Already got some good result using a graphic your share:
    upload_2019-2-25_18-15-6.png

    upload_2019-2-25_18-15-16.png

    but after close check there some unwanted ripple on terrain like this:

    upload_2019-2-25_18-16-27.png

    Not sure if what goes wrong here, might be some node I am not setting right.
    Can you help me with this thanks.
     
    Nihilus0 likes this.
  29. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    This might happen when using Unity noise type. Don't see what noise type you are using, but guess it's worth trying to change the type per-noise to find out what node causes the ripple.
     
  30. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    And here is another problem with MM and RTP

    upload_2019-2-26_19-1-35.png

    after setup RTP terrain In editor mode shows correctly. But not showing in Runtime.

    upload_2019-2-26_19-0-14.png

    upload_2019-2-26_19-0-20.png

    terrain generate on runtime with RTP is not show correctly. The first one will show after I click it in editor. But the other terrains will never show right. Looks like no material is set on terrain.

    Is there any way to make RTP working in runtime?
     
  31. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    Thanks Wright. I will look in to it.
     
  32. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Are you using MM 1.9.6?
     
  33. nicefive

    nicefive

    Joined:
    Feb 22, 2014
    Posts:
    1
    Good job with MapMagic. I am working on a very ambitious project and MM is helping to make this possible.

    I need to know when a chunk is about to be destroyed so I can freeze/hide dynamic objects first. I was hoping there would be an OnBeforeDestroy(terrain) ChangeEvent but I can only find on generate and on apply events.

    I could slightly alter the code to fire an event but of course I would need to do this every time I update MM.

    Am I missing something that already exists?
     
  34. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    You can use terrain's OnDisable - it might be more handy than changing MM's code. But if for some reason it will not work (not sure about dynamic objects) then take a look at Chunk.OnMove and Chunk.OnRemove methods, or ChunkGrid.Deploy. I can add an event on some point so you will not need to change the code all the time, just let me know where you need it.
     
  35. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    Do you have an updated version of this that works with 2018.3 terrains? Currently exported terrains using this script lose all their textures. (It works fine in 2018.2)
     
  36. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    I've come across another 2018.3 terrain issue. My grass patches are getting tinted in Map Magic, but not in a 2018.3 generated terrain. (Using 2018.3.6f1). You can see the difference in the screenshots below. Note. I'm using trees as grass to simulate an aerial scene. GrassTint01.jpg GrassTint02.jpg
     
  37. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    This script deals with splats only because of some unity issue. I guess they fixed it all with the layers system, so this script might work (have not tested it though):
    Code (CSharp):
    1.        void ExportTerrainData (Terrain terrain)
    2.        {
    3.            if (!export) return;
    4.            export = false;
    5.            string path= UnityEditor.EditorUtility.SaveFilePanel(
    6.                "Save Terrain as Unity Asset",
    7.                "Assets",
    8.                "ExportedTerrain.asset",
    9.                "asset");
    10.            if (path!=null && path.Length!=0)
    11.            {
    12.                path = path.Replace(Application.dataPath, "Assets");
    13.                Terrain terrain = GetComponent<Terrain>();
    14.                UnityEditor.AssetDatabase.CreateAsset(terrain.terrainData, path);
    15.                UnityEditor.AssetDatabase.SaveAssets();
    16.            }
    17.        }
    Note that you are using a different grass type in MM rather than in manual placement. On the first screen it's a standard "grass" type while on the second it's a "billboard" grass. Try switching grass mode in Grass Output layer.
     
    Dorian-Dowse likes this.
  38. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    it really shouldn't be so impossible to just make each chunk a random biome based on probability and seed. that would be the perfect solution for what i'm talking about
     
  39. valentinwinkelmann

    valentinwinkelmann

    Joined:
    Nov 3, 2014
    Posts:
    190
    The preview on terrain function has been broken for a while. In various new / empty projects I get every time only
    Code (CSharp):
    1. ArgumentNullException: Value cannot be null.
    2. Parameter name: shader
    3. UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/buildslave/unity/build/Runtime/Export/Shader.bindings.cs:105)
    4. MapMagic.Preview.DrawMatrices () (at Assets/MapMagic/Main/Preview.cs:205)
    5. MapMagic.Preview.DrawGizmos (UnityEngine.Transform objectTransform, UnityEditor.GizmoType gizmoType) (at Assets/MapMagic/Main/Preview.cs:146)
    6. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    Unity 2018.3.2f1
     
  40. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    Yes I do use 1.9.6 and Unity 2018.3.6 also try ti on 2018.3.5.

    I follow the tutorials of Using RTP in the menu. It said there should be a message that _RTP_LODmanager object has been created. But I didn't see it after I click any fix buttons. And there is no ReliefTerrain component on MagicMap gameobject. I have to add it myself.

    Not sure if there is anything I am doing wrong, but I cannot figure out myself. Counld you please help me on this one. Thanks! It buzz me for a week.
     
  41. Ruonan

    Ruonan

    Joined:
    Dec 6, 2012
    Posts:
    53
    Hey Wright

    I think I got find reason why this is happanning.

    Code (CSharp):
    1.                 #if RTP
    2.                 if (rtp==null) rtp = MapMagic.instance.GetComponent<ReliefTerrain>();
    3.                 if (rtp==null) //if still not found
    4.                 {
    5.                     layout.Par(42);
    6.                     layout.Label("Could not find Relief Terrain component on MapMagic object.", rect:layout.Inset(0.8f), helpbox:true);
    7.                     if (layout.Button("Fix",rect:layout.Inset(0.2f)))
    8.                     {
    9.                         MeshRenderer renderer = MapMagic.instance.gameObject.GetComponent<MeshRenderer>();
    10.                         if (renderer==null) renderer = MapMagic.instance.gameObject.AddComponent<MeshRenderer>();
    11.                         renderer.enabled = false;
    12.  
    13.                         rtp = MapMagic.instance.gameObject.AddComponent<ReliefTerrain>();
    14.  
    15.                         //filling empty splats
    16.                         Texture2D emptyTex = Extensions.ColorTexture(4,4,new Color(0.5f, 0.5f, 0.5f, 1f));
    17.                         emptyTex.name = "Empty";
    18.                         rtp.globalSettingsHolder.splats = new Texture2D[] { emptyTex,emptyTex,emptyTex,emptyTex };
    19.                     }
    20.                 }
    21.                 #endif
    This chunk of code is never running because RTP marco is never defined. And I didn't find any code in MM or RTP defines it. Is there any step I am missing like define RTP some where?
     
  42. ElevenGame

    ElevenGame

    Joined:
    Jun 13, 2016
    Posts:
    146
    Hey Ruonan,
    I am pretty sure that this is just an optional part of the code for those who use RTP. The defines you are referring to can be made in the Player Settings. (Scripting Define Symbols, just the String like "RTP" without " and they are separated by ";")
     
    Wright likes this.
  43. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Thanks, was not aware of this. Is there any way I could reproduce this issue starting from an empty scene?

    You can enable this from MM's compatibility window (Window - MapMagic - Compatibility). Or by manually adding the RTP keyword in scripting define symbols as ElevenGame said.
     
  44. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    Anyone experienced with MapMagic looking for paid work?

    If so, please PM me some screenshots of your MM generated terrain.

    Looking for nothing crazy (various standard biomes, village generation) but would like nice looking scenes that include water. Thanks!
     
  45. valentinwinkelmann

    valentinwinkelmann

    Joined:
    Nov 3, 2014
    Posts:
    190
    I think so, please try it out in an empty project. my unity version is as I said Unity 2018.3.2f1 . I have noticed this bug for a long time in previous versions. I'm currently helping myself by always having a debug texture in the texture output and then viewing my preview over it, but the preview function is of course smarter and should therefore be fixed. it always helped very well in designing the graph.
     
  46. akuptsov

    akuptsov

    Joined:
    Jul 12, 2015
    Posts:
    6
    Hello there!
    Try to import Demo folder too, because TerrainPreview.shader is inside
    Hope that helps
    BR, Alex
     
  47. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    Thanks for that. It still has some issues. The first export creates a blank terrain with height map but no textures. If I export is again, I get this:
    But the exported terrain now has the textures on it. However the terrain editor is locked out of the textures. As soon as I save it, the textures are gone again.
    TerrainPaintError.PNG

    After restarting Unity the editor is available, but the textures are blank, and it's thrown a random layer on at the end.
    TerrainAfterRestart.PNG

    At this point I can: Edit Terrain Layers / Replace Layer and it works.

    It looks like it's not creating links to the layers. This new layer system is quite cool, but it creates an aweful mess when you upgrade to 2018.3. It creates a new folder called "_TerrainAutoUpgrade" and every texture on every terrain gets a layer asset that is dropped in this folder. My project created 218 layer files. I've had to go through and sort them out. I found I can move them and rename them ok.

    For Map Magic to be fully compatable with the new terrain layers, we should be able to drag a terrain layer into the texture node instead of the diffuse/normals.

    I'm also getting some other issues.

    I get this when I try to use the Preview on Terrain:
    And I get the when I select the terrain in the Hierachy:
     
    Last edited: Mar 6, 2019
  48. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Might be so, but it will loose all the compatibility with the previous Unity versions then. I think it's better make a new output (Layers Output or something) that will work only in 2018.3

    That's right, that really might cause this preview issue. Dorian-Dowse, Diego_Graphics, do you have a demo folder in a project?

    Just tried empty project with full MM install in Unity 2018.3.3, but it seems to be working fine. Not sure if this is because of a slight Unity version difference.
     
    Dorian-Dowse likes this.
  49. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    That'd work.

    Yes, no demo folder. We have a lot of assets in our project and we routinely delete demo folders to save space (currently sitting on 44gig). It'd be a good idea not to put critical functionality in a demo folder.
     
  50. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Sure thing. But at least now I know what causes that issue, and will move the shader out of the demo folder in next update.