Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    All of the recent MapMagic versions work with the Unity's Terrain Layers system. To use a normal map you've got to assign it to the terrain layer rather than output node.
    However, you can still use the old splat way if you'd like to by creating a Splat Output from Legacy section.

    You've probably got an error in the console - if so could you please paste it here?
     
  2. pau1o-hs

    pau1o-hs

    Joined:
    May 16, 2017
    Posts:
    5
    Hi! Can I get a lowpoly effect in my map? How?
     
  3. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
  4. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    You've got to use a separate asset for that. The thing is that MM is a map generator, not terrain engine. Unfortunately, I haven't tried low-poly terrain shaders so I can't say which a compatible with MapMagic.

    I have not tried it yet, but it looks rather promising.
     
  5. MagiSoftworks

    MagiSoftworks

    Joined:
    Feb 12, 2019
    Posts:
    124
    Hi- Really liking Map Magic - Powerful. Got it recently and started with Raw Input Gray Scale Island I did in Adobe - Was about to start adding MegaSpat and have tile line in terrain. I remember you talking about this so maybe its something easy- I'll continue to research just a bit busy. Thanks -
     

    Attached Files:

  6. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Perhaps someone here might be able to help me.

    When MM generates the next chunk and activates it, I'm getting MASSIVE Culling spikes in performance.
    spiking from 80 FPS to 20, over and over again. And it generally stops once a terrain is unloaded.

    Not sure what else I can do to make this more optimized.
    I even lowered my tree counts considerably and the result is still the same.

    Designing my own culling plugin now in hopes that can help me, but I don't wanna spend time doing this unless it's absolutely required if there's already some built in solution that can help me resolve this.

    Every single mesh has LOD with culling, etc.
    Single Terrains not an issue at all, always 80ish FPS, but the second a second terrain is 'activated' that's when the issues come into play.
     
  7. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    It might be related to your grass, try temporarily removing it and see if you get the same performance issues.
     
  8. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Interesting how grass has such a horrendous impact on performance.
    It made a big difference turning them off.

    Assuming there's no alternative other than adjusting patch size and such.
    I do have UNature, but haven't really used it much, but I think it's supposed to be more efficient and is compatible with MM.
     
  9. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Can't seem to figure out how to make Unature work with Map Magic. I followed the insrtuctions on the https://gitlab.com/denispahunov/mapmagic/wikis/Problem_solving

    But it's not showing any grass at all now, not even standard grass.

    [EDIT]
    Yeah no Unature isn't very efficient. Garbage Collection is over 3 MEGS and it's less dense in grass quality than normal grass. 1100.12 MS. So going to figure out another way.
     
    Last edited: Jul 15, 2019
  10. Refeas

    Refeas

    Joined:
    Nov 8, 2016
    Posts:
    192
    Look at Vegetation Studio Pro. They are using the new ECS and Burst compiler to draw vegetation, it should be a huge performance improvement and it's compatible with MM. uNature is rather outdated. Once they add full HDRP support to VS Pro, I'll get it as well.
     
  11. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    VSPro requires some still sort of "experimental" grade stuff to be turned on, and I had some problems with it, though it is a lot faster when it works. I'm using standard VS for the specific purpose of grass. The performance difference over standard Unity grass is monumental.
     
  12. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    214
    Or check out GPUInstancer which can gpu enable your grass and other objects with MM compatibility.
     
  13. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Thanks for the tips everyone. Definitely going to consider these choices :)
     
  14. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    Hi, folks--

    I've been happily using MapMagic for years, but lately I'm having big problems when trying to export terrains for use in other scenes that don't include MapMagic.

    I'm using Unity 2019.1.5f1, and I add the "ExportTerrainData.cs" script to the terrain object (which is under the MapMagic parent object). When I click on the checkbox ("Export"), a save-to window pops up, and I enter a name for the terrain asset file.

    Once I click OK, the script goes to work and then, very quickly, it appears to erase the textures on my terrain. The splat map itself is apparently saved, but the texture slots show up as blank squares in the terrain-painting section of the terrain object.

    The missing-texture issue occurs *instantly:* -- in other words, the textures are actually removed from the terrain object that is under MapMagic.

    Here's a before-and-after to show what happens. Any help would be appreciated, thanks!

    Before Export:
    upload_2019-7-15_19-28-6.png




    After Export (immediately after I click the export-terrain-data checkbox and select a destination, the textures are blanked out in the existing terrain object in the scene, as well as in the exported asset file if I import it into a new scene):

    upload_2019-7-15_19-30-43.png
     
  15. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    BTW, I do get an error (actually several identical errors) when I perform the export process. Here's what the console reports:

    MissingReferenceException: The object of type 'TerrainLayer' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.Object.get_name () (at C:/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:189)
    UnityEditor.Experimental.TerrainAPI.PaintTextureTool.DrawFoldoutEditor (UnityEditor.Editor editor, System.Int32 controlId, System.Boolean& visible) (at C:/buildslave/unity/build/Modules/TerrainEditor/PaintTools/PaintTextureTool.cs:82)
    UnityEditor.Experimental.TerrainAPI.PaintTextureTool.OnInspectorGUI (UnityEngine.Terrain terrain, UnityEditor.Experimental.TerrainAPI.IOnInspectorGUI editContext) (at C:/buildslave/unity/build/Modules/TerrainEditor/PaintTools/PaintTextureTool.cs:158)
    UnityEditor.TerrainInspector.ShowPaint () (at C:/buildslave/unity/build/Modules/TerrainEditor/TerrainInspector.cs:1387)
    UnityEditor.TerrainInspector.OnInspectorGUI () (at C:/buildslave/unity/build/Modules/TerrainEditor/TerrainInspector.cs:1796)
    UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:445)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  16. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    Was it really the grass? Guess it's some Unity stuff, but I could have a look into it to find a workaround.

    In recent MapMagic versions terrain exporting works out of the box, so you don't need additional scripts. And it works with the new terrain layers system, so there should not be an issue you've mentioned. In order to export terrain data press the Save button next to the Pin and Lock.
     
  17. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    I've tried that also, but it has the same problem (no/blank texture info). On the plus side, though, there aren't any error messages with that approach -- but it doesn't work any better. Same problem: instantly removes the texture info from the terrain as soon as I export. And creating a new terrain using the exported terrain asset data only loads the height info plus the blank texture slots.

    Fortunately, I've found that MadMaps allows me to save / export the terrain info properly (though only in 2018.3 for now). I can use that as a workaround until (hopefully) a MapMagic update allows full exporting.
     
  18. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    Are you using the Textures Output with the terrain layers assets assigned, or is it the legacy Splats Output?
     
  19. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @Wright : I think that was partially it. It did make a difference. But ultimately it came down to my LOD on my trees I believe, when you got 17K trees on one terrain, and a few thousand more on another and another and another (4 terrains loaded) at once, I guess it adds up to, too much.

    So I suppose LOD is a bit of a performance killer lol.

    But hey I have a question to whomever can answer this.
    Is there anyway to determine when a Terrain chunk is generated?

    I need to add a specific script to a generated Terrain chunk.
    Assuming there's some way to handle that.
     
  20. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    you can subscribe to the callback MapMagic puts out with:
    MapMagic.MapMagic.OnGenerateCompleted += MyMethod;
    Or intercept it in the Update function of MapMagic.cs at around 300.
    You can also have a script on your MapMagic object and turn on the option to include components. That will copy components on the MapMagic object to any new terrains, though you have to be aware of pooling and some things with that approach.
    OnGenerateCompleted should probably also check to see if the script is present before adding it, in case of pooling.

    There was an interesting read about performance improvement in a game where a guy moved his LOD from per object to chunk based, said he had great results with. Something like 50m squared chunks or something I would assume. As yes, tens of thousands of LOD's running math every frame can be rough.
    https://www.gamasutra.com/blogs/DannyWeinbaum/20171201/310813/Foliage_Optimization_in_Unity.php
     
  21. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Thank you @malkere will look into this.
    It says MapMagic.MapMagic.OnGenerateCompleted doesn't exist.

    Edit: Figured out how to do it around line 300 like you said. Thank you.
     
    Last edited: Jul 20, 2019
  22. noobynobody

    noobynobody

    Joined:
    May 9, 2019
    Posts:
    75
    Anyone use this with Synty Studio's Nature Pack? I'd love to see a screenshot to see if the texture painting looks good.
     
  23. Hexer_

    Hexer_

    Joined:
    Aug 25, 2016
    Posts:
    94
    Did anyone manage to make MM work with CTS 2019 and VSP?
    I tried everything and am just about to give up.
    Nothing spawns when I connect CTS textures to VSP .
    No errors, just nothing..
    Normal Grass node works though
     
  24. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    Still no luck creating a terrain that can exist independent of MapMagic.

    Using the "Save" button in the main MM component, I'm able to get it to create a terrain and heightmap but, as I explained above, the splat/texture data is lost. In fact, all splat/texture in the scene turns to the standard/blank gray color, unless I regenerate it again in MapMagic.

    I can reconstruct the terrain layers (textures, settings, tiling) by filling in the data from the "Splats" node in my MM editor, but that wastes a lot of time. Alternatively, if MM exported the terrain layers themselves, I could simply drag and drop the files into the new terrain's layers.

    Wright, you asked:
    <<Are you using the Textures Output with the terrain layers assets assigned, or is it the legacy Splats Output?>>

    I have no idea. I haven't managed to find any settings/options regarding those items. Or perhaps you were responding to N1's question?

    Any guidance on this would be appreciated, even if it's just to say that you know about the problem and will eventually fix it. ;-)
     
  25. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    I agree that subscribing to event is the best way to get notified when the chunk is generated - mainly because it's available out of the box and you don't have to change anything in MM code. But I'd rather recommend subscribing to OnApplyCompleted - this is the one that marks all of the work done (both generating and assigning heightmapsplatmap/etc to terrain).

    Have you tried looking through these tutorials? If you have - do you get any issue when following them? If so could you please clarify what exactly goes wrong?

    https://gitlab.com/denispahunov/mapmagic/wikis/output_generators/Custom_shader#using-cts

    Could you please make a screenshot of your graph? It's the node that you are using to paint your terrain - it should be called whether 'Textures' or 'Splats'. I've just tried exporting the terrain made with Textures, and can see no problem with it - all of the textures are exported and the terrain could be used in a different scene (keep in mind that to use it in a different project you have to re-assign terrain layer assets).
    However, I have not tested it with the Splats output, and I'm not sure that it will work since it's an outdated solution - Unity have replaced splats with the terrain layers recently.
     
    Hexer_ likes this.
  26. Hexer_

    Hexer_

    Joined:
    Aug 25, 2016
    Posts:
    94
    Hi, thank you for posting that link I noticed I didn't turn on the compatibility for CTS/VSP because when the first time I opened that window I got this..
    Now either the instructions on that page are wrong or the label is wrong?
    Now MAPMAGIC constant appeared in the player settings and all works as it should :)
     

    Attached Files:

    Last edited: Jul 22, 2019
  27. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    Update: First, I think I found an alternate way to get the terrain export function to work, without having to manually re-create the texture layers. I'll explain that later, if I can't get the new system to work.

    More importantly, though, I think I understand what you were asking regarding the Textures Output (I had assumed you were talking about the MM component in the inspector!). Yes, I've been using the SPLATS output node; I'm something of an old dinosaur user of MapMagic, I guess. o_O I handle all aspects of building the game, from Blender to scripting to level design, building, etc etc, and it can be tricky to keep up with deprecations and new features!

    EDIT: Re my question about how to create terrain layers: I hadn't realized you were talking about the standard way of creating them within Unity's terrain editor; I had thought there was a new way to specifically create the layer files that Unity saves - not realizing that the terrain editor now automatically generates those whenever we add a new texture/layer in the Terrain component.

    At any rate, I'd like to try using the Textures Output node as you've suggested -- but I'm not finding a way to actually create the Unity layers as you've described at https://gitlab.com/denispahunov/mapmagic/wikis/output_generators/Textures
    (on that page, you say "You've got to create the terrain layer using the standard ways (check Unity manual)").

    I'll keep hunting for the reference, but I think the manual has changed; I keep getting Page Not Found errors. Could you point me to a reference on how to create the layers? The only ones I'm finding are those that Unity apparently creates in the "_TerrainAutoUpgrade" section; nothing new is being created when I save terrains.
    NOTE: I had renamed the _TerrainAutoUpgrade folder, though (assumed it was aimed at converting existing terrains, not new ones); I'm going to try renaming back to the default and see if that helps.
     
    Last edited: Jul 22, 2019
  28. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    UPDATE - SUCCESS!!!
    I did as you suggested -- I've manually re-created the terrain layers directly in the Unity Terrain component (copying the values I had created in the Splat node). Once I did that, those new terrain layers were available for addition into the slots of your new Textures output node. I added them into the Textures node, hooked up the same inputs I had been using as the ones from the Splats node, and then used the "SAVE" button on your MapMagic object / component.

    The terrain seems to have exported just fine. Rather than blanking out all the terrain texture values, the terrain layers are preserved and the saved map is identical to the one I had been working on. It's portable and capable of being transferred into another game level just like any regular Unity terrain.
     
  29. BlackManatee

    BlackManatee

    Joined:
    Jun 13, 2013
    Posts:
    82
    Clarification: If anyone has experienced similar confusion about the change from the Splat node to the new Textures node, here's a screenshot illustrating the process. Older versions of MapMagic used the Splats node (and IIRC, populated Unity's terrain textures on the terrain component, based on what I had entered into the Splat node). These days, it's essential to create the terrain texture-layers inside the standard Unity terrain component FIRST, and then place the newly-created layers (Unity will save them with obscure names like NewLayer...) into the Textures node on the MapMagic map. Once that's done, it's simple to click on the SAVE button on MapMagic's inspector/component and then save (after clicking on the terrain tile you want to save/export, in Scene view).

    Here's a screenshot of the part I was confused about. Hopefully it'll prevent others from getting snagged like I did! (Note: I've left the Splats node connected just to illustrate that the Textures node uses the same connections)

    upload_2019-7-22_8-55-2.png
     
    camta005, Wright and malkere like this.
  30. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    thank's BlackManatee it's what's i try understand

    but why keep the Splat node ?
     
  31. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    Guess it's just the way to show the way new Textures node should be connected.

    Thanks BlackManatee for clarification!
     
  32. jasonofthestorm

    jasonofthestorm

    Joined:
    Aug 22, 2017
    Posts:
    4
    Hi, is there a way to decrease the resolution below 64, or to achieve a lower poly count some other way?
     
  33. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,910
    Increase Pixel Error setting.
     
    Wright likes this.
  34. ajaxlex

    ajaxlex

    Joined:
    Jul 15, 2016
    Posts:
    38
    Hi @Wright,
    Thanks again for the great tool. I am using MM with microSplat on unity 2019.1.10f1, and I think I have found a significant issue with the way the custom shader output is working with the microSplat terrain.

    As you recall, microSplat includes a texture array that it uses to support lots of textures in the final terrain. It will bundle those textures in groups of 4 into individual splat maps, which can be viewed on the Micro Splat Terrain component.

    Whenever I add a layer to the custom shader node whose texture index is above 3 ( for example, index 5 ), my landscape goes haywire, and the texture appears to be unrelated to the node inputs.

    What I see in the Micro Splat Terrain component is that a new custom splat has been created, presumably to account for the new texture which will be accounted for in the next set of 4 ( 5 % 4 = Custom Splat 1 ). This new custom splat is created whether or not I have any data going into the new texture layer - which is fine, however, the new splat is entirely white. This means that all of the textures for that splat are blending together I guess. This happens because Unity's default Texture2d is not initialized to all black/transparent.

    I seem to have solved it by arranging for a Color[] array 'clearColor' that I leave empty, and then if the incoming color array is null, I apply that color to the corresponding texture.

    I'd be interested to hear if anyone else can reproduce this issue, or if its a result of some other problem with my setup.

    CustomShaderOutput.cs ( in Apply method )

    431 (add):
    Code (CSharp):
    1. Color[] clearColor = new Color[rect.size.x * rect.size.z];
    451 (modify):
    Code (CSharp):
    1. if (colors[i] != null)
    2. {
    3.     tex.SetPixels(0, 0, tex.width, tex.height, colors[i]);
    4. } else {
    5.     tex.SetPixels(0, 0, tex.width, tex.height, clearColor);
    6. }
     
    Last edited: Aug 2, 2019
  35. ajaxlex

    ajaxlex

    Joined:
    Jul 15, 2016
    Posts:
    38
    Fyi, explanatory screencaps
     

    Attached Files:

  36. ajaxlex

    ajaxlex

    Joined:
    Jul 15, 2016
    Posts:
    38
    For other people who are using Map Magic and MicroSplat, and who are also trying to use MicroSplat's terrain blending, I found an issue with MicroSplat's code that generates the blending texture that comes up when following Denis' tutorial on integrating MicroSplat with Map Magic. If you can't get it to work as expected, check this out -

    Link to MicroSplat forum:
    https://forum.unity.com/threads/fre...or-unity-terrains.487458/page-49#post-4806887
     
  37. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    172
    I've found a similar issue with MS and MM I think where reducing the number of textures in the Custom Input from say 5 to 4 does not remove the splatmap generated for the fifth texture.
     
  38. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    I'm literally confused on making a custom generator.

    I make sure I put using MapMagic; at the top.
    Then if I literally copy paste the examples from the docs a lot of things simply error out.

    Code (CSharp):
    1. //For example this: (Errors out)
    2. public override IEnumerable Inputs() { yield return input; }
    3.  
    4. //Really should be (works).
    5. public override IEnumerable<Input> Inputs() { yield return input; }
    6.  
    7. // This doesn't work. (errors out).
    8. public override void Generate (MapMagic.MapMagic.Chunk chunk)
    9.  
    10. // It only works with this specific way.
    11. public override void Generate (CoordRect rect, Chunk.Results results, Chunk.Size terrainSize, int seed, Func stop = null)

    It really appears that these examples are based on an outdated codebase.
     
  39. SoloHonk75

    SoloHonk75

    Joined:
    Mar 27, 2016
    Posts:
    31
    Hey @Wright.

    1. Any ETA for MM2?
    2. What will be the minimum unity version?
    3. Will functions of the existing Third-party-expansions already be included?
    4. Do you have a plan how expensive the update will be for existing customers?
    5. is there a beta-phase where we can help you with testing?

    Thanks in advance and keep up the good work.
     
  40. ajaxlex

    ajaxlex

    Joined:
    Jul 15, 2016
    Posts:
    38

    I've successfully made generators, so it can be done.
    its difficult to see what is wrong without the error text though.
     
  41. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    upload_2019-8-3_12-10-52.png

    And this comes from an example from the https://gitlab.com/denispahunov/mapmagic/wikis/Creating-a-custom-generator
    Code (CSharp):
    1. [System.Serializable]
    2. [GeneratorMenu (menu="MyGenerators", name ="MyGenerator", disengageable = true)]
    3. public class DynaGrassMaster: Generator
    4. {
    5.     //input and output properties
    6.     public Input input = new Input("Input", InoutType.Map, mandatory:true);
    7.     public Output output = new Output("Output", InoutType.Map);
    8.  
    9.     //including in enumerator
    10.     public override IEnumerable Inputs() { yield return input; }
    11.     public override IEnumerable Outputs() { yield return output; }
    12.  
    13.     public override void Generate (MapMagic.MapMagic.Chunk chunk)
    14.     {
    15.         Matrix src = (Matrix)input.GetObject(chunk);
    16.  
    17.         if (stop!=null && stop(0)) return;
    18.     }
    19.  
    20.     public override void OnGUI (GeneratorsAsset gens)
    21.     {
    22.         layout.Par(20); input.DrawIcon(layout); output.DrawIcon(layout);
    23.     }
    24. }
    Now to get rid of the errors this is the stuff I have to replace.

    Code (CSharp):
    1. //For example this: (Errors out)
    2. public override IEnumerable Inputs() { yield return input; }
    3.  
    4. //Really should be (works).
    5. public override IEnumerable<Input> Inputs() { yield return input; }
    6.  
    7. // It only works with this specific way.
    8. public override void Generate (CoordRect rect, Chunk.Results results, Chunk.Size terrainSize, int seed, Func stop = null)
    9.  
    10.  
    11. // This doesn't work. (errors out). (Was on the same examples page).
    12. public override void Generate (MapMagic.MapMagic.Chunk chunk)
    My point isn't that we can't create generators, but it appears things are outdated or something, or there's some very big clear step that isn't obvious that I'm missing to why this stuff isn't working.
     
    Last edited: Aug 3, 2019
  42. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    I mean everything with the 'custom' stuff is literally old code you can't do anything with, it's more headache and is fixing to make me just abandon MM indefinitely. I hate to say that because I really love MM. But literally every single example - literally ALL of them are from how things used to be or simply aren't completed examples.

    For example, was searching around the MM GitHub and found a simple enough generator to put a water plane at the center of the terrain so I can just use a single water source for all my terrain chunks. Nope it's missing stuff, so don't work. Not incompatible stuff, no literally - it's actually missing stuff.

    Here's the entire code snippet for doing that from the GitHub page.
    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.         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.             Vector2 pos = new Vector2(src.offset.x + src.size.x/2f, src.offset.z + src.size.z/2f);
    12.             dst.Add(pos, level,0,1); //position, height, rotation, scale
    13.             output.SetObject(results, dst);
    14.         }
    15.         public override void OnGUI (GeneratorsAsset gens)
    16.         {
    17.             layout.Par(20); input.DrawIcon(layout, "Input"); output.DrawIcon(layout, "Output");
    18.             layout.Par(5); layout.Field(ref level, "Level");
    19.         }
    20.     }
    21.  
    It errors out about the two below.
    There is no 'src' variable.
    And there is no 'input'.

    I've never in my life been so fed in trying to understand something. It has nothing to do with how things are done in MM. It has to deal with I suppose updates happening and bringing about major changes, so literally every single example on the github is out-of-date so there's nothing to really learn from.

    I've tried to look at the Generators inside MM itself and it's too much of a garbled mess to understand how things are even working. I have not once yet seen how it's even calling other methods. Or why some methods are called and why others are seemingly never called in the code but apparently are called behind the scenes some how.

    Really, I love Map Magic a lot, but this stuff really needs updated examples so i can even understand how to do things.
     
  43. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,910
    There is a SampleGenerator in MapMagic/Generators you can look at.
     
  44. Baum_Joshua

    Baum_Joshua

    Joined:
    Oct 5, 2013
    Posts:
    25
    Hello I purchased MapMagic friday and when i added it to a new project I am getting the following errors "\MapMagic\Generators\CustomShaderOutput.cs(626,46): warning CS0618: 'Terrain.MaterialType' is obsolete: 'Enum type MaterialType is not used any more." I am using the latest version of Unity and MapMagic. Any idea why these are happening?
     
  45. ajaxlex

    ajaxlex

    Joined:
    Jul 15, 2016
    Posts:
    38
    @N1warhead - when I made mine, I just opened up the mapmagic generators folder in my project, and opened the various generator files - they are known good examples.

    I think one of the important things that i see - Denis' examples aren't showing the includes necessary to properly build the generators. For example, you need to include 'System' to get use of Func type. As far as the function calls go, most of the main functions in the generators are meant to be called from the supervising MapMagic script - they obey its workflow. Part of the reason it can be hard to work with MM is that the functions are designed to be multithreaded, so there are lots of yields, etc, and the code can sometimes behave strangely in the debugger IIRC.

    Anyway, here is a generator I threw together that works in my up-to-date asset store MM. It puts a ridiculous block in the middle of the map. Not really useful, but shows all the critical stuff - including the 'using' at the top.


    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using System.Collections.Generic;
    4. using MapMagic;
    5.  
    6.  
    7. namespace VertexHerder
    8. {
    9.     // Adds a big goofy cube to your terrain
    10.     [GeneratorMenu (menu="VertexHerder", name ="BlockGenerator", disengageable = true)]  //uncomment this line to add generator to right-click menu
    11.     public class BlockGenerator : Generator
    12.     {
    13.         //input and output properties
    14.         public Input input = new Input(InoutType.Map);
    15.         public Output output = new Output(InoutType.Map);
    16.  
    17.         //including in enumerator
    18.         public override IEnumerable<Input> Inputs() { yield return input; }
    19.         public override IEnumerable<Output> Outputs() { yield return output; }
    20.  
    21.         public int size = 10;
    22.  
    23.         public override void Generate(CoordRect rect, Chunk.Results results, Chunk.Size terrainSize, int seed, Func<float, bool> stop = null)
    24.         {
    25.             Matrix src = (Matrix)input.GetObject(results);
    26.  
    27.             if (src == null || (stop != null && stop(0))) return;
    28.             if (!enabled) { output.SetObject(results, src); return; }
    29.  
    30.             Matrix dst = new Matrix(src.rect);
    31.  
    32.             Coord min = src.rect.Min; Coord max = src.rect.Max;
    33.  
    34.             int halfx = (max.x - min.x) / 2;
    35.             int halfz = (max.z - min.z) / 2;
    36.             int halfsize = (int)size / 2;
    37.  
    38.             for (int x = min.x; x < max.x; x++)
    39.             {
    40.                 for (int z = min.z; z < max.z; z++)
    41.                 {
    42.                     if (x > ( min.x + halfx - halfsize ) && x < (min.x + halfx + halfsize) && z > ( min.z + halfz - halfsize ) && z < (min.z + halfz + halfsize))
    43.                     {
    44.                         dst[x, z] = src[x, z] + size;
    45.                     } else
    46.                     {
    47.                         dst[x, z] = src[x, z];
    48.                     }
    49.                 }
    50.             }
    51.  
    52.             if (stop != null && stop(0)) return;
    53.             output.SetObject(results, dst);
    54.         }
    55.  
    56.         public override void OnGUI(GeneratorsAsset gens)
    57.         {
    58.             layout.Par(20); input.DrawIcon(layout, "Input", mandatory: true); output.DrawIcon(layout, "Output");
    59.             layout.Field(ref size, "Size", min: 0, max: 200);
    60.         }
    61.     }
    62.  
    63. }
    64.  
     
  46. ajaxlex

    ajaxlex

    Joined:
    Jul 15, 2016
    Posts:
    38
    Oh yeah, I like to namespace my generators too. Code Hygiene. Good luck!
     
  47. ajaxlex

    ajaxlex

    Joined:
    Jul 15, 2016
    Posts:
    38
    @Bodyclock - it probably isn't getting rid of the other splatmap because the _index_ of one of the remaining textures is above 3. For example, suppose I only had 3 textures in the custom shader node ( set, of course to microsplat ), and those three textures had IDs of 2, 6, and 10. I would expect to see 3 separate splatmaps - one for textures 0,1,2,3 ( 2 is there ), one for 4, 5, 6, 7 ( 6 is there ) and one for 8, 9, 10, 11 ( 10 is there ).
     
  48. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Thank you, that worked!
    let me see if I can figure out how to spawn a water plane in the center now.
     
  49. MagiSoftworks

    MagiSoftworks

    Joined:
    Feb 12, 2019
    Posts:
    124
    Does Nature Manufacture R.A.M 2019 with Map Magic? Carving the river, painting , Removing vegetation etc-
    I can get a nice river spline in place but it seems to have issue painting the spline with sand, bright cliff etc. Thanks!
     
  50. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    If it has a yellow icon in the console then it's a warning that may occur on some Unity versions. It says that some methods are obsolete, but still needed for the compatibility reasons (for those who are using older Unity versions). If it's a warning it doesn't affect the code compile and execution, it's not an error, and it could be disregarded.

    I always try to update the online documentation on any code change related with it. It's not always possible with videos, but the docs stored on GitLabs should be up to date. Please let me know if find the outdated information here, but it's definitely not the custom nodes, I've just cross-checked it.

    And thanks for letting me know that adding 'using System;' directive isn't as obvious as I thought. It's hard to target all of the coders of all the amounts of knowledge, so I might be missing something, but will try to fix it once I get feedback.

    ajaxlex, Bodyclock, try this CSO script. It should work with multiple splat textures for MicroSplat. It's still under development, but all of the upcoming works are related mostly with MegaSplat.

    I plan to release it in autumn.

    I develop it with 2019.1, but hope it will work with 2018 too (however can't guarantee that).

    Don't know extensions do you mean exactly, but it will have the extended node set compared with the MM1. Mostly it would be the spline nodes, but I assume that some other nodes will have the same functionality with some third-party assets.

    Yes, I plan to provide the significant discount to MM1 users, however it's amount is still under the consideration.

    Probably I will release a public beta version some weeks before publishing the final one - some kind of evaluation version, just like the one for MM1. Currently there's a closed beta running - you can take part in it by emailing me your order number.

    BTW I'm currently started the recording of MM2 video tutorials - unlike MM1 that had a single video describing the scene creation from scratch, I'm going to split it in a dozen of 10-minute tutorials. The first video is nearly ready, and I'm going to upload it soon. It could be helpful for MM2 beta testers, and could be interestingly for others.

    MapMagic creates the standard terrains, so theoretically any asset working with the terrain could be applied after the MM's generation is done in editor. However, it won't work in the infinite mode, but I guess the problem here is with the generated terrains only?
     
    ftejada and Stardog like this.