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

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    What do you mean by chunk ID? You can get a chunk using it's coordinate (i.e. position/terrain size briefly) by using
    Code (CSharp):
    1. public Chunks [coordX, coordZ]
    This way we can get chunk using terrain transform position:
    Code (CSharp):
    1. Chunk chunk = MapMagic.instance.chunks[
    2.     Mathf.FloorToInt(terrain.transform.position.x/mapMagic.terrainSize),
    3.     Mathf.FloorToInt(terrain.transform.position.x/mapMagic.terrainSize)];
     
  2. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    I meant the chunk coordinates. So I just use the terrain tile's position and divide them by terrain size from MM instance right?
    Will it work if I use the world shift function?
    And about world shift function, now it moves all objects in the scene all together, but actually the Canvas, Skybox and gamemanagers does need to be moved. Is there any ways that can let me choose which object should be moved rather than move all of them?
     
  3. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Yep. And floor them to int (not cast, but Mathf.FloorToInt - it process negative values correctly). The only thing to mention - it's better to take localPosition if you are using world shift.

    That's a point. I think I'll make a feature to exclude some objects using tags or layers or something.
     
  4. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Maybe simply make a public list for us to drag in the gameobjects that need shift, they actually won't be too many.
     
  5. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    I'm researching smaller terrains so that there is less lag when new foliage/etc *pop* in on new terrains... Currently I use 1024 size with 1024 resolution (I want 1 meter per vertex) I found these results though and they make no sense to me:

    Code (CSharp):
    1.    grid   res   fps    ram    tris
    2. 1: 2x2    1024  1030   1126   680k
    3. 2: 4x4    512   385    1133   2.2m
    4. 3: 8x8    256   84     1223   4.6m
    those are the amount of terrains in scene using mass pin, the terrain resolution, the fps on a stationary camera, the memory use of the editor in play mode, and the visible triangle count.

    Okay but...

    Code (CSharp):
    1. 1024x1024x2x2 = 4,194,304
    2. 512x512x4x4   = 4,194,304
    3. 256x256x8x8   = 4,194,304
    why is the vertex count doubling in play when they should all be the same?... we're talking about heightmap resolution of course... I don't get it? I must be missing something stupid here...
     
  6. AshyB

    AshyB

    Joined:
    Aug 9, 2012
    Posts:
    191
    I love this asset. If i have to use terrain in any game then I always use mapmagic. Cant live without it.
     
  7. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Is this forward or deferred?

    Remember that in deferred, and forward w/ depth, it does things in passes (col, depth, etc), and that when you go to 5 terrain textures (dirt + grass + cliff + rocks + sand, sand being the 5th here) it renders the terrain an additional time.

    Also doublecheck you were doing the tests at the same resolution. Unity terrain changes poly count based on screen resolution. I'm sure pixel error made sense at some point but it's a strange thing to debug and can easily catch you out now.
     
  8. AshyB

    AshyB

    Joined:
    Aug 9, 2012
    Posts:
    191
    Anyone else getting errors with 1.8.4? mmerrors.png
     
  9. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    I used the same camera throughout the test, the same pixel error, the same screen resolution, zero textures, one light. There are no changing elements between the different size other than the size of the terrains, the count of the terrains, and the resolution of the terrains. I even tried looking straight down at a small patch of... wait let me look at it in wireframe...

    the higher resolution higher size is still clearly creating way less vertices than the smaller terrains even though they are at the same distance... I'll try creating a flat terrain...

    Add: ok so I doubled the noise size for the 512 version as MapMagic doesn't compensate for that by default (I might be a version or two behind) and put them back to pixel error 1, and there is clearly higher LODs being used on the smaller terrains for whatever reason. Assuming the math being used here is exactly the same it should all draw out the same, but it's not... I'll keep playing
     
    Last edited: Oct 22, 2017
  10. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    malkere, I don't know exactly what were the conditions of your tests, but you've got the results so surprising that I wanted to check it myself:
    ResolutionSize.jpg
    With a pixel density 1 pixel per 1 world unit, and pixel error of 5 the triangle and vertex count is about the same for all of the cases, at least according to this monitor:
    ResolutionSizeMonitor.jpg
    And the result is not changing no matter I enter playmode or not (generate infinite terrain is off).

    I'm using Unity 2017.1.2 and MapMagic 2.0b. Maybe that is the reason? Got to try it with current MM version when I have time.

    AshyB, what were you doing when the error occurred? What is the top one error full text? It would be great if you could report a bug on the issues page and paste the error text and steps to reproduce it here.

    Thanks so much for such a warm words! I really appreciate it!
     
    malkere likes this.
  11. AsoraX

    AsoraX

    Joined:
    May 3, 2017
    Posts:
    22
  12. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    I'm on 2017.1.0 and MapMagic 1.8.3. I don't think it's MapMagic really... but I
    Thank you for looking at it Denis, it's clearly my fault. In part the min/max of the heightmap affects the chosen lOD according to a staff post I found. My original test was not fixing noise I blame that. I'm still running 1.8.3, I think you fix noise across resolution changes since then. I'll have to upgrade. Thanks again.
     
  13. YolanOTHER

    YolanOTHER

    Joined:
    Oct 23, 2016
    Posts:
    47
  14. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    You've got to apply CTS component to terrain only to set up the profile. Component should not be used on terrains in build or playmode. Here are the steps to apply CTS to MM:
    • Create a CTS profile with the standard way: create terrain, assign textures, add CTS component, create and apply profile (menu/Component/CTS/Create and apply profile), delete terrain;
    • OR: select already existing MM terrain, add CTS component, create and apply profile, remove component;
    • Create MapMagic object, open editor and add Custom Shader Output;
    • Switch Mode to CTS;
    • Fix all the warnings pressing "Fix" buttons;
    • In Custom Shader Output node / Material Template press Update Now;
    • Connect Custom Shader Output node layers to the other graph.
     
    ftejada likes this.
  15. YolanOTHER

    YolanOTHER

    Joined:
    Oct 23, 2016
    Posts:
    47
    I walked through all the steps above and now it is working. I missed two steps previously. Removing the cts component from the pinned tile and hitting the update now button.
     
  16. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    just updated to 184 and am getting at:
    control.Apply(updateMipmaps:true, makeNoLongerReadable:!enableReadWrite);

    this:
    UnityException: Texture '' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.
    MapMagic.MegaSplatOutput+<Apply>c__Iterator2.MoveNext () (at Assets/MapMagic/Generators/LegacyOutputs.cs:765)
    MapMagic.GeneratorsAsset+<Apply>c__Iterator1.MoveNext () (at Assets/MapMagic/Main/GeneratorsAsset.cs:553)
    MapMagic.Chunk+<ApplyRoutine>c__Iterator0.MoveNext () (at Assets/MapMagic/Main/Chunk.cs:246)
    MapMagic.ThreadWorker.CoroutineFn () (at Assets/MapMagic/Main/ThreadWorker.cs:604)
    MapMagic.ThreadWorker.UpdateApply () (at Assets/MapMagic/Main/ThreadWorker.cs:176)
    MapMagic.ThreadWorker.Refresh () (at Assets/MapMagic/Main/ThreadWorker.cs:143)
    MapMagic.MapMagic.Update () (at Assets/MapMagic/Main/MapMagic.cs:261)
     
  17. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Don't use the legacy MegaSplat Output, it's not supported anymore, use the Custom Shader Output instead.
     
    malkere likes this.
  18. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Thanks Denis, that was it.
     
  19. AsoraX

    AsoraX

    Joined:
    May 3, 2017
    Posts:
    22
    @Wright... Will there be a "Generate Terrain on GPU" option in one of the next Versions?
     
  20. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    I'd like to mention that not everything that run on GPU is automatically fast. I've made some experiments with the compute shaders and found out that it could be accelerated only with a flexibility loss - for instance, have to give up using multiple output connections. The reason I prefer multithreading to GPU calculations is that it fits dynamically generated infinite terrain better. GPU generating usually looks great in the editor, but in playmode, when GPU load is usually 100% it can squeeze graphics calculations and produce some lag. While in most cases the processor cores are not so loaded (maybe except the main unity thread), which allows to use them almost unnoticeable.

    MapMagic uses multithreading instead, calculating all of the generators asynchronously in a several separate threads, and just applies final the result in a main thread. Calculating terrain is mostly fast (dozens milliseconds per generator per thread) except some generators like erosion, which can take up to several seconds. All the generating runs in a background and creates no lag in game.

    PS: I'm currently experimenting with native C++ erosion calculation, this can speed up the most continuous generator.

    PPS: If you'd like to improve MM performance consider using smaller chunks with a smaller resolution (so that the overall terrain density remain the same). Calculating 4 chunks of 512 takes about 3-4 less time than 1 chunk of 1024 on modern computers, despite of the same terrain square and detail.
     
    Last edited: Nov 2, 2017
    malkere likes this.
  21. RoyArtorius

    RoyArtorius

    Joined:
    Jul 11, 2013
    Posts:
    73
    I'm debating on purchasing this. I've developed my own voxel system that I use for the terrain in my game, but I have no user friendly way to generate terrain for my system. I understand that there's some sort of plugin support and comes with source code, so it would be theoretically possible to use Map Magic to generate the data for my own system. My question is would this be a valid reason to purchase Map Magic? Or should I look elsewhere for a editor for my voxel system? (By the way, I'm not interested in VoxelLand. I'm extremely proud of my voxel system and to replace it would make my game feel, honestly, less special to me)
     
  22. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    214
    I have some questions about mapmagic and multiplayer. I'm generating an infinite terrain and due to the way the seed system works, I know that each client will see the same map which is good. However I would like an authoritative server to reduce the risk of cheating.
    I was thinking of running a headless server running unity under linux and on the server having a camera for each connected client (at least if they are located in different chunks). I am hoping this would force the server into creating the chunks around each of the client positions. So the questions are:
    Will mapmagic run under a headless linux server running unity?
    Will the idea of having multiple cameras force map magic to generate the correct chunks so the terrains around all players is available to the server?
    As there would be no graphical output, will the savings on CPU/GPU compensate for the need to keep say up to a max of 8 different views of the terrains and the relevant chunks active?
    Will map magic automatically know to only calculate a chunk once if there are multiple cameras in the same chunk or do I need to some how work out a way of disabling cameras?
    Assuming you think this is a workable solution can you think of anything else that needs to be taken into consideration or do you have any other suggestions?
     
    malkere likes this.
  23. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    219
    is there any way to get the current progress of the mapmagic generation? this would be useful to put a progress bar in a loading screen for our game which generates a random map each time you play.
     
  24. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    If you could make a tool that converts the heightmaps generated by MapMagic to your own voxel structure then MM could be worthwhile for you. You could run this converter in a custom generator, so it could be nicely integrated with MM. Anyways, you can try evaluation version before the purchase.

    I have not tested using MM this way, but I don't see anything that prevents doing that. MapMagic does not rely on any graphics feedback from scene. You can try using eval version (link above) to see if it will really work.
    MapMagic can use not just a main camera, but any object (or objects) with a specific tag to generate the terrain around (generate markers). When using multiple markers MM will ensure that the terrain is generated around each of the markers. Surely, if two or more markers located at the same chunk it will not be generated twice.

    I'm going to implement this in v.2.0
     
  25. Daniel-Talis

    Daniel-Talis

    Joined:
    Dec 10, 2011
    Posts:
    425
    Hi there, bought MM and have been exploring it and watching the videos. Reached the point where I am placing objects on far terrains. The 'long' video displays a 'hide far pinned' feature (in the general settings) but the version I have, version 1.8.4 doesn't seem to have it. Has something replaced it? Thanks.
     
  26. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    In the latest version all of the terrains are affected with Enable Range value, no matter if they are pinned or not. This was done to prevent a "floating terrains" effect of a pinned terrains visible while no terrain around them is displayed.
    Just skip this step, it has already 'hide far pinned' enabled.
     
    Daniel-Talis likes this.
  27. RoyArtorius

    RoyArtorius

    Joined:
    Jul 11, 2013
    Posts:
    73
    Excellent! I'll certainly give it a try! Thank you!
     
  28. Hurtful-Toad

    Hurtful-Toad

    Joined:
    Feb 18, 2016
    Posts:
    20
    I would like to export masks from the graph, but when I use "Preview In Window" it only displays the mask for 1 terrain. Is there a way to get a combined mask from all terrains as it is shown when you preview on terrain?
     
  29. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Each of the terrains use it's own maps, they are independent and not connected in any way. When you preview them on the terrain each chunk has it's own map applied. Combining maps in one is a tricky thing since you can pin any combination of the terrains - including pinning 2 terrains 10 or 100K units from each other. This way the combined map will have an insane resolution - and will be almost black.
    The other thing I'd like to say that using preview maps as heightmaps for other terrains is not a good idea (I don't know how are you going to use them, actually, but just to mention). Preview textures have only 8 bits per channel, this can result in a "stairs" effect. Obviously, preview maps were made mainly for the preview :). If you are going to use them as heightmaps you'd better export RAW data per-chunk.
     
  30. Nihilus0

    Nihilus0

    Joined:
    Jan 25, 2017
    Posts:
    52
    Hi, I bought MM and VL5.
    I only installed MM and VL5 in Empty(New) Project, but I got 230 Namespace errors.

    I'm not trying to use both MM and VL5 in a single scene.
    I want to use these alternately for each scene.
    However, they are making errors within the project.

    So I am looking for a way to install both MM and VL5 in one project.

    1. "Out of the box compatibility with Voxeland 5." Does this statement mean 'compatible'? I am a non-English speaker and use a translator. However, only this sentence is translated into contradictory content for each translator.

    2. The threads in the forums say plugins may be needed, but what plug-ins are needed? No matter what I looked for, there were no specific references such as download links.

    Ask for help on how to put both MM and VL5 in one of project.
     
  31. MakeGames2

    MakeGames2

    Joined:
    May 23, 2016
    Posts:
    82
    You have to get the Plugin Tools from https://gitlab.com/denispahunov/plugintools
     
  32. Nihilus0

    Nihilus0

    Joined:
    Jan 25, 2017
    Posts:
    52
    I can not find the download button on the link.
    Should I be approved? Or should I ask for it separately? Or else, do I have to authenticate Unity Bill by email somewhere?
     
  33. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Cosmoraph, you don't need to download anything, especially beta tools from GitLab.

    I don't know what causes this issue, but since it's not the first issue report of this kind I'm going to find out and fix it ASAP. The most vexing thing is that I can't reproduce it.

    For now here is workaround that theoretically might work:
    • download MapMagic from the asset store,
    • move MapMagic folder somewhere out of the Assets,
    • download Voxeland
    • return the MapMagic folder.
     
  34. SSL7

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    349
    How I get the absolute center of a terrain to an object output portal? I guess I use a scatter, but could I get the absolute center out of the scatter with density 1?

    edit: hmmm i think i got it. Square algorythm, density 1 uniformity 1 ?
     
    Last edited: Nov 9, 2017
  35. Nihilus0

    Nihilus0

    Joined:
    Jan 25, 2017
    Posts:
    52
    Thanks to your instructions, the problem is solved.
     
  36. nitoh

    nitoh

    Joined:
    Mar 20, 2014
    Posts:
    30
    Hi, I bought Map Magic, and I have a problem:

    I followed your tutorial about creating a city, everything working fine, except the Blob generator (that creates Sand), under the houses. The center of the generated Blob is not the center of the object that it based on. I highlighted the second Blob genereator that causes the bug. It would be great to fix this error, because everything else is just working fine!

    Thank you for your help!
     

    Attached Files:

  37. nitoh

    nitoh

    Joined:
    Mar 20, 2014
    Posts:
    30
    I figured it out. The terrain size / resolution caused it.
    It would be great to fix it in a way to work in smaller resolution too.
     
  38. MarkusGod

    MarkusGod

    Joined:
    Jan 10, 2017
    Posts:
    168
  39. Daniel-Talis

    Daniel-Talis

    Joined:
    Dec 10, 2011
    Posts:
    425
    Hi, been experimenting with importing raw maps into MM. When I tile an imported raw map, the edges of the map are not stitching. ie. I get the wall effect seen in the images.
    Any idea why things are not lining up. I'm exporting old terrains I have from Unity then back into MM. They look and load fine but like I said they just don't stitch evenly together.
     
    Last edited: Nov 10, 2017
  40. rmorph

    rmorph

    Joined:
    Apr 3, 2012
    Posts:
    87
    Hi I am trying to follow the tutorial for mapmagic and Voxeland integration I tried this but I'm getting the same error tha t others have been describing. originally just installing the two assets together didnt give me any Voxeland options under create new> 3d object.

    I then followed this instruction:

    And then at least I could get the "Voxeland static" 3d object.. so I can continue with the tutorial. While I do that however there are still hundreds of errors being reported as before so I guess this is not fixing the issue.

    I'm using unity 2017.2 with no other assets in the project apart from these two.
     
  41. totallylegitunicorn

    totallylegitunicorn

    Joined:
    May 11, 2016
    Posts:
    14
    Howdy All! I looked through this thread (I probably missed it) - could I use this asset to generate polygon landscapes? I have generating biomes / normal landscapes down but I haven't attempted the polygon variety and was looking to see if anyone else has and if they have a few quick tips.

    Thanks!
     
  42. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Yep!

    The problem with the low resolutions is that splat map information is located in-between the height pixels (vertices). Actually, this is the way all of the Unity terrains work, but on low resolutions it's visible the most. And since you can't say whether the generated map will be used in height output or texture output it's not possible to completely remove this issue - however, in v2.0 the effect will be less visible because of a slightly different way object generators work.

    Fixed, will be avaIilable in 1.8.5

    Daniel-Talis, is your raw image tiled (repeating itself in all dimensions)? You have to make it tileable similarly to the standard tiled texture.

    rmorph, what are these errors? Could you please post the first (top) one?

    Currently I'm not aware of any low poly shader 100% compatible with MM, but since MM use the standard terrains internally you can use any polygonal shader that works with the standard terrains - however, on pinned terrains only.
     
  43. Daniel-Talis

    Daniel-Talis

    Joined:
    Dec 10, 2011
    Posts:
    425
    Ahh, thanks that is the vital piece of information I was lacking. No, they aren't tiled.
     
    Last edited: Nov 11, 2017
  44. rmorph

    rmorph

    Joined:
    Apr 3, 2012
    Posts:
    87
    I reinstalled my Unity and re-downloaded the assets and I don't get the red alarms any more so the workaround is working for me now. The problem was probably in unity itself :)
     
  45. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    301
    Does MapMagic has the ability convert final terrains to meshes ( after all editing done ) so they can be work more efficent on mobile devices ? Even more convert to mesh ( keep copy of original terrains and restore later for more editing.. etc.. ) If the answer is NO, do you have future plans to add these features, which can be very handy and useful for vast majority of developers.

    Regards.
     
  46. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Converting terrains to meshes is out of the scope of MapMagic. There are special assets for that and I don't see any point in duplicating their functionality. You can use probably any of them with the pinned terrain (since the pinned terrain is the standard Unity terrain). If you have any suggestions on which of the terrain to mesh assets should be used in the infinite mode - feel free to share.
     
    MoribitoMT likes this.
  47. nitoh

    nitoh

    Joined:
    Mar 20, 2014
    Posts:
    30
    Hi!

    It would be great if anyone could help with my problem:
    Because of my limited C# knowledge i cant rewrite the Propagate generator, to face at the center (offset / or input) object.

    I knew that this must be just a few lines of code, because i can write it outside of the generetor...

    I hope anyone can help me with this, or just give me a few hints.

    Thank you guys!!!
     
  48. BlairTheDizzyWitch

    BlairTheDizzyWitch

    Joined:
    May 28, 2017
    Posts:
    5
    Hello,

    since I started a new project. Imported MapMagic, then imported Voxeland and MapMagic starts throwing errors with "namespace name 'xyz' not found. Are you missing Voxeland5 using directive?"

    Can anyone help me with this?

    Greetings.
     

    Attached Files:

  49. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Line 711 and further of ObjectGenerators.cs should look like this:
    Code (CSharp):
    1.                 //creating objs
    2.                 for (int n=0; n<num; n++)
    3.                 {
    4.                     float angle = rnd.CoordinateRandom(obj.id, n*2) * Mathf.PI*2; //in radians
    5.                     Vector2 direction = new Vector2( Mathf.Sin(angle), Mathf.Cos(angle) );
    6.                     float dist = distance.x + rnd.CoordinateRandom(obj.id, n*2+1)*(distance.y-distance.x);
    7.                     dist = dist*(1-sizeFactor) + dist*obj.size*sizeFactor;
    8.                     dist = dist * terrainSize.pixelSize; //transforming distance to map-space
    9.  
    10.                     Vector2 pos = obj.pos + direction*dist;
    11.                     if (pos.x <= dst.offset.x+1.01f) pos.x = dst.offset.x+1.01f; if (pos.y <= dst.offset.y+1.01f) pos.y = dst.offset.y+1.01f;
    12.                     if (pos.x >= dst.offset.x+dst.size-1.01f) pos.x = dst.offset.x+dst.size-1.01f; if (pos.y >= dst.offset.y+dst.size-1.01f) pos.y = dst.offset.y+dst.size-1.01f;
    13.  
    14.                     float rotation = Mathf.Atan2(direction.x, direction.y) * Mathf.Rad2Deg;
    15.  
    16.                     dst.Add(pos, obj.height, rotation, obj.size, id:obj.id+n);
    17.                 }
    Have not tested it though.

    I've fixed this issue, fixed version is currently on the review. Here is workaround:

     
    nitoh likes this.
  50. antony57

    antony57

    Joined:
    Sep 9, 2017
    Posts:
    28
    Hello.

    I am using it with CTS but when I enter playmode all the texture turn to black...

    Any idea how to fix it?

    Thank you very much!!

    a.