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

    Emiles

    Joined:
    Jan 22, 2014
    Posts:
    37
    Hi, I noticed that there was an update (1.10.7) which addresses MegaSplat. I'm wondering what was changed as i manually updated the mapmagic implementation of the custom shader megasplat implementation to correctly select top/bottom textures and work acros biomes.
    https://gitlab.com/denispahunov/mapmagic/issues/299
    i'm hoping i can just pull in your update.
     
  2. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    You can try using DiffChecker of CustomShaderOutput.cs. Here you can find the saved diff with the last file version. Just paste your code to the left to see the changes. I guess I did the same as you did - fixed top/bottom textures. Don't know about the biome issue, so thanks for the code, I will look into it a bit later.
     
  3. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,241
    I am loving MapMagic:)

    I want to have a slider to control grass distance, density etc. Normally I would just target the scene terrain, but with MapMagic they are dynamic.

    Can anyone suggest the best way to maintain a list of current map magic terrains in a scenene?

    I am thinking I :

    1. Set slider to choose distance
    2. Iterate over a list of currency active terrains in the scene and change the grass distance on each one
    3. Change the grass distance on the MapMagic object so that subsequent terrains are also generated with the new distance

    Does this sound like a good approach?

    IMG_6626.PNG
     
    MagiSoftworks and camta005 like this.
  4. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,475
    Here's the code I use for my settings menu. I hook up a slider using the inspector:
    Code (csharp):
    1. public void TerrainDetailDensity(float value)
    2. {
    3.     foreach (Chunk c in MapMagic.MapMagic.instance.chunks.All())
    4.     {
    5.         c.terrain.detailObjectDensity = value;
    6.     }
    7. }
     
    camta005, malkere and protopop like this.
  5. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,241
    Wow code too - thank you very much :)

    Do you think I need to change the map magic object setting itself too for subseqyentkx generated terrains? (as the player walks around generating more chunks, which I guess means terrains in MM?)
     
  6. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,475
    It seems to work across all terrains. My game uses the infinite terrains.
     
  7. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    I reference them when they come on via the callbacks since I'm engaging a lot of custom logic when they do anyway, then use the references all over my code, same thing though.
     
  8. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    protopop, you can use the code Stardog shared, but keep in mind that if you are not going to run it each frame then you'll have to change the MM's values too. So, yes,
     
    protopop likes this.
  9. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    249
    Will MM1 and MM2 be separate assets on the asset store?
     
  10. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    Yes, they will be two different assets. MM1 users will have a significant discount on MM2. Moreover, there will be a grace period - all who bought MM1 one month (maybe more) before the MM2 release will get it for free.
     
    Daniel-Talis and camta005 like this.
  11. HanAusBerlin

    HanAusBerlin

    Joined:
    Sep 13, 2017
    Posts:
    63
    Hi,
    are there any presets for different kinds of environments? Or can anyone of you share the ones you use?
     
  12. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    249
    HanAusBerlin likes this.
  13. HanAusBerlin

    HanAusBerlin

    Joined:
    Sep 13, 2017
    Posts:
    63
  14. HanAusBerlin

    HanAusBerlin

    Joined:
    Sep 13, 2017
    Posts:
    63
    Desert is deleted. And where do I need to put the nodes file?
     
  15. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,241
    If it helps anyone. I updated from Unity 2019.2.6 to 2019.2.8 and I use MicroSplat in map magic. The terrain was turned only 1 color - actually just one of my pinned terrains, the first one, was pink texture. I looked in my nodes and found that the Microsplat material I had assigned to my Mapmagic Custom Shader node was removed. I added it back into the slot and all is good. Just in case it saves anyone from freaking out:)

    After upgrade
    Screen Shot 2019-10-23 at 6.43.40 PM.png


    Fixed
    Screen Shot 2019-10-23 at 6.43.51 PM.png
     
    Wright, MagiSoftworks and camta005 like this.
  16. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    This graph was made by secondsight - he has to be somewhere on these forums. Try contacting him to ask for re-upload.
    You can import the nodes file by right-clicking somewhere in the graph window and selecting "Import" and then choosing that file.
     
    HanAusBerlin likes this.
  17. secondsight_

    secondsight_

    Joined:
    Mar 2, 2014
    Posts:
    134
    Hey,
    Didn´t realize it was still on my server, which I had to wipe a few weeks back. Will go through my projects and try to find it.
     
  18. patchworkx

    patchworkx

    Joined:
    Nov 8, 2014
    Posts:
    19
    heye `
    i`just had an voxeland terrain running .. but afterwards updating several times it`s just not workin somehow -- voxeland do not realice mapmagic is installed..-
    how i can tell voxeland that everything ids fine..--?
     

    Attached Files:

  19. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    Check you've got _MAPMAGIC_ enabled in Project Settings -> Player -> Scripting Define Symbols. If not - just add it after semicolon.
     
  20. Baum_Joshua

    Baum_Joshua

    Joined:
    Oct 5, 2013
    Posts:
    25
    Hello So I've been using MapMagic for a while and I encountered an odd situation. I was working with the Forest Generator and at one point my Trees were not scaling right. however when I removed the Forest Generator to start again I noticed a bunch of the trees have stayed and did not delete. Any idea how I can remove the trees without having to go into each terrain tile manually and remove them?

    The red square in the screenshot was where I had all of the Tree object files for the forest. notice the trees still in the scene after I deleted them from the MapMagic editor.
     

    Attached Files:

  21. Tsilliev

    Tsilliev

    Joined:
    Jan 21, 2014
    Posts:
    34
    When does map magic 2 comes out? 2020 Q1?
     
  22. Nerevar7

    Nerevar7

    Joined:
    Jul 31, 2018
    Posts:
    138
    Hi there! So I tried out the demo version and I really like what this does so far, but I am still very much a beginner both with Unity and this sort of tool so I just have some quick questions:

    1. I recognize that this seems to work for generating infinite terrains, but what about really large terrains that are only generated once? I'm referring to something really really huge, like say 2,000 sq km. Could I generate that, limit it's size to that, and then save it so it's always the same 2,000 sq km map?

    2. I've read Unity has issues with floating point limitations and this tool seems to get around that by moving everything to the origin, which is great. Having said that, would there be ways to instantly travel to a far off chunk with this system turned on? Let's say I want to move to a chunk that would normally appear on the X axis at around 4000 but my floating point settings are at 1000. Is there a way map magic can move me to a far off chunk of terrain in that 2,000 sq km map?

    Sorry if these questions are not clear enough, I just really want to make sure this tool is the one I need, and thanks in advance for the answers!
     
  23. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,475
    How can I get the number of objects a generator outputs? Such as the amount of scatter points, or propagate points? I need it for runtime, not just preview window.

    I have this code so far:
    Code (csharp):
    1. foreach (var result in MapMagic.MapMagic.instance.Results())
    2. {
    3.     var _propagate = MapMagic.MapMagic.instance.gens.list[25] as PropagateGenerator;
    4.  
    5.     object objsBox = _treePropagate.output.GetObject<object>(result);
    6.     SpatialHash spatialHash = (SpatialHash)objsBox;
    7.     Debug.Log(spatialHash.Count);
    8. }
    I get null reference error on the Log. I tried a few other ways based on PreviewWindow, but I can't figure it out.

    Also, how to regenerate only propagate/scatter at runtime without generating entire terrain maps, like it happens in graph? For example, trees can regenerate position without chunk disappearing.
     
    Last edited: Nov 6, 2019
  24. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    My game does that, definitely possible. You may need to write a few extra lines of code yourself to get things working perfect for whatever you scenario is. I think by default MM tries to make one "shift" movement per frame, I had to change it to figure out how many shifts it needs to reach the intended destination and apply them all at once, for example.
    You can't have a 2000km single terrain though, that's not smart for many different reasons. MM uses "chunks" that you can load/unload dynamically. But for anything bigger than 5km or so you REALLY want to go procedural, hand-painting stuff that big is just a bad idea, and that's really what MM is designed for. I use 1km chunks and I have players that have reached 1,000,000 kilometers.
    MM uses deterministic noise, so it's always the same so long as you give it the same seed. It doesn't use "random" numbers to generate things. So my 2,000,000km^2 gameworld is always the same (for their seed) no matter where a player goes and I only have to save anything they change.
     
    camta005 likes this.
  25. Nerevar7

    Nerevar7

    Joined:
    Jul 31, 2018
    Posts:
    138
    Thanks for the reply! Let me see if I can clarify myself a bit more:

    I wasn't really planning on hand sculpting the whole thing, but I was wanting to limit it's size to something huge like 2000 km^2. I'd likely make each chunk 1km^2 though, what I don't want is for it to keep going past a certain point, because I want to make a map that the player opens up that represents the world, and when they click on a location on the map, they can go there, say maybe 1000km away from where they were.

    Hopefully that's a bit more clear, I don't want the player to just be able to keep walking until the engine stops working (like Minecraft). Rather I want to represent a huge landmass as a map and have MapMagic create the terrain.

    Not sure what you mean by the shift movements, but like I said, I just started working with the demo version so I'll explore a little more. Thanks again!
     
    malkere likes this.
  26. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,121
    Not everything is built-in to Unity or MM, but with a little C# and determination you can do anything. You can certainly limit the world to 2000km and a map to click and go would work just fine too, I've been wanting to make something similar for a while. To avoid floating point precision errors you need to stay near the world zero. This is a problem of the physics engine (almost all physics engines), not MM. It does the normal approach to solving that problem of just grabbing everything and moving it back say 4000m everytime the main camera passes 4000m then pretends it's at 0, 4000 so that it spawns new terrains in the proper locations. By default (again, unless this has changed recently) it makes that 4000m (or whatever you set the threshold to) "shift" once per frame. If you want to go out to 1,500km then it needs to make 375 shifts, so you'd want it to do that all at once instead of over 375 frames. Little things like that you might need to adjust, but again with C# you can do whatever you can think of.
     
    Nerevar7 likes this.
  27. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,475
    Anyone know a decent setup to allow distant terrains to be loaded, but without gameobjects for a large view distance? Unity terrains seem fast enough to have at least 3x3 loaded at a time, but not when there are thousands of LoD/culled gameobjects parented.

    I'm thinking about using a second terrain that uses a similar graph, but with all trees/details deleted, and pre-pinned. Then when I reach the 'threshold' just disable that terrain and allow MM to load the real terrain fully. Or maybe set the MM dynamic terrains to only draw trees/details... I will try it out.
     
    Last edited: Nov 25, 2019
    protopop likes this.
  28. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    So now you have no tree output in a graph - and MapMagic affects only that terrain data it can change. This way all of the trees remain intact, like if they were placed manually. To remove that tree data simply unpin the terrain and pin the new one at it's place.

    At least I plan so. Probably I will release the public beta version (some kind of evaluation version) in December.

    The point of generating the land on the go is that you don't have to keep all of your 2000 square kilometers terrain in memory or load it by batches. If you are using resolution of 512 and just 4 texture channels each sq km will take 2,357 Kb, that leads to overall terrain size of nearly 5 Gb. Not an overwhelming size for the modern games, but the point is that you can't change each and every terrain chunk by hand, so why don't leave it generating automatically? And you will need some streaming solution anyways if you want to use 5 Gb terrain data...

    I see no problem in instant travelling with moving origin (it will just offset the world before rendering the frame), but I'd like to warn you that if you are jumping to non-generated terrain you've got to wait some seconds before the terrain will be created - maybe using some effect the way it's done in GTA.

    That's who I call the real explorers!

    I'd like to recommend you to limit the player movement with scripts or collision rather than with MM. Just let MapMagic generate the background player can't reach, it will look more natural than allowing to see the edge of the world.

    Unfortunately I don't see an easy way to implement this. It was one of the main reasons I've started MM2. I'm afraid you can't have two MapMagic objects in a single scene by design. However you can try keeping one MM script disabled all the time - and enable them alternately on player position change. Not an elegant solution and I doubt it will work out of the box, but at least worth trying.
     
    protopop and malkere like this.
  29. HanAusBerlin

    HanAusBerlin

    Joined:
    Sep 13, 2017
    Posts:
    63
    Hi,
    I am using the island demo scene with a grass script (assetstore) that uses spawners dependent on a texture. So therefore I need the textures to have a opacity of 100% with very little transitions (because if theres just 1% of an texture mixed into another substraction wont work). I tweaked the settings but with no sucess. Any idea?

    And another question: I need to tag my terrain. But whenever I preview it, Map Magic keeps resetting it, which is very annoying. Any way to fix that without deactivating the map magic script?
     
  30. UnconventionalWarfare

    UnconventionalWarfare

    Joined:
    Jul 11, 2019
    Posts:
    17
    Hello,

    we're seeking to replace our current procedural terrain solution with something better. I stumbled upon this asset and was quite impressed by the demo, which made it look like Map Magic would be a great fit.

    But I have some questions first. I want to know how well it would work for our specific use case.
    We aren't creating huge terrains, but only small patches where you fight. As you can see on the attached screenshots, they aren't big at all. You can walk across in under a minute and they aren't complex either. Think of them as randomized arenas for combat.
    Terrain_1.png Terrain_2.png

    We generate a small navmesh on top using Unity's NavMeshComponents. These only have to be generated once at the start of the level and with how small the levels are, we found that performance here isn't a problem.

    What we want is pretty much what you've seen above (maybe with a little more fidelity), but with more terrain surrounding it (so you can't see the edges) and faster; a lot faster. Performance is the main problem we have right now.
    Would you mind creating a Linux build of the demo (with the mountains)? I ask, because the slowest device we have available for testing is an old laptop with a slow Nvidia GPU running Linux. I'd like to know how quickly MM generates terrain on there. The fact that MM runs a lot faster than our current solution on my machine doesn't matter all that much, because my machine can brute force it.

    Also, how different will MM2 be from MM1? If we were to choose MM, we'd wait for 2 since we time for that. I want to have a look at the evaluation version of MM1 in meantime, but won't if you say that it's drastically different. (I wouldn't want to waste too much time, because I have tons of other matters to tend to.)

    Thanks.
     
  31. roboshark

    roboshark

    Joined:
    Dec 19, 2016
    Posts:
    1
    Hi, @Wright , I am running into an annoying crashing issue with the MapMagic Editor.

    I can't be sure if it's the Unity version or the fact that I'm on MacOS, but it seems once I add a certain amount of generators the editor starts crashing. Sometimes when I just click on it after coming from another window, or at other times once I try to add a new generator, or make a change to an existing generator.

    Tonight I ran into this again, while trying to edit a 6x3 map, using terrain size of 1000. I have the resolution at 512 and terrain height at 600. I have 6 generator and 4 curves, and no objects or even textures yet. It just crashed and then crashed twice right after re-starting Unity and opening the editor and just clicking on it, even after I lowered the resolution. Basically now I'm unable to continue working on the map.

    I'm on MacOS 10.15 and using Unity 2019.2.11f1

    Any suggestions would be welcome

    Thanks
     
  32. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    You can make all of your maps contrast before assigning them in Textures output node. You can use a curve node with a curve like this:
    CurveContrast.png

    That's exactly what the evaluation version is for. Feel free to use it to create the terrain of the size you need and test it under your target or minimum platform.

    It will be similar to MM1 in basic concepts and general workflow, but very different under the hood. Speaking of performance I can say it will be no way slower than MM1, so I guess it's worth trying evaluation anyways - in case you will be happy with the MM1 performance.

    6 generators is almost nothing, it should not be a problem. I guess you could link them the way they are creating infinite loop. However there should be a safety catch to prevent doing this. Could you please post your graph screenshot (or email it to me - both graph+screen)?
     
  33. UnconventionalWarfare

    UnconventionalWarfare

    Joined:
    Jul 11, 2019
    Posts:
    17
    It says that the evaluation version cannot create builds, so testing is going to be a bit difficult with as bad as that laptop is. On top of that the Linux editor was in a bit of a sorry state last time I tried it out.
    But I'll just try it out. Thanks for the response.
     
  34. jebediahh

    jebediahh

    Joined:
    Feb 20, 2017
    Posts:
    23
    Hi - When I'm using output->grass, I can't get it to draw past about 50 units or so... I've tried adjusting the setting in the mapmagic gameobject - under details settings.. it's maxed at 250 there. What is the method for drawing billboard grass or prefab grass and being able to increase the view distance out past 40 or 50 units?
     
  35. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    Oh my bad, I totally missed that thing. Yeah, it will not allow to create a build. Please email me if you want to try non-evaluation version.

    It's hard to say for sure what causes this problem without seeing a screenshot, but I've got a similar problem once - the grass wasn't displayed because of the alpha filtration on the mipmaps - they just went below alpha ref value and the grass became invisible. Try filling alpha with white - for test purposes, of course, just to see if the problem is in it.
     
    UnconventionalWarfare likes this.
  36. UnconventionalWarfare

    UnconventionalWarfare

    Joined:
    Jul 11, 2019
    Posts:
    17
    I appreciate the offer, but I made it work by editing the demo project to be less resource intensive. The CPU efficiency of MM is quite impressive even on that junk hardware.
    We're going to buy a license and switch to it when MM2 becomes available. There are still plenty of other things on our todo list so we're in no hurry to switch immediately.
     
    protopop likes this.
  37. Giantsmall

    Giantsmall

    Joined:
    Apr 28, 2019
    Posts:
    6
    1. I have a problem with waiting for MagicMap generation to finish.
    The only way it works for me right now is call Generate(true) and see as Terrain changes after couple of seconds.
    But catching in script the moment generation ends does not work so far.
    Creating loop checking MapMagic.instance.IsWorking goes infitely, ang mapMagic start generation only when I exit that loop.

    I think I need some threads/coroutine tutorial.. anyone?
     
  38. Nerevar7

    Nerevar7

    Joined:
    Jul 31, 2018
    Posts:
    138
    Hello! Maybe this is a dumb question but can I use a heightmap image to generate a terrain based on that image with Map Magic?

    If so, can I adjust the size of the area that is generated with the image? That is, if I want the heightmap image to generate a single chunk vs maybe a 4x4 area of chunks.
     
  39. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    249
    Yes you can use the Raw Input generator and edit the scale if you want it stretched over multiple chunks.
    https://gitlab.com/denispahunov/mapmagic/wikis/Map_generators/Raw_input
     
    Wright likes this.
  40. Nerevar7

    Nerevar7

    Joined:
    Jul 31, 2018
    Posts:
    138
    camta005 likes this.
  41. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    Rather odd that IsWorking doesn't return true. The rotating generate icon in a toolbar uses IsWorking internally. Does it ever changes with the green complete mark?
     
  42. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,241
    Thank you - that explains a lot:) I think also force regenerating the terrains will remove those extra trees.
     
  43. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,241
    Until MM2 arrives I am thinking of creating. GridManager.cs script that tracks all off the currently generated terrains (I already track them to change options like grass density across all terrains - see above). the I could track which terrain I am currently "on". I could use a timer to intermittently, lets say every few seconds, check to see if I've switched to a new terrain. As a post process after a train has generated, if im not on it, I could set the details low manually - like no grass or limited trees or low pixel detail etc. This way "distant" terrains will be lower detail and less pressure presumably. I advent done it yet bt im going ti give it a try:)
     
  44. MorpheusXI

    MorpheusXI

    Joined:
    Jan 18, 2018
    Posts:
    47
    Thanks for info. Would be superb if Mr Wright integrated this feature into MM, I know there's a Voxel map creation tool that is procedural and has builtin NavMesh generation.
     
  45. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,475
    I don't get what his post means with regards to "100 AI making their own Navmesh". NavMeshComponents already seems to do what he describes.

    You just put the NavMeshSurface script next to MapMagic, then for 'Collect Objects' choose 'Children'.
     
  46. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    That's right, NavMesh can gather child objects. However it's still not immediate and take some time to generate, so I recommend using realtime pathfinding when possible, using waypoint navigation, collision detection and steering behaviors.An open terrain is not a maze, so in most cases it should be enough. However, for pinned terrains that can have some complex POI like villages or cities a manual navmesh could be created with the standard tools.
     
  47. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    975
    Can I apply Map Magic to an existing terrain?
     
  48. DropNodes

    DropNodes

    Joined:
    Jun 11, 2019
    Posts:
    36
    Is there a way to not having these "freezes" when the terrain is created on runtime? I get some frame skips on very good PCs, I have it on max generate time 30", and it generates it much fast so it's not like it reached the max time so it pushed harder. Do I miss something?

    So my issue is not the time that the map is generating, but the spikes at some points, I would prefer longer generation time without the spikes.
     
    Last edited: Nov 28, 2019
  49. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,674
    It should be the terrain apply spikes. Splitting in smaller chunks (lowering chunk resolution and size) should help.

    Hmmm... no. But how do you see it?
     
  50. ANUBISKONG

    ANUBISKONG

    Joined:
    Nov 16, 2016
    Posts:
    32
    Suppose I have selected the area I want to modify with level select. How can I lower the altitude of this area?
     
unityunity