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

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    365
    Hello, apologies if these questions have been asked before but I am trying to piece the info in one place:

    1. Can this asset be used to create a terrain via a seed generated at runtime (and that specific seed number be stored say in a PlayerPref so it can be retrieved at a future point to generate the same terrain)?
    2. If so is an entire terrain generated from a single seed or is it a combination of procedural definitions including the seed that generate the terrain?
    3. Can a seeded terrain also have some regular pattern such as a zero edge so multiple seeded terrains can be tiled at the same edge height easily?
    4. Can specific graph nodes be references in code and values be changed at runtime?

    Many thanks :)
     
    Last edited: Sep 4, 2019
  2. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,067
    1. That's the normal flow of the asset yes.
    2. The MapMagic object itself has a seed that is sort of the "main" seed. There are also internal seeds on the generator nodes such as Noise and Scatter that generally remain static and are used more to make sure that each noise node is generating something different than one another, though you can manipulate those freely as well.
    3. You can write custom generators to do almost anything. I have a custom generator that defines a biome for every 8x8 chunk or terrains which then tells MapMagic what to draw where.
    4. Absolutely. To make this easier I've added a simple "name" string to some of my generators so I can find them during startup. Keep in mind that changing a value in runtime would mean that you would need to regenerate all the terrains for the changes to take affect, which is basically turning them all off, regenerating them, then turning them all on again. This isn't a problem for like world settings prior to loading a level, but not really something you want to do while the world is loaded and being played.
     
    Wright likes this.
  3. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    365
    Thanks for the detailed response :)
     
  4. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    365
    I guess I should wait for the new version MM2?
     
  5. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,067
    I'm not sure how you came to that response? MM2 won't be changing any of those base mechanics as far as I know. Is there something that sounded bad in all that?
     
  6. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    365
    Sorry, no I just mean if it is being released soon I could avoid buying both versions
     
    Last edited: Sep 5, 2019
  7. PyroStudios

    PyroStudios

    Joined:
    Sep 23, 2012
    Posts:
    206
    I would like to add MapMagic to a current project that I'm working on.. but I keep hearing about MM2 and I don't want to jump in now because I'm not sure when MM2 will be released.
     
  8. Binary42

    Binary42

    Joined:
    Aug 15, 2013
    Posts:
    158
    Bump.
    For the platformer im using MM for, i managed to *just not* generate the tiles in view direction and behind the camera with a custom center object that strictly moves left/right only. So i kinda have a 1D generation but with a realistic FOW one can see the left and right tiles pop in, that's why i should use a higer range for tile generation but that would generate those in view dir and behind too ...

    The other question is: how do i feed world data into MM? For instance a road network.

    For MM2 there will maybe a fair upgrade price @Wright? So you can start right away, it's worth it. ;)
     
  9. Zoryth

    Zoryth

    Joined:
    Dec 5, 2016
    Posts:
    33
    and can my project migrate to mm2? or I will have to make another terrain "from scratch"?
     
  10. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,606
    Stardog, Bodyclock, thanks for reporting the issue. The thing is the assets compatible with MM change, and this can cause the bugs where it was working and tested.

    It would be cool if you could share your project so I could look deeper into this issue (email). If not - could you please check if the same issue appears in the demo scene?

    You can input custom coordinates with the custom node like this one. There's no way to access scene objects out of the box, however the custom node that reads coordinates in Prepare function is possible, but requires some scripting knowledge.

    You can turn off both "Generate around main camera" and "Generate around objects tagged", and assign the tiles you need to generate manually with the script using mapMagic.chunks.Deploy and CoordRect.PickIntersectingCellsByPos to calculate the deploy rects.

    I like the idea of naming generators to get access via code. Will note it to implement in MM2 :)

    It depends on how much time you have for your project or what features do you need from MM. If you are happy with MM at it's current state or don't have three months or so in reserve - take MM1. If you are looking for a platform for you future projects or need splines, faster speed, drafts, etc - then MM2 is worth waiting for. I plan to release it within three months, however it's just a plan.

    I will make a grace period of minimum a month for MM1 users on MM2 release - this means that all who purchased MM1 a month prior to MM2 release date will get MM2 for free. Other MM users will get it for the half price.

    There will be an upgrade helper tool that will convert the nodes to MM2 format, however the generated results will differ because the random algorithms have changed. You will still need to look through and tune your graph.
     
    Binary42, PyroStudios and malkere like this.
  11. Lumos

    Lumos

    Joined:
    Feb 11, 2013
    Posts:
    45
    The GPU Instancer is compatible with MM out of the box. One of the older versions didn't support biomes, but I'm pretty sure they've fixed it at this point.
     
    msmolana likes this.
  12. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    365
  13. msmolana

    msmolana

    Joined:
    Apr 28, 2019
    Posts:
    5
    Regarding accessing mm output by coordinates
    I made some progress on accessing generator output by coordinates.
    I created bitmap that somewhat reflects output preview (see attachment - preview is on right).
    I am not sure how to proceed.. any ideas?

    Code (CSharp):
    1.  
    2.         MapMagic.Chunk.Results results = new MapMagic.Chunk.Results();    
    3.         MapMagic.Chunk.Size size = new MapMagic.Chunk.Size(magicMap.resolution, magicMap.terrainSize, magicMap.terrainHeight);
    4.         magicMap.gens.Calculate(32, 32, 1024, results, size, 12345);
    5.         MapMagic.Matrix mmTrix = (MapMagic.Matrix)results.results.Values.ToList().First();
    6.  
    7.         float min = mmTrix.array.Min();
    8.         float max = mmTrix.array.Max();
    9.         int len = (int)Math.Sqrt(mmTrix.array.Length) / 2;
    10.         Rectangle bmpRect = new Rectangle(0, 0, len, len);
    11.         Bitmap bmp = new Bitmap(len, len, PixelFormat.Format32bppRgb);
    12.         byte[] byteArray = new byte[len * len * 4];
    13.    
    14.         byteArray = new byte[len * len * 4];    
    15.         for (int x = 0; x < len * 2; x++)
    16.         {
    17.             for (int y = 0; y < len * 2; y++)
    18.             {
    19.                 int index = x * len * 2 + y;
    20.                 byteArray[index] = (byte)((mmTrix.array[index] - min) / (max - min) * 255);
    21.             }
    22.         }    
    23.  
    24.         BitmapData flagData = bmp.LockBits(bmpRect, ImageLockMode.ReadWrite, bmp.PixelFormat);
    25.         System.Runtime.InteropServices.Marshal.Copy(byteArray, 0, flagData.Scan0, byteArray.Length);
    26.         bmp.UnlockBits(flagData);
    27.         bmp.Save(@"U:\\bitmap.bmp");
     

    Attached Files:

  14. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,067
    @msmolana what's your end goal with this?
     
  15. msmolana

    msmolana

    Joined:
    Apr 28, 2019
    Posts:
    5
    I want to get tactical map that will be generated based on position on world map.
    So if I am standing in the forest tactical map will be generated with trees etc.
     
  16. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    193
    Is it possible, to create several map graphs, then switch them dynamically? Like eg. 1 level is forest, Level 2 desert. Ect ect.

    and what is the common practice people use for Navmesh?
     
    Last edited: Sep 8, 2019
  17. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    193
    I updated mapmagic, and if i try to load a project, it crashes...
     
  18. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,067
    You could definitely take a picture with a camera just looking down at your world and render that to a sprite if that works for your case. Otherwise, the way I do it is to actually use the TerrainData of the terrain itself once MM is done with it. There you've got splat weights and tree positions easily accessible. I assign each splat a color and generate a color for each point on the map based on a blend of all the splats. I don't take into account trees, but you could make a pass on the resulting image to paint top down trees on it.
     
  19. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,606
    Could you please clarify what are the size ratios between world map and tactical map? Is the world map the one that has a large scale, and tactical map just uses the part of it? Or vice versa?

    If you mean graph - could you please send it to me so I could look into this? If it's really a project - well I have to try to load it somehow anyways.
     
  20. p_hergott

    p_hergott

    Joined:
    May 7, 2018
    Posts:
    193

    Create a render texture. Set a camera like 50 units or more above your player, set the render texture into that cameras render slot. Then create a UI. With the raw image of that render texture. Like malkere said. Or set the camera super high with a far clipping and use that as a larger world type map. Just dont render that one everyframe lol.
     
  21. flow-

    flow-

    Joined:
    Apr 19, 2015
    Posts:
    138
    I send you an Email...
     
  22. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    288
    I was away for the last several weeks, and when I got back I updated my Unity 2017.4.x project to 2017.4.32f1 (for Mac) and updated MapMagic to 1.10.6. Ever since, I've been getting this hard stop error in my console.

    Assets/MapMagic/Generators/CustomShaderOutput.cs(842,5): error CS1525: Unexpected symbol `break'

    I tried deleting and re-installing, but it persists. I'm not sure if it's relevant, but this project had Vegetation Studio (not Pro) 1.5.2.0 (update dated 7 September) installed as well. Any help you could give me banishing this error would be greatly appreciated.
     
  23. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,606
    It's related with CTS rather than Vegetation Studio, but it's definitely MM issue. Try this quick fix.
     
  24. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    288
    Thanks, though unfortunately it created a dozen other hard stop errors...

    Assets/MapMagic/Generators/CustomShaderOutput.cs(1,0): error CS1525: Unexpected symbol `<'
    Assets/MapMagic/Generators/CustomShaderOutput.cs(3,25): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(4,5): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(23,24): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(24,24): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(25,24): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(29,21): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(71,37): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(76,255+): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(76,255+): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(76,255+): error CS1012: Too many characters in character literal
    Assets/MapMagic/Generators/CustomShaderOutput.cs(76,255+): error CS1012: Too many characters in character literal
     
  25. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,606
    All the MapMagic 2 testers might find useful this new MM2 tutorial:

    It seems that something went wrong during the downloading or copying the script. Please check if your CustomShaderOutput.cs really contains the code.
     
    ftejada and Nihilus0 like this.
  26. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    115
  27. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    288
    I tried re-saving the file through dropbox, and it worked the second time. Thanks, and can't wait to get to use MMWG 2!
     
  28. DropNodes

    DropNodes

    Joined:
    Jun 11, 2019
    Posts:
    15
    updated to the latest version and getting this error:

    Assets\MapMagic\Generators\LegacyOutputs.cs(378,26): error CS1061: 'MapMagic' does not contain a definition for 'terrainMaterialType' and no accessible extension method 'terrainMaterialType' accepting a first argument of type 'MapMagic' could be found (are you missing a using directive or an assembly reference?)

    Assets\MapMagic\Generators\LegacyOutputs.cs(388,26): error CS1061: 'MapMagic' does not contain a definition for 'assignCustomTerrainMaterial' and no accessible extension method 'assignCustomTerrainMaterial' accepting a first argument of type 'MapMagic' could be found (are you missing a using directive or an assembly reference?)

    I completely deleted the old MM and installed the new one

    Unity 2019.2.5f1
     
  29. AngelBeatsZzz

    AngelBeatsZzz

    Joined:
    Nov 24, 2017
    Posts:
    168
    Hi, I am using the latest version of Mapmagic + Unity2019.2.0f1.

    I have a flying camera and when it flies for about 15-20 minutes the terrain may suddenly be no longer generated, no matter which direction. In the end, there is only one terrain block left. My MapMagic component configuration is shown in the figure, and the editor node is the same as the Demo scene. Do you know how to solve this problem or optimize it?

    There is another problem, I tried to check Draw Instanced, but after checking, the camera can see the tree behind the mountain.

    20190914205615.png 20190914205637.png
     
  30. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,606
    Thanks for finding that out, the issue is fixed and submitted for review. As a workaround you can remove the LegacyOutputs.cs script completely if you don't want to use old Splats Output.

    Is there any error in the console?
    I have not encountered the issue with trees seen through the terrain, but they could be probably related with the floating point precision limitation. Flying for 20 minutes is a pretty large distance after all. Or is this happen on the first tile?
     
  31. AngelBeatsZzz

    AngelBeatsZzz

    Joined:
    Nov 24, 2017
    Posts:
    168
    Error:
    Code (CSharp):
    1. Error generating chunk: MapMagic.Coord x:1 z:-1: System.OutOfMemoryException: Out of memory
    Where can I change the floating point precision limitation? If I reload the game scene, do I need to reset the mapmagic with code?
     
  32. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    209
    How difficult will it be to update custom generators to MapMagic 2 ?
     
  33. PyroStudios

    PyroStudios

    Joined:
    Sep 23, 2012
    Posts:
    206
    Hello @Wright I have my MM purchase invoice number. Could I somehow help test MM2?
     
  34. Southroner

    Southroner

    Joined:
    May 29, 2017
    Posts:
    5
    Hello! Thanks again for the continued support of your great asset.

    I have used Megasplat with Map Magic in the past and had it work flawlessly using your integration. However, I have tried getting it to work again here recently in Unity 2019.2.3f1 and have run in to a problem with the current integration - only the base layer texture cluster is shown regardless of input to other texture clusters. I can get other clusters to show if I use a constant - 1 input or if I use noise with intensity > 2 (however this makes the whole chunk's texture that of the texture cluster fed by the noise node). There is never any overlap or more than one texture cluster drawn per chunk.

    I opened a test project using only map magic's demo scene and swapped in Megasplat instead of the texture node - no other assets - but the problem remains.

    I am able to properly texture another terrain procedurally using Megasplat and a script of my own so Megasplat seems to be working well even though it hasn't been updated recently. I just am not sure what broke in the integration or if there is something obvious I need to do that I am missing.

    Thanks in advance for your help!
     
  35. trilobyteme

    trilobyteme

    Joined:
    Nov 18, 2016
    Posts:
    288
    Heads-up, MMWG 1.10.7 is crashing on install in Unity 2019.4.9f1. It downloads without incident, and the import button and floating menu appear as expected, but partway through actually installing it, it crashes the Unity Editor (on macOS). After it crashes the project, the Unity Editor will then crash on launch until the /Assets/MapMagic folder is deleted.

    I tried again after manually removing that folder (in case it was something in the previous install causing the issue), but that did not help. I then created a blank Unity 2018.4.9f1 project with nothing else in it and tried to import MM, and it crashed.
     
  36. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,606
    Guess it's 2018.4 you are talking about. Probably something mac-related, on PC it seems to be working fine. Might it be that it has not been downloaded properly?

    Thanks for reporting this issue. I've already fixed this, and the fixed version (1.10.7) is now available at the Asset Store.

    Sure, email me your order number and GitLab account name if any.

    It should not be a problem, especially when your generator logic is placed within a special method. Here is what the new nodes will look like:
    Code (CSharp):
    1.     [System.Serializable]
    2.     [GeneratorMenu (
    3.         menu="Map/Modifiers",
    4.         name ="Terrace",
    5.         icon="GeneratorIcons/Terrace",
    6.         disengageable = true,
    7.         helpLink ="https://gitlab.com/denispahunov/mapmagic/wikis/map_generators/terrace")]
    8.     public class TerraceGenerator200 : StandardGenerator, IOutlet<MatrixWorld>  //standard (non-layered-output-biome etc) generator that returns matrix
    9.     {
    10.         [Val("Input", "Inlet")] public readonly Inlet<MatrixWorld> inlet = new Inlet<MatrixWorld>();
    11.         public override IEnumerable<Inlet> Inlets() { yield return inlet; }
    12.  
    13.         [Val("Seed")]         public int seed = 12345;  //attributes instead of gui method
    14.         [Val("Num")]         public int num = 10;
    15.         [Val("Uniformity")] public float uniformity = 0.5f;
    16.         [Val("Steepness")]     public float steepness = 0.5f;
    17.         [Val("Intensity")]     public float intensity = 1f;
    18.  
    19.      
    20.         public override void GenerateSelf (TileData data, StopToken stop)
    21.         {
    22.             MatrixWorld src = data.GetProduct(inlet); //gets source matrix from data
    23.             if (!enabled || src == null || num <= 1) return;
    24.  
    25.             MatrixWorld dst = new MatrixWorld(src); //clones source
    26.  
    27.             float[] terraceLevels = TerraceLevels(new Noise(data.random,seed));
    28.                 //prepares the heights of the terrace
    29.          
    30.             if (stop!=null && stop.stop) return;
    31.             dst.Terrace(terraceLevels, steepness, intensity);
    32.                 //native c++ function that applies terrace levels to matrix
    33.                 //here could be your own custom logic instead
    34.  
    35.             data.SetProduct(this, dst);  //writes cloned and processed dst to data
    36.         }
    37.     }