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

    RandomDevil

    Joined:
    Dec 15, 2016
    Posts:
    11
    You were correct, Wright, it was an infinite loop, but it was one that took me a while to find. It was because I was doing a scatter > slide > adjust > flatten, and the slide uses a height input. I guess, because of this, you just can't use slide with a flatten.(?) It's working well enough now to be usable, I'm just having to get creative to get the result I want.

    Also, Wright, I have my team working an NDA for you so we can talk about getting some direct support. Thanks.
     
  2. siblingrivalry

    siblingrivalry

    Joined:
    Nov 25, 2014
    Posts:
    384
    Sorry i posted this in the wrong thread before:



    The pinned terrains and procedural terrain logic looks great,

    * Can players build houses and place objects on the procedural terrains?
    My concern is that when the players leave the terrain and come back to it later, the objects will still be there.

    * Can AI move from one terrain to another without a human player near or on the same terrain tiles?

    Thanks.
     
  3. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Ai and runtime placed object will have nothing to do with the terrains. If they are parented to the terrains they will probably get wiped when a player goes too far away and the terrain gets recycled, but you don't have to parent them to your terrains. I do, but I save them long before the player gets far enough away for the terrain to get recycled.

    AI is the same. Colliders exist or they do not. The script is active or it is not. They don't specifically care whether a terrain or a player exists unless explicitly programmed that way. If the collider is removed while the AI is still alive it might fall though.
     
    tanoshimi likes this.
  4. siblingrivalry

    siblingrivalry

    Joined:
    Nov 25, 2014
    Posts:
    384
    Thanks
     
  5. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    I wonder if I could run a second instance of mapmagic in an asyncronous scene...
    edit: well that didn't work... trying to bypass the global instance and operate two instead...
    eidt2: woo hoo! looks like it's working.. I'm storing two separate instance of MapMagic (after disabling the disabler) and reassigning them to the namespace instance per Update when/where they start to perform their operations. With different saved graphs I've got two entirely different instance operating simultaneously... time to see if I can get more creative and plug it into a "realworld" sitation ;p

    edit3: grrr the threads all bump heads when the calculations aren't instant... back to the drawing board
     
    Last edited: Feb 25, 2017
  6. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    @Wright I have a question about the biomes feature.
    If I use different custom shaders for each biome, will the final terrain that blends biomes together able to recognize every shader for each biome? Or should I use only one custom shader for all biomes?
     
  7. SayhiUnity

    SayhiUnity

    Joined:
    Jan 7, 2017
    Posts:
    10
    why there is no snow on your tree, go to work hahahaha
     
  8. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    I got multiple instances running in one scene by just making sure only one is ever enabled at a time. You have to watch out for thread conflicts too because of the namespace usage. I can be more specific if anyone cares, I doubt it though ;p

    I also go a zero point shift to work. I have a global offset Vector2, and I use that to offset my custom noise, and to intercept the chunk - camera distance calculations so that the MapMagic matrix moves with it. I can be more specific with this too if anyone cares =D
     
  9. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    I'm using RTP with Biomes. Once you load up RTP with 8 textures, those same 8 textures appear in each instance of the RTP node in MM. I have one in each Biome. I usually like to use a mix of 2 textures per biome with Noise to break them up. Mixing textures with RTP is very effective. You end up with new textures because to the way RTP height blends.

    I haven't had any problem with the 8 texture limit. I'd rather have 8 RTP textures than 256 flat textures any day.
     
    trilobyteme and malkere like this.
  10. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    thx
    for the reply, I'm having 11 biomes in total for now, and this number will get increased. I'm using 4 textures for universal textures use, and 1 texture for the specific biome, it's brilliant to use RTP's mix texutre function to create new texture, I'll try it, but the 8 texture per world is just a big limitation to my game. I actually don't need 8 textures per terrain tile, for my game world is huge, but the total textures should be used in the whole game is definitely more than 8, and this number will increase if I add new biome into it.
    But I found another light weight solution for my problem, a shader uses texture's alpha channel for the height map. It can not have smoothness effects but still can height blend the textures and have no limit on the number of textures.
    It doesn't have triplanar, UV blend, parallax effects, but I'm thinking adding these functions into this shader by myself, and even add the smoothness slider for the overall smooth control of a texture, it'll be enough for my game.
     
  11. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    I'm planning 22 biomes for my current map. I know that seems like a lot, but each is quite small. My map is 16x16km, which is massive in game terms, but geologically quite small. There is not much variation in soil type or rock type in a terrain this size. I understand if you are making a fantasy game you might want more variation. I'm making a simulation that aims to be as realistic as possible. As far as realism goes, it's hard to walk away from RTP.
     
  12. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    In my game, there also doesn't have many rock variations, 1 for cliff and another for cavity, but there are several grass variations, 2 green, 2 yellow(I can use the mix textures function to mix them into one for each color), at least 1 swamp texture, 1 mud texture for the red wood forest, 1 leaf texture for mountain forest, and 1 dark stone texture for volcano biome, besides the beach and wet sand textures for my game is set to islands. 8 is just not enough. Do you have any ideas to scale the number down?
    And I also found a problem using MM with RTP, is that if I use 4 layers in 1st pass, the add pass textures will always be black, but they are normal when I add RTP directly to an isolated terrain. any ideas about this issue?
     
  13. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Jason is currently working on MegaSplatOutput that will apply MegaSplat to procedural terrains, and I'm trying to help him as much as I can. But we decided to aim straight for the upcoming MapMagic version (the one that will be Voxeland-compatible). This version will bring a lot of change and simplify layer system a bit, so I think it's better not to spend time creating this generator for both current and new MM. However the new version will be released in a month or so.

    They can, but any changed terrain should be pinned and locked to prevent it's re-generating and removing of all the changes - and since it happens in playmode pinning should be done with a script.

    You can use AI characters as an additional generate centers using tags. MM will create terrains around them the way it creates land around main camera, and this can make them move seamlessly between terrains. But keep in mind that that any NPC could not be such a "wanderer" - in this case MM will generate all the terrains with NPC at once. So I'd like to limit most of the NPC's movements with one terrain tile.

    malkere, MM is using singleton pattern. It has it's advantages and drawbacks, and the main flow is inability to use multiple MM objects in one scene. I assumed that since the terrain has no limit there's no point in having multiple infinite terrains in one scene.
    If you always have one MapMagic disabled you can switch between them by assigning MapMagic.instance = mapMagic1.

    Terrain shader is used for all of the MapMagic chunks, it's not changing with biome.
    Dorian-Dowse, Harekelas I'd like to stress that Jason and me are working on MegaSplat integration. Take a look at this asset, it's really awesome and bet it's worthy alternative for most of terrain plugins. And it supports up to 256 layers. In a single pass.
     
  14. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    I think it depends on the textures and mode.. this is Megasplat with RDT textures upload_2017-2-27_22-22-10.png

    Does this look flat? There is a noise & height blend feature in Megasplat as well to make texture combinations, whatever you like.

    The mountain in the background hasn't been worked on yet.
    There is only one mesh for the terrain- there are no other meshes on it.
     
    ftejada, pixelsteam and malkere like this.
  15. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    Yeah, I watched the video Dennis linked above. Megasplat does look pretty good.
     
  16. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    @Wright So glad to hear that megasplat is going to be intergreted with MM!! And voxeland!!
    I've always wanted to make my game world voxel, always waited the combination of MM and Voxeland, if this can add megasplat together, it'll be absolute awsome!! Look forward to it!
    Take your time and do the most amazing works like always ;)
     
    ftejada and Ascensi like this.
  17. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    Is there a work around for the giant forests? I'm using speed trees. If I have scale enabled on the tree output, and use a forest, I end up with trees that are kilometers high. I can turn scale off, but then all the trees are the same size. Rotations don't seem to work with forests either.
     
  18. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    312
    Hi,
    What is the latest version of Unity that works with MMWG ?
    5.5.0f3 don't work
    Thks
     
  19. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    Yes it does. What "doesn't work" for you?
     
  20. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    stigmamax, 5.5.0f3 is my current Unity's version (I just port MM back to 5.2 for final tests and upload). All of the recent MM releases were created with 5.5. And as far as I can see it works fine here. What is wrong with it, does it logs any console error?

    Dorian-Dowse, you can use Adjust Generator to scale objects down, just set Scale range to 0.01-0.01 to make trees height be somewhat dozens of meters instead of kilometers.

    Harekelas, Thanks! That's really encouraging!
     
  21. TQA10

    TQA10

    Joined:
    Mar 2, 2017
    Posts:
    1
    Hi. I am new to Unity (as in never ever used before) so sorry if my questions seem obvious. I want to make a procedural open world game (Yes, I know this is extremely ambitious.)

    What would be some ways to implement a procedural cave system that would work fluently with this terrain generator? My main idea was to make cave section meshes that could be linked together and somehow implement those.

    Could the trees/rocks for this be 'harvested'? As in cut down and gathered by a player?
     
    DesertRaven likes this.
  22. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Unity terrains cannot have caves as they are only 2D. You can use RTP to create invisible patches and turn off the terrain collider when entering it to "go through" the terrain into a cave. RTP creator has a youtube tutorial on that.

    Creating procedural caves is easy as long as the ends match up. Start by just trying to generate using room prefabs made of up primitive cubes in 2D to figure it out.

    Rocks and plants are a lot easier to make harvestable than trees, you just add some scripts to them. Trees become a part of the Terrain and use it's collider instead of their own. There are plenty of solution designed just for that though if you search for them.

    MapMagic is a mostly just a tool for creating badass terrains.

    Make sure you start out simple and add complexity as you go or you will never finish anything.
     
    tanoshimi likes this.
  23. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    The next version of Map Magic will include Voxeland support, which does allow caves.

    Check out
     
    DesertRaven likes this.
  24. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    @Wright i post the video here too as you said :p

     
    ftejada and pixelsteam like this.
  25. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Great video! I have been challenged with creating the biomes...is there a good video on how to do this?
     
  26. Elzean

    Elzean

    Joined:
    Nov 25, 2011
    Posts:
    584
    Hey thx :)

    This video should help you with biomes:
     
    Mr-Logan and pixelsteam like this.
  27. Sussifix

    Sussifix

    Joined:
    Dec 1, 2015
    Posts:
    9
    MapMagic is really an impressive asset. Thanks for that!

    I have two questions btw:
    1. Is it possible for the future, that the menu points are in alphabetic order or that the user can change the order? ( I am searching all the time ^^)
    2. If is possible, will be in future maybe a tutorial how to make a world during runtime? (That the player can choose values or seeds?)

    Greetz
     
  28. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    @WPG_Member you just have to input the MapMagic.Instance.seed to change the global seed. That has to be done before generation of course. I store it in a static variable that gets set on creating a new game, then when the scene is loaded it sets that as the seed.

    @Wright how do caves work in Voxelland through MapMagic? Will that be a special 3D generator?
     
  29. Sussifix

    Sussifix

    Joined:
    Dec 1, 2015
    Posts:
    9
    @malkere: Ah, thanks for fast answer!
     
  30. IndyGeek

    IndyGeek

    Joined:
    Mar 5, 2017
    Posts:
    2
    Looking for advice on how to create the horizon terrain that players will never reach. I don't really like the SkyBox technique but I haven't found a good tutorial or tips on creating the horizon in MapMagic. I am really impressed with MM just not greatly experienced, yet.

    I should add, the terrain is mostly mountainous.
     
  31. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    I've been using HorizonON for this. It works quite well on single terrains but not so well with streaming terrain.

    With map magic I'm trying a different approach. I'm using a RAW height map with a 16x16 terrain. I also make a separate Unity terrain and scale it up to 16000x16000, and apply the same height map. This second terrain is then placed a few meters below the MM terrain. It is then used as a distance terrain. As you approach a border the next MM terrain pops and covers the underlying terrain. With the right textures and some atmospheric scattering it should work.

    It won't work if you're entirely generating the height map in MM.

    What would be cool is if you could set independent generate distances on terrain/textures and trees/grass/objects. This way you could generate terrains much further away for distance viewing, then add the terrain objects when you get closer.
     
  32. txarly

    txarly

    Joined:
    Apr 27, 2016
    Posts:
    197
    hi, hope you can help me

    what should the best way to mix 4 biomes the way the screenshot below?
    thinking that the white biome will be the higher one (snow) and the darkest gray the lowest height, lets say in 1000 mt height, whith chunks of 1000x1000 or 2000x2000.

    thanks
    biomes.png
     
  33. IndyGeek

    IndyGeek

    Joined:
    Mar 5, 2017
    Posts:
    2
    Thank you, Dorian-Dowse. I will give the dual terrains a try.

    The horizon terrain was a bullet on the list of features when I purchased MM, so I was hoping there would be an easier in-product solution. Maybe in the next version, which I am excited to try out the road creation ability.
     
  34. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    I'm afraid that sorting in alphabetic order will confuse those users that used to work with MM and familiar with the current sorting. I'll think about an alternative sorting, but cannot promise that it would be possible.

    Since I've got many requests for "How to make my scene unique each time I start the game" I'm going to make "Start with random seed" toggle that will change the seed on playmode start (and turn itself off to avoid changing seed on further scene load).

    Nope, but caves will be still possible, as well as floating islands and other 3D structures. Voxeland Output is using layered structure with layers of different types (sort of 3D blend-modes). One of the modes allow to "carve" caves in the terrain using layer thickness (i.e. cave cell height) and height (i.e. cave floor absolute elevation) maps.

    Pity I cannot make a screenshot to illustrate what I'm trying to say - I've encountered an error when I've tried. Yap, there are still errors :) I will post screenshot once it's fixed.

    Dorian-Dowse, IndyGeek, I have far LOD chunks feature in my to-do list, but I've got to finish Voxeland first. I plan to generate far terrains with a lower resolution and without Objects and Grass outputs - not sure about Trees output thought. I've made some experiments with this feature, I can say that it's possible, but it has to be complete and polished.

    txarly, you can use something like this grpah. Note that Normalize Generator is working in Layers mode.
     
    ftejada likes this.
  35. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    That makes sense though, layered heightmaps. I'll bet with features capable of doing that we could hack in some vertical calculations to make infinitely descending caves =D
     
  36. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    For me personally, it wasn't so much starting with a *random* seed that was a problem, it was setting a custom seed at runtime (such as the world seed from a saved game, say) and passing that to MM before it had started to generate using the old seed. Otherwise I was getting the "synchronisation" errors described earlier in this thread.

    I have a current solution that seems to work by setting the number of allowed MM threads to 0 on Start, then setting the seed, then setting the number of threads to a normal value to allow it to start generating, but something a little less clumsy would be nice!
     
  37. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    You can use mapMagic.ForceGenerate method - it will make terrain re-generate after seed change:
    Code (CSharp):
    1. mm.seed = newSeed;
    2. mm.ForceGenerate();
    Or you can start with a disabled mapMagic object, and enable it once the seed is set in your script's Start method:
    Code (CSharp):
    1. void Start()
    2. {
    3. mm.seed = newSeed;
    4. mm.enabled=true;
    5. }
    Personally, I prefer the second approach since it works both in multithreading and non-multithreading mode: it does not start unneeded old-seed generate on scene start that will be erased with ForceGenerate.
     
    malkere likes this.
  38. Stanchion

    Stanchion

    Joined:
    Sep 30, 2014
    Posts:
    269
  39. dreyn74

    dreyn74

    Joined:
    Mar 10, 2017
    Posts:
    14
    How do I export the map datum? Height,Splat, etc...
     
  40. Dwight_Everhart

    Dwight_Everhart

    Joined:
    May 11, 2014
    Posts:
    123
    I'm using Map Magic with Unity 5.6's runtime navmesh. It works well, except everything generated with the Trees node is not taken into account when the navmesh is generated. The terrain is, and anything generated with the Objects node is, if you've added the Nav Mesh Source Tag component to the prefabs. You also have to add that component to the MapMagic object, so it will be copied onto generated terrains.
     
    Last edited: Mar 13, 2017
    malkere and tanoshimi like this.
  41. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    dreyn74, since MapMagic uses the standard terrains, it is possible to export heightmap data by clicking "Export RAW" in each of the terrain chunks settings. Exporting splat maps will require some scripting, this seems to be a solution at first glance.
     
  42. operator23

    operator23

    Joined:
    May 17, 2013
    Posts:
    14
    1489286021.jpg Biome errors in 5.5.0f3 and latest version from asset store:
    Trying to recreate the biome blending video and I get this error upon connecting the constant up with a single biomea) (demo data). Any ideas?
     
  43. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Odd thing, I can't reproduce this error in Unity 5.5.0f3 (neither in 5.2.1). Actually, you've got 4 "Generate thread errors" - could it be that they happened at some graph state before? Do you remember the sequence how you created each of the generators, set value parameter and assigned data? Could you please note at which step the error occurs? And the most important thing - could you please paste "Generate thread error" description?
     
  44. operator23

    operator23

    Joined:
    May 17, 2013
    Posts:
    14
    Sure. No errors through removing any the default node groups, nor when creating either constant or biome. The errors occur only when assigning a biome. Depending on if the constant is connected at the time a biome is selected determines which of these two errors I get:

    If I select a biome with the constant connected, it throws this error:
    1489348036.jpg

    If I select a biome (island or demo) without the constant connected, I get this error:
    1489347862.jpg

    Hope that helps...
     
  45. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Something is wrong with generators list in your biome data. Do island and demo scenes work? Can you open the scene and call "Force Generate" here - will it log the same error?
    It seems to be that the data in your demo scenes is currupted. Were you making something unusual with .asset files like importing to older Unity versions?
    Anyways, you can try to perform a clean install of MM with removing the older version - this should resolve the problem - I'm just curious about the cause of it to prevent it in further versions.
     
  46. operator23

    operator23

    Joined:
    May 17, 2013
    Posts:
    14
    I tried your clean install suggestion, but errors returned. So I tried a new project with just the Map Magic package and got an error on starting the project : Recursive Serialization is not supported. You can't dereference a PPtr while loading. (Constructors of C# classes may not load objects either. See stacktrace.) So, I Googled that error and came up with these steps which ended up fixing the issue:

    1. If Map Magic is open, close it
    2. Delete the Map Magic folder entirely
    3. Reset the window layout of Unity (key step!)
    4. Install the new version of Map Magic

    Now all is working fine, must of been an issue with the layout I was using...
     
  47. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Unity can get confused if you have the MapMagic tab created somewhere still after uninstalling. That is related to Unity user settings and is cross project, maybe per login? I only use one login...
     
  48. Dorian-Dowse

    Dorian-Dowse

    Joined:
    Jun 2, 2016
    Posts:
    95
    Question about the Split Generator, In the manual on page 37 is talks about using the Height property with Layered Match Type to place items according to their height. It appears to not work though as each object's height is zero no matter how high up the terrain it is.
     
  49. Morgrhim

    Morgrhim

    Joined:
    Jun 19, 2015
    Posts:
    9
    Have a question about a custom generator I'm working on for a diamond square generator. I'm using the following code to try and set the corner heights, and have no errors on adding my generator and connecting it to a heights output, but nothing happens:

    Code (csharp):
    1.  
    2. if(RandomizeCornerValues)
    3.         {
    4.             dst[min.x, min.z] = Random.Range(0f, MapMagic.MapMagic.instance.terrainHeight);
    5.             dst[min.x, max.z] = Random.Range(0f, MapMagic.MapMagic.instance.terrainHeight);
    6.             dst[max.x, min.z] = Random.Range(0f, MapMagic.MapMagic.instance.terrainHeight);
    7.             dst[max.x, max.z] = Random.Range(0f, MapMagic.MapMagic.instance.terrainHeight);
    8.         }
    9.  
    RandomizeCornerValues is a bool that has a Field ref in OnGUI, and appears to be functioning, but the corners never change height. From the sample in the manual I thought this was how to set the extreme corners of the matrix and use the Map Magic instance to pull the terrain height, but the corners stay flat.

    Is there a better way I can implement this to get the corners to start at random heights?
     
  50. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,276
    Dorian-Dowse, you can use Adjust Generator to change objects height:
    SplitObjectsByHeight.png
    The bad thing is that you have to use Adjust Generator to reset object's height back after the split, this does not make the grpah look very tidy. I'm thinking about some basic adjustments in Objects Output, but it's not a high priority task.
    Note that all of the adjusts use Absolute mode. The first one's height is set to terrain height in world units, the others ("reset" adjusts) height is zero.

    Morgrhim, it's unclear what is "dst" in your script (I believe it's an output matrix?), and what are min and max (it's bounds?), but I can suppose that when you try to get last member of the array you should use max-1 instead of max, i.e. max.x-1 instead of max.x, and max.z-1 instead of max.z.
    But still at least one point should be randomized in this case. Try setting values to 1 instead of randomizing to see if you get terrain peaks at your key points.