Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    274
    MapMagic's pretty firmly set up to work only with 2d noises and flat terrains, right? There's no way to use it for a spherical planet?
     
  2. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    209
    I give up, trying to make map magic work with CTS is giving me lots of headaches, how hard can it be? I do all the steps in the documentation, and the terrain is like not updating the splat maps from cts, it works when it wants and I'm trying to make sense of what happens but I'm very lost here, anyone else having issues? (im using mapmagic 1.8.5 and cts 1.5)
     
  3. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    209
    now my project crashes at start
     
  4. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,154
    Are there any updates to world shift coming soon? Currently it just moves the MapMagic parent but that still breaks everything if you go too far out.

    My other problem is that I have many other things in game that are based on distance, so I can't just move everything without telling certain systems they've been moved.

    I've tried to fake the camera position at extensions.cs:824:
    camPoses[0] = UnityEditor.SceneView.lastActiveSceneView.camera.transform.position + new Vector3(offset.x, offset.y, offset.z);

    I have the noise generator using the same offset variable and tell MapMagic to position the terrains accordingly OnCreate and OnMove in Chunk.cs:104:
    go.transform.localPosition = coord.ToVector3(MapMagic.instance.terrainSize) - offset;

    also in OutputGenerators.cs:862:
    position -= offset;

    It kind of works, but it breaks a lot when I try to make big jumps like 8km+ =[ I'm not the MapMagic wizard that @Wright is of course, maybe some of that will help you think up a better approach... Anyone have any luck with this, or @Wright have any ideas how I can improve this? Is it any different on the git repository?

    Thanks as always.
     
  5. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    antony57, Cleverlie: I'm trying to reproduce the CTS issues, but it seems to be working fine for me. It would be great if you could watch this video and say what exactly are you doing the other way than me or at what stage you get a different result:


    PS just tried closing Unity and opening it again, but still it seems to be working fine. No black terrain, no crashes. So your advice on where to look for those issues could be very handy. I'm using MM 1.8.5, CTS 1.5 and Unity 2017.1 (I don't believe it's somehow related with Unity version).

    It depends on the planet tech you are using. If you can use a heightmap you can write your own generator to spherically tile it and assign to planet mesh.

    malkere, I've planned to do it by v.2.0, along with all other enhancements. But since it's not a complicated task I guess I can make it earlier. Marked as bug too.
     
    malkere likes this.
  6. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    209

    I can't really figure out what exactly is the problem, now I made it work, sometimes it stops working fine and the cts profile is messed up, if I catch the bug again I will do screenshots and a proper post, in the meanwhile I can tell that there is inconsistency between the docs and the actual way to make it work.

    in the docs it says that after adding the cts component to the terrain, you need to apply the profile and remove the component, but actually you must not remove the component, and the profile can be set by drag and dropping the profile in the CSO node, if you delete the cts component from the terrain weird stuff starts to happen, at the point where I closed unity and opened it again and the project crashes unity and I had the lucky to solve it by deleting the cts material from the assets folder.

    this a specific use case, but I would want to generate a terrain with map magic and cts, then completely disconnect the terrain from map magic and save it as a terrain data object, and save also the cts material that is currently applied to it (since it seems that the cts material contains the splatmaps).
    then re do this steps but with a different mapmagic node data (or call it biome), and a different cts profile.
    repeat this multiple times,

    so I would end with multiple "baked" terrains which I can enable/disable at will on runtime, is that even possible? maybe thats a limitation of cts, I made it work once and then for some reason it was screwed and I had to start over.
    I know these are bad UX from unity itself, probably is not totally related to how map magic works, but is a bit undeterministic when it works fine or not, so at this point I can't give you specific steps to reproduce, as soon as I get a glitch I'll screenshot and let you know.

    btw it would be great if we can get the terrain previews when working with cts, is that possible somehow? I guess the way the shader works doesn't let you hack the splat maps to show the previews right?
    cheers
     
  7. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    Aha, it seems to be the cause of the issue. Documentation does not lie, you definitely should to remove CTS component. And, as you can see in a video, I am removing the component too. No CTS component should be assigned to terrain chunk or parent MapMagic object. Custom shader output is using the CTS profile only.

    Does it means that having a CTS profile non-assigned to any terrain crash Unity? I've got dozens of profiles with components, terrain or entire scenes removed, an, I believe, most of the CTS users too. Try reproducing this issue with the standard non-MapMagic terrain.

    It should work, I've just tested it. I believe CTS component applies it's own terrain material each frame instead the preview one.
     
  8. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,154
    Do you have a rough ETA for 2.0 release? And/or for increased world shift capability if you've got time to look into that before wrapping up 2.0. :)
    It's so close to working with my ugly hacks it's painful XD
     
  9. antony57

    antony57

    Joined:
    Sep 9, 2017
    Posts:
    28
    Hello @Wright.

    I made it work too. Also, now I am trying to spawn houses via the object node. I'd like to limit the slope they can spawn in to 5 degree and to use the stamp to adjust and level the area around the house but I can't make it work.

    Can you send a screenshot of what the graph should look like ?

    EDIT : Ok, I found the wiki explaining the process. I did the exact same graph but I end up having 90% of my terrain reaching max height and being completly flat. I think the problem comes from the portal "Height to villages" as I have no idea from where it has to be created? I linked in to the erosion node but not sure it's right...

    Also, how did you get the white circles highlighting the center of the village? Sorry I am quite a beginner with unity...

    I've been going over and over the tutorial I don't get it...
    https://github.com/akaWraith/MapMagic/wiki/Creating-villges-with-MapMagic

    Also you display twice the same graph at the beginning while I think that in graph 1 you meant to show how you scattered the rare object and what the portal "height to villages" means...

    Edit 2 - I've been tyring on a brand new scene and I've the exact same graph than the last one on the link and I don't get any flat area... How did you exactly do the village center?

    Thank you very much
    Antony
     
    Last edited: Nov 17, 2017
  10. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    209
    Hi @Wright I think I figured out what the problem is with my setup and what I wanted to achieve

    the problem is that the way the terrains + mapmagic + cts work is a bit obscure, here it goes:

    when you save the current terrain in mapmagic with the button Save at the top of the MM component, it saves the TerrainData.asset file, which contains the internal settings and heights etc of the current (selected) terrain object.

    the problem comes when you try to re utilize that asset later in for example another scene, the TerrainData.asset should contain as a child asset a texture called "SplatAlpha 1" (when you see the project tab, the asset has a child texture included), the asset actually saves that splatAlpha which dictates what material layer goes and blend at each pixel, the problem is that I think you are saving an old splat there, because probably when we use CTS CSO node, you don't update the actual internal terrain splatmaps and you go directly to update the CTS splatmaps that need to be updated in the material itself, the CTS material has a texture called "Texture_Splat_1" which holds the splats, actually there is four of them, (thats the reason CTS is limited to 16 layers)

    so my theory is that when you hit save in MM component, it saves the terrain data with an outdated splatAlpha map because the moment you remove the usual Textures Output and replace it with the CSO output, then you are not updating the splats in the terrain itself anymore and instead you are passing the splats to the CTS material.

    I'm trying a workaround for this right now, where I manually save in code the terrain asset, the CTS material (which is currently only in memory), and a copy of the splatAlpha that is linked to the material, all in separate assets.

    here is the code:


    Code (CSharp):
    1. [ContextMenu("save")]
    2.     public void Save()
    3.     {
    4.         var dataCopy = Instantiate(GetComponent<Terrain>().terrainData);
    5.  
    6.         var matOrig = GetComponent<Terrain>().materialTemplate;
    7.         var splatOrig = matOrig.GetTexture("_Texture_Splat_1");
    8.  
    9.         var splatCopy = Instantiate(splatOrig);
    10.  
    11.         UnityEditor.AssetDatabase.CreateAsset(splatCopy, "Assets/" + Name + "_splat.asset");
    12.  
    13.         var matCopy = Instantiate(GetComponent<Terrain>().materialTemplate);
    14.  
    15.         matCopy.SetTexture("_Texture_Splat_1", splatCopy);
    16.  
    17.         UnityEditor.AssetDatabase.CreateAsset(dataCopy,"Assets/" + Name + ".asset");
    18.         UnityEditor.AssetDatabase.CreateAsset(matCopy, "Assets/" + Name + "_mat.mat");
    19.     }
    UPDATE: the code above works great! after saving all that stuff, then in a new scene create an empty gameobject, add a terrain component, drag and drop the terrain data asset created, then set custom material and drag and drop the created material, it works perfectly, one thing to notice though, this only work for terrains of up to 4 layers, if you want more you need to change the code above to save all splatmaps needed
     
    Last edited: Nov 17, 2017
  11. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    274
    My planet tech is still up in the air. My current prototype is just a high poly sphere with each vert displaced away from the middle based on the value of a 3d perlin noise at its position. I'm still figuring out the best mapping for the sphere, but there's no reason I couldn't use a height map to do the displacement. The difficulty, I think, would be in making the height map seamless around the sphere -- right now I'm doing that with 3D noise.
     
  12. antony57

    antony57

    Joined:
    Sep 9, 2017
    Posts:
    28
    Hello @Wright. I kept on trying all night. Impossible to make it work. This is a graph I have



    And this is the heightmap graph that I have



    But as mentionned I also tried on a brand new scene with only the default heightmap graph that shows up with you create a map magic terrain and yet again it doesnt work...

    a.
     
  13. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    Oh, it took me almost a minute to realize that it's an old GitHub wiki. I was sure that I've clarified this height-to-villages portal, and I really did: here is the right link.

    Cleverlie, so you are saving pinned terrain to asset files! That should really be a reason! I'll take a look into it to make it work the usual way. Thanks for finding that out!

    brisingre, yep, seams might be the real problem when trying to wrap heightmap to sphere. Have you thought about a triplanar mapping? It's usually used in a context of materials, but I bet these principles could be used in mesh displacement case too.
     
  14. antony57

    antony57

    Joined:
    Sep 9, 2017
    Posts:
    28
    Thank you @Wright

    What does Village stutt means ?

    And again how do you display the white circles?

    thanks for answering it helps alot !

    a.
     
  15. antony57

    antony57

    Joined:
    Sep 9, 2017
    Posts:
    28
    Hello @Wright,

    I've been trying again all the afternoon now. I used the demos scene and the graph provided to try to figure it out based on the link you sent.
    Nothing work

    upload_2017-11-18_17-36-6.png

    You have to keep in mind that sometimes you are interacting with people having very few knowledge of unity, and also non native english speaker. So when you drop out of nowhere "village stutt" for some people it seriously doesn't mean anything...

    So again, can you please explain the whole process from scratch? Happy to discuss via skype if needed.

    Most of the demo scene end up max height and completely flat..


    Some improvements but still not quite there



    And the graph of the demo's heightmap




    Although you don't see it in the screenshot, there is again 90% of the terrain being completely flat at max height

    Thank you,

    a.
     
    Last edited: Nov 18, 2017
  16. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    antony57, under the 'village stuff' I mean all those nodes described below. Everything in the Village group, all of the nodes added in this tutorial.

    Those circles are an object preview. You can enable them by clicking on any generator's output (green circle to the right) and choosing Preview -> Preview on Terrain, I guess you've already found that out.

    I'm not a frequent Skype user, but you can contact me via Discord: Denis#6854. If you could share the screen I'd try to give some advice.


    2ALL: good news to those who have MapMagic on a wish list: starting November, 20 it will be 50% off during the Black Friday sale.

    If you are already using MapMagic it's a good chance to complement it with Voxeland since it is going to be on sale too!

    On that occasion I've created a quick short video showing some of MM demo scenes:

    And since I've mentioned Voxeland here is a video with it too:
     
    TerraUnity likes this.
  17. nitoh

    nitoh

    Joined:
    Mar 20, 2014
    Posts:
    24
    Hi everyone!

    I need a little bit of help with coding. I'm wondering if anyone has a custom generator that can randomly select x number of object input. For example if i use the scatter generator, it could select exactly one output.

    I'm sorry im not good in scripting, especially if hashtables included...

    If anyone could share this piece of code, i would greatly appreciate it!

    Thank you guys!
     
  18. FrostBladePoro

    FrostBladePoro

    Joined:
    May 28, 2017
    Posts:
    5
    Hello,

    I was reading this post as an idea came up to me. How would I do a large terrain with fixed keypoints? The keypoints are static pre/manual created pinned terrains at a fixed location (How to set the location? Ideas?) and the terrain between the keypoints should be generated procedurally with mapmagic.

    My first idea was to use the biome feature for this: every keypoint is a biome and the biomes are then stuffed in the base-terrain wich will be responsible for the terrain between the biomes.

    Do you have better/different approaches?
     
  19. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    107
    Hello. I would like to use your asset in my projects. But I couldn't find any scripting API reference or tutorials.
    I need player to be able to change some settings in runtime (like terrain size, forest percentage etc.) and to apply them to nodes and generate a terrain. Is it possible with your solution?
    Also please leave your contacts for further support. Do you have a VK profile?
     
  20. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    nitoh, here is an example of a node code that will take only a 'number' of objects from Input and pass them to Output. It's not ideal, it uses the standard Unity random and can take the object twice, but at least it's demonstrative:
    Code (CSharp):
    1.     [System.Serializable]
    2.     [GeneratorMenu (menu="Custom", name ="Select", disengageable = false)]
    3.     public class SelectGenerator : Generator
    4.     {
    5.         public Input input = new Input(InoutType.Objects);
    6.         public Output output = new Output(InoutType.Objects);
    7.         public override IEnumerable<Input> Inputs() { yield return input; }
    8.         public override IEnumerable<Output> Outputs() { yield return output; }
    9.  
    10.         public int number = 1;
    11.  
    12.         public override void Generate (CoordRect rect, Chunk.Results results, Chunk.Size terrainSize, int seed, Func<float,bool> stop = null)
    13.         {
    14.             SpatialHash src = (SpatialHash)input.GetObject(results);
    15.             SpatialHash dst = new SpatialHash(src.offset, src.size, src.resolution);
    16.  
    17.             for (int i=0; i<number; i++)
    18.             {
    19.                 int randomCell = UnityEngine.Random.Range(0, src.cells.Length);
    20.                 int randomNum = UnityEngine.Random.Range(0, src.cells[randomCell].objs.Count);
    21.                 dst.Add(src.cells[randomCell].objs[randomNum]);
    22.             }
    23.  
    24.             output.SetObject(results, dst);
    25.         }
    26.  
    27.         public override void OnGUI (GeneratorsAsset gens)
    28.         {
    29.             layout.Par(20); input.DrawIcon(layout, "Input"); output.DrawIcon(layout, "Output");
    30.             layout.Par(5); layout.Field(ref number, "Number");
    31.         }
    32.     }
    FrostBladePoro, I recommend using a slightly different pipeline: firstly you need to pin the terrains at your key locations to force generating terrain here, and once the terrain is generated lock them and edit these places manually (preferably leaving the borders untouched). This way you'll get manually sculpted land at your key points with all of the land generating procedurally between them.

    hottabych, if you are going to change the settings like forest density before actually starting the scene (i.e. generating the first terrain) you can use your custom generator for that. In the forest density you can use a custom node as a mask for the forest generator. Here are some other frequently asked questions about scripting discussed.

    However, you cannot change the land chunk size in playmode.

    You can contact me via email stated in a publisher profile (you can email me in Russian if you'd like to). If you encountered an issue or have an idea please feel free to share them at MM's gitlab page. Unfortunately, I don't use VK.
     
    nitoh likes this.
  21. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    97
    Any plan/ETA to add roads and rivers?
    About rivers if we can handle it with R.A.M. that will be fantastic!
    Please tell me this is in the roadmap :)
     
    SSL7 and Diego_Graphics like this.
  22. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    It's in a roadmap, I'm experimenting with splines from time to time, but still don't know ETA. If everything goes well I'll add a couple of splines beta generators in v.2 in January.
     
    camta005 and SSL7 like this.
  23. SSL7

    SSL7

    Joined:
    Mar 23, 2016
    Posts:
    297
    I would like to ask about something, I am trying to have different spawned things at specific terrains, but not having them by chance (using a constant generator), is there any way to have a pin position or something as a requirement to start a generator process? for example, terrain 1x2 spawn a village, so I have a village only in 1x2 terrain.
     
  24. kuru61

    kuru61

    Joined:
    Oct 17, 2016
    Posts:
    3
    Hello. Does anyone have any idea how to generate lakes in the landscape?
     
  25. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    You can use a simple custom generator that will spawn a single object if the terrain position == 1000,2000. Something like that:
    Code (CSharp):
    1. [System.Serializable]
    2.     [GeneratorMenu (menu="Custom", name ="Select", disengageable = false)]
    3.     public class SelectGenerator : Generator
    4.     {
    5.         public Output output = new Output(InoutType.Objects);
    6.         public override IEnumerable<Output> Outputs() { yield return output; }
    7.  
    8.         public override void Generate (CoordRect rect, Chunk.Results results, Chunk.Size terrainSize, int seed, Func<float,bool> stop = null)
    9.         {
    10.             SpatialHash dst = new SpatialHash(src.offset, src.size, src.resolution);
    11.            
    12.             if (rect.offset.x==1000 && rect.offset.z==2000)
    13.                dst.Add( new Vector2(1500,2500), 0,0,1); //position, height, rotation, scale
    14.  
    15.             output.SetObject(results, dst);
    16.         }
    17.         public override void OnGUI (GeneratorsAsset gens)
    18.         {
    19.             layout.Par(20); input.DrawIcon(layout, "Input"); output.DrawIcon(layout, "Output");
    20.             layout.Par(5); layout.Field(ref number, "Number");
    21.         }
    22.     }
    I have not tested this code, let me know if it's not working.

    Lakes are just land areas below some particular level (water plane(s) Y). You can mask these areas with Curve node to apply different textures and scatter different objects. To create a nice shoreline I recommend using the Beach node.
    Actually, making lakes does not differ significantly from creating seas. The difference is only in water areas size.
     
  26. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,902
    Looking for some ideas on the best approach to creating islands. Nobody does this well FYI. I have world creator which is the only one I have found that has this built in. But the approach it uses, which is the same one I have in a custom MM generator, is to just slope down the terrain around the edges. The problem is the simple approach here doesn't factor in terrain contours. It's easy enough to create a slope based on say the height from center, but simple approaches like that result in very unnatural looking terrain.

    The best approach I have actually found so far is to just create a setup that gives me the general terrain look I want, and then generate terrains changing the seed until it produces an island. It might be simpler with better result in the end to just automate that process, with some logic to verify all edges are under the water height.

    Curious how others have dealt with this.
     
  27. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,902
    I think where I'm going wrong is I'm trying to modify the height directly. I should just be modifying the output of other generators like noise so their values fall off relative to center.
     
  28. Daniel-Talis

    Daniel-Talis

    Joined:
    Dec 10, 2011
    Posts:
    394
    Hi, is it possible to use a weather system program like 'Enviro' with Map Magic? Thanks.
     
  29. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    I don't see why the adding noise to smooth island heightmap does not fits you (the way it's shown in that long tutorial). But you can use a simple form with a low intensity factor smoothed by curve to lift the center of the island just a bit. All of the other "natural" work will be done with a noise.

    I saw the screenshots of MapMagic working with Enviro somewhere in Enviro forum thread, but can't find them now, so I might be mistaken.
    I have not tested Enviro compatibility myself, but theoretically it should work.

    2all: you can always try MM evaluation version to see if it's compatible with your assets.
     
  30. MarkusGod

    MarkusGod

    Joined:
    Jan 10, 2017
    Posts:
    164
    Eniro simply following player transform, so no problem there, they works together just great.
     
  31. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,902
    Using a heightmap doesn't fit my use case. I do have around 20 terrains that will be hand tweaked, but I need several thousand others that will all be procedural from a base biome template. Just varying the seed and a few key inputs to add some variety.

    The issue with simple form is I always end up with it being too prominent. Like with a cone it's always just a mountain in the center.

    I think I'll need to just keep iterating on my edge generator.
     
  32. nitoh

    nitoh

    Joined:
    Mar 20, 2014
    Posts:
    24
    Hi Wright!

    If an object is near to the edge of a mapchunk and i blob under it with a big radius, is it possible somehow to extend the blob to another mapchunk, because right now it just breaks at the edge.

    Thank you for your answer!
     
  33. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    I don't really know what exactly you are going to achieve and what you get using simple form, but I'm afraid you are making it's effect too pronounced. Here I've just sketched what I mean: I adjust simple form effect with a curve to make it look like a bump rather then a cone, and multiply it's effect with a noise. Note that to make the noise multiplicative you need to connect it via "mask" input. And I'm using the noise with a slightly lowered detail level to give a way for further modifications.
    Island5.jpg

    Each MapMagic chunk is independent, it does not have any information about the neighbor ones. This way it cannot paint a blob of the object that belongs to the other chunk. I'm thinking of the way to remove this limitation in v2 by adding some "margin" that will overlap neighbor chunks the way it's done in Voxeland, but if the blob size is really big it will not help a lot. The only thing I can recommend is increasing "safe borders" value to gradually mask the blob at chunk edges to make this effect less noticeable.
     
  34. MarkusGod

    MarkusGod

    Joined:
    Jan 10, 2017
    Posts:
    164
    Hehe, by the way, didn't you think to add seamless mode for those who don't need infinite terrain, something like composing a huge terrains*resolution heightmap, applying generators to it and splitting back to chunks, so we can prototype level in standart maner and after bake the all terrains. I think such approach can eliminate chunk border problems for particular usecases. But i didn't look into maagick code yet so sorry if this can't be suplorted due to mapmagick initial design.
     
  35. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,902
    Ah ok the mask approach works a lot better. Thanks for the example.
     
  36. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    5,260
    I've hooked up events for the following:
    • OnPreparedStarted
    • OnGenerateCompleted
    OnGenerateCompleted is being called once for each terrain (there are currently 25 active in my scene - so once for each terrain.
    However, OnPrepareStarted is being once for each terrain every time a terrain is generated - that is, it's called 25 times for each terrain - for a total of 625 times. Is this expected? I was thinking it would be only once per terrain - so it would match the OnGenerateCompleted.
     
  37. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,902
    I know this most likely has nothing to do with mapmagic per say but thought maybe someone had seen this and might have a workaround. Trying to save the terrain data as an asset is crashing unity. 2017.1.2.p2. I've had crash issues with the new texture array stuff before. And I had megasplat on this terrain when it crashed. Removed it went back to default material but still crashed. It's pretty bad too it crashes, then crashes again on the next startup:)
     
  38. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,902
    New scene fresh mm component no crash. My best guess is it's the custom terrain materials unity has a bug with. And removing them still leaves behind references that trigger the bug.
     
  39. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    Internal prepare function is called each time any chunk is going to be generated, but it seems to call event for all of the chunks each time. Thanks for finding this issue, I'll fix it.

    Yes, all of the data assigned with CSO remains on terrain even if you replace it with the standard texture output. It's probably the MegaSplat control map that is not saved properly. I'll look into it. Issue.
     
  40. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    340
    Hello,
    Is it planned to add a possibility to adjust the procedurally generated terrain manually, without losing these manual changes after subsequent procedural changes? I mean something like this:
    1. I create the terrain procedurally using MAP MAGIC
    2. I adjust it manually (for example by lowering the terrain in one place)
    3. I change some things procedurally (the changes from point 2 are retained)
    4. I adjust something manually again
    and so on...

    As far as I know, with an asset that is a competition to this one, it's possible using this tool ----->
    https://www.assetstore.unity3d.com/en/#!/content/85286
    It would be great if Map Magic had such capabilities too.

    Regards
     
  41. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,902
    Is there a way to apply textures with both a height and slope filter? So I can have a set of textures for height range 0-100, and another one for 100 - 500? And then apply slope filters on top of that?
     
  42. kuru61

    kuru61

    Joined:
    Oct 17, 2016
    Posts:
    3
    How can I force objects to always be created with a certain height? for example Position.y = 200? I would like to put Aquas waterplane for each tile once.
     
  43. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,154
    I do that in script using callbacks. When MapMagic finishes a terrain it sends a callback with the terrain attached. You can just intercept that and Instantiate your water, make it a child of the terrain, and position it properly. I also add a script to the terrain to watch for it being disabled. When it's disabled I destroy the water and everything else I've added on there to be sure that I don't put another one on when MM recycles the terrain from it's pool. In the case of water it might be smarter to just disable it and check it before instantiating, instead just turning it back on and repositioning it, but there are lots of ways to go about it.
     
  44. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    Well, you can use terrain "lock" mode (next to pin button) that will prevent it from any graph change, so all of the custom made terrain will remain untouched. But this mode spreads to the whole terrain chunk, so if your graph change involves significant height or splat changes you can get sharp height or splat gradients at the chunk borders.

    That's exactly what a Blend node for. Link height to one blend input, slope to the other, set the blend mode (I guess, in your case "additive" will do the trick) and at the blend output you'll get the combined result.

    You can use the Adjust generator place the objects at the desired level and Output with "Relative Height" toggle off:
    ObjectsAtTheSameLevel.png
    (sorry for debug mode screen).
    But anyways, you've got to to place the object at the center of the terrain, so you'll either have to use the a custom generator or take malkere's advice and use a callback.

    Here is a sample generator code (warning: I have not tested it):
    Code (CSharp):
    1.     [System.Serializable]
    2.     [GeneratorMenu (menu="Custom", name ="Place at Level", disengageable = false)]
    3.     public class LevelGenerator : Generator
    4.     {
    5.         public Output output = new Output(InoutType.Objects);
    6.         public override IEnumerable<Output> Outputs() { yield return output; }
    7.         public float level = 200;
    8.  
    9.         public override void Generate (CoordRect rect, Chunk.Results results, Chunk.Size terrainSize, int seed, Func<float,bool> stop = null)
    10.         {
    11.             SpatialHash dst = new SpatialHash(src.offset, src.size, src.resolution);
    12.             Vector2 pos = new Vector2(src.offset.x + src.size.x/2f, src.offset.z + src.size.z/2f);
    13.             dst.Add(pos, level,0,1); //position, height, rotation, scale
    14.             output.SetObject(results, dst);
    15.         }
    16.         public override void OnGUI (GeneratorsAsset gens)
    17.         {
    18.             layout.Par(20); input.DrawIcon(layout, "Input"); output.DrawIcon(layout, "Output");
    19.             layout.Par(5); layout.Field(ref level, "Level");
    20.         }
    21.     }
    If you are making a water plane a child of the terrain there's no need to manually track terrain disabling or removing. It will be turned off and on with terrain anyways. Just note that since MapMagic uses the terrain pool you have to check if the terrain already has a water plane before actually adding it in a callback.
     
    malkere likes this.
  45. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    340

    I do not really understand
    I need something like this:
    1. I create a procedural area (including trees etc)
    2. I Correct the terrain manually and remove some trees to place a building there
    3. Performs a procedural correction by changing something else
    4. Corrections from item 2 are retained

    In general, this is to combine procedural and manual terrain construction and use together and alternately.

    The terrain generated by the procedures looks great, but ... it's only when you integrate procedures with manual corrections it brings you to a higher level of creation.

    Anyway... thanks for reply.
     
  46. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,154
    good point! I generate a lot of stuff per terrain so I'm in the habit of deleting and repopulating. The water is always static though and should really just be left alone after the first generate like you suggest.

    I'm going to spend some time trying to tackle floating point stuff again tomorrow. Do you have any suggestions on things I should be careful of. camPoses calculation interruption, output generator position interruption, OnMove and OnCreate position interruption, and noise min max values, are what I am currently interrupting to try and offset terrains by a provided variable.
     
  47. David-Kimball

    David-Kimball

    Joined:
    Sep 18, 2014
    Posts:
    8
    I just purchased MapMagic and VoxelLand but when I build my project after importing I get an error about overlapping output semantics for the tree shader. Is anyone else having this issue, or know what the fix might be?

    Shader error in 'Demo/Tree': overlapping output semantics at line 133 (on d3d9)
    Compiling Vertex program with SHADOWS_CUBE
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA
     
  48. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,154
    You can record your changes (probably easier in runtime) by just storing the before and after results, comparing the difference and then saving them. You could then "reapply" the the changes with the click of a button after you regenerate the terrains due to whatever changes you've made. Anything you didn't change manually wouldn't register with the compare and wouldn't reapply.

    Another way, the way I use in "in-game" is to save every permanent action a player makes like terraforming, chopping a tree down, etc. Later, when a terrain is finished reloading I then reapply all the changes, removing trees, changing the heightmap, etc. Very similar end result, but more aimed at runtime player interactions. A save/load on click approach might be better for what you are trying to achieve.
     
  49. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,775
    I'm going to make a "partial lock" feature in v.2.0: you will be able to set what areas exactly should be locked with a brush. For now I'm just experimenting with this feature and, to be honest, I'm not quite happy with the result: it's more or less working for all generators, but when you change the height the seams between generated and locked become visible.

    I doubt that recording changes is an ultimate solution, it will not work properly with objects. Well, it will, until the same objects are spawned at the same positions, but what if the user increases the forest density in Szaruga's use case? Some of the trees (the old ones) will be removed, while other will grow through the house. And if player change the forest seed it will break completely.

    David-Kimball, what are your OS and build platform?
    At worst you can just throw away that shader if you are not using the demo trees anywhere in your project, but I'd really like to find out what's wrong with it.
     
  50. Hexaedre

    Hexaedre

    Joined:
    Jan 23, 2015
    Posts:
    110
    Hi,

    Is there a way to output textures from MapMagic and save it ?
    I plan to use Horizon[on] and it needs a RGBA mask. I would like to make my masks with MapMagic.
    Being able to save on disk a texture with a channel mixer from MapMagic would be really nice.
    It also would be usefull in order to generate macro textures.

    Are you still working on a warp node ?
    I think that it is not a trivial feature. Being able to deform noises with other noises open the doors to a next level of possibility for creating very rich shapes in therms of complexity and variations. As a Substance Designer user, I use it on allmost all my textures.

    Warping is so much love, please make it alive in MapMagic.
     
unityunity