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

    SoloHonk75

    Joined:
    Mar 27, 2016
    Posts:
    31
    @Wright

    Thank you for your answers. Email is on the way...
     
  2. MagiSoftworks

    MagiSoftworks

    Joined:
    Feb 12, 2019
    Posts:
    124
    Thanks Denis!
     
  3. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    260
    I have upgraded my project to 2019.2.0f1.

    Previewing on terrain is not rendering correctly; I think the shader used to preview terrains is not working properly with changes made to terrain in 2019.2. The preview in window does appear to be working correctly.

    Thanks.
     
  4. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    @Wright I notice in your demos when you add clusters of stones you're adding them as GameObjects on the terrain. Is there any performance difference with this and putting them on as detail objects? Specifically are terrain objects culled differently to scene GameObjects.. Maybe something more intelligent like quadtrees or something?
     
  5. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Thanks for reporting the issue, Unity 2019.2 brings some terrain material changes that require MM to be updated. I'm doing it now and will try to release ASAP.

    I guess detail objects will render faster. However I wasn't using them them because of their simple shader (diffuse-lit if I'm not mistaken). Besides, I wanted to show the way objects could be added to the terrain - detail objects should be placed via Grass output, and should have maps instead of the objects node, and I had to show the way Slide or Propagate nodes are working.
     
    protopop and Ziplock9000 like this.
  6. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    260
    Hi,
    I downloaded the update you released and found it does fix the issue with Unity 2019.2 terrain changes with the built in render pipeline, but it introduces a few new problem when using the light weight render pipeline in Unity 2019.2. First, non-pinned terrains are assigned the built in pipelines terrain material in play mode and after leaving play mode the map magic terrain material field has been changed to Nature/Terrain/Standard.

    I have found the issue in the code and I believe I have fixed it. Every time On Enable is called in MapMagic.cs in play mode, the material is being replaced with Nature/Terrain/Standard.

    I found changing
    Code (CSharp):
    1.  
    2.              #if UNITY_2019_2_OR_NEWER
    3.             Shader terrainShader = Shader.Find("HDRP/TerrainLit");
    4.             if (terrainShader == null) terrainShader = Shader.Find("Nature/Terrain/Standard");
    5.             customTerrainMaterial = new Material(terrainShader);
    6.             #endif
    in MapMagic.cs OnEnable() to
    Code (CSharp):
    1.  
    2.             #if UNITY_2019_2_OR_NEWER
    3.             if (customTerrainMaterial == null)
    4.             {
    5.                 Shader terrainShader = Shader.Find("HDRP/TerrainLit");
    6.                 if (terrainShader == null) terrainShader = Shader.Find("Light Weight Render Pipeline/Terrain/Lit");
    7.                 if (terrainShader == null) terrainShader = Shader.Find("Nature/Terrain/Standard");
    8.                 customTerrainMaterial = new Material(terrainShader);
    9.             }        
    10.             #endif
    resolves this issue.

    Second, I have found that in the DemoScene, generated terrains will occasionally be created with no material assigned when using the light weight render pipeline.

    Thanks.
     
    Last edited: Aug 9, 2019
    Wright likes this.
  7. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    My bad, really missed that thing! Thanks for finding that out! Fixed and submitted.

    Just change the LWRP shader name to "Lightweight Render Pipeline/Terrain/Lit" in your code (instead of Light Weight), it will make the demo scene terrains work.
     
  8. Refeas

    Refeas

    Joined:
    Nov 8, 2016
    Posts:
    192
    @Wright Hey there!
    For fast iteration purposes (graphical authoring) we use small map size (256 size, 128 resolution and 64 height). And then, for in-game testing, we use 1024 map size, 512 resolution and 256 height. So as you can see, we keep the size/resolution/height ratio same for both maps. However, when we spawn something using say scatter, forest and other objects generators in the small map, it doesn't behave the same on the larger one - the distances between scattered objects vary even tho the density should be relative (that's what I concluded from the documentation and seems only logical to me) - am I missing something here? Thanks!
     
  9. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    The fixed MM version is available at the Asset Store.
    I recommend updating to all users who are using the custom shaders together with the Unity 2019.2 and latest MM.

    Some MM generators work per-pixel, and some are per-unit. That's why it's hard to say what you get when using the different resolution and terrain size, even if their ratios are the same. MM's pipeline does not suppose changing any of those.

    It's a design flow that wasn't obvious during MM development, and one of the main reasons I started MM2. MM2 is absolutely resolution independent, and allows to get the same result on the terrains of any size and resolution (lower resolution terrain will be just less detailed, but keep the overall form).

    BTW MM2 is using your pipeline by default - it generates lower-resolution terrain (draft) first, generating higher res chunk in a background.
     
    desertGhost_ likes this.
  10. Refeas

    Refeas

    Joined:
    Nov 8, 2016
    Posts:
    192
    Thanks for clarifying that out! I'm excited for the MM2 release then. Is there any summary of the new MM2 features/differences from MM1 available?
     
  11. Kaen_SG

    Kaen_SG

    Joined:
    Apr 7, 2017
    Posts:
    206
    I'm having some trouble with the MM+VSPro Demo Scene.

    Using Latest Unity 2019.2, Latest MM, Latest VSPro.

    Initial Load looks good
    upload_2019-8-15_0-0-44.png

    Then after running for a few seconds... I get to the edge and this is what happens.

    upload_2019-8-15_0-1-46.png

    upload_2019-8-15_0-23-12.png

    The terrain texture has gone completely pink.

    and I'm not using HDRP/LWRP/etc. Just Linear/Deferred.
     
    Last edited: Aug 14, 2019
  12. AngelBeatsZzz

    AngelBeatsZzz

    Joined:
    Nov 24, 2017
    Posts:
    239
    Hi, I used the code in the tutorial to place the object, but ‘src.offset’ and ‘Input.DrawIcon’ are red, I have used the 'MapMagic' namespace, what should I do?

    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.  
     
    Last edited: Aug 15, 2019
  13. Kaen_SG

    Kaen_SG

    Joined:
    Apr 7, 2017
    Posts:
    206
    Did more testing... there's a lot of strange behavior. Like Trees spawning in the sky... grass not showing up at all.
    And sometimes trees spawning under the terrain... you can see tree tips sticking out of the ground (also missing grass).

    upload_2019-8-15_16-25-51.png

    upload_2019-8-15_16-27-20.png

    On further testing. The missing textures also happens on the regular MM DemoScene (without VSPro) but somehow works perfectly fine generating new terrains on the IslandDemo

    upload_2019-8-15_16-17-12.png

    All testing done on 2019.2.0f1 and Latest versions of MM/VSPro. (Except the last screen shot which uses the MM Demoscene and doesn't use VSPro)
     
    Last edited: Aug 15, 2019
  14. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Here is a page devoted to MM2 Preview version. Here you can find the main features list and a short FAQ.

    I suppose you having an error in the console when the pink terrain is about to appear. If so, could you please paste it here? I guess all of the other issues are caused by it too.

    It seems that you are missing your generator input. If you take a look at Creating Custom Generator manual you can see that MyCustomGenerator contains a public field named `input`. It is the left circle on the node graph that reads the data. Generate method starts with the loading input's object `input.GetObject(chunk);`. The thing is that you've lost your input somehow, but as far as I can see your node should have one.
     
  15. Kaen_SG

    Kaen_SG

    Joined:
    Apr 7, 2017
    Posts:
    206
    upload_2019-8-16_8-5-21.png

    No errors in console.
     
  16. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Can I create this kind of mountain with Map Magic?
    Remote_Mt_view.jpg Cardamon Mountain.jpg
     
  17. Sam512

    Sam512

    Joined:
    Jan 13, 2019
    Posts:
    178
    Can I manaully paint and sculpt like Unity terrain? (I use Speedtree 8)
     
  18. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    You can create any kind of mountain.
    MM does not save/load manual changes out of the box. You will need to write a simple script to store changes and reapply them post regeneration with MM, assuming you regenerate. Alternatively you can get a terrain to where you like, then completely remove MM and work on it manually from there. In other words, if you regenerate your terrains at any time all manual changes will be lost by default.
     
  19. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    @Wright we miss you in Discord
    I'm working on a custom generator to split between custom biomes. It blends the edges of each "biome" (not MM biomes, just using the term in general) towards the neighbor terrains biome, but it seems there is a safe borders routine somewhere affecting the final results. Depending on the order that the terrains come on the corners and edges can end up with different results. Was curious if you could point me towards what does this so I can play with it.
     
    mmaclaurin likes this.
  20. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Thanks for reporting the issue! I could reproduce and fix it, submitting for review. Here is a quick fix if you need one. Alternatively you can turn off the Terrain Pooling in Settings.

    Except for the waterfall, yes, you can create such mountains in MapMagic.

    Unfortunately, no, that's not what MapMagic is about. MM is not a sculpting tool. However you can create the standard terrain with MM, and then sculpt it the usual way.

    Yeah, sorry for that. I plan to spend more time to it once I deal with MM2 (or at least with public/eval beta). For now I can be engaged mainly in MM2 channel, today I'll bring a small but pleasant surprise here.

    It might be the terrain welding. Try setting Height and Splat Weld Margins to zero in Settings.
     
    malkere likes this.
  21. Prod212

    Prod212

    Joined:
    Dec 13, 2017
    Posts:
    17
    Hello, I have a question regarding our grass because right now it doesn't seem like the grass is being rendered properly on generated terrains. As you can see from the image, the grass gets rendered on the pinned terrain on the left but when it's a generated terrain, the grass appears as a white texture plane. Does anyone have an idea on why this happens?

    upload_2019-8-20_16-21-0.png
     
  22. MagiSoftworks

    MagiSoftworks

    Joined:
    Feb 12, 2019
    Posts:
    124
    Hi All - Don't know if anyone ran into this but on a fresh download of CTS -MapMagic\Generators\CustomShaderOutput.cs(841,32): error CS1002

    Its just a semicolon on Line 841
    line 841: ctsProfile = serCtsProfile
     
  23. Aress28

    Aress28

    Joined:
    Dec 12, 2015
    Posts:
    100
    I have problem that i want spawn objects at run time in vegetation studio but i cant tell VS Pro to not spawn grass for example on sand cuz its not recognise textures on terrain as there is only CTS shader on actual terrain. Is there a way to make it work?
     
  24. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    I have sent Denis a bug report about this now. It contains a build and a scene.

    What video card drivers do you have? I using 411.70. Maybe I will try to update.
     
  25. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Oh, my bad! Thanks!

    You need to switch the grass scattering rule from per-texture to the mask one (the way it's shown in the tutorial).

    Thanks for sending a report, I have received it and downloaded linked files. Will try to reproduce and fix it after the weekend.
     
    Stardog likes this.
  26. jvetulani

    jvetulani

    Joined:
    Dec 20, 2016
    Posts:
    55
    Hi! Is there possibly an incoming river/lake generator?
    And also a node that would allow for hand sculpting of terrain on top of the generated one (like something that adds to the heightmap) while still being able to keep the generated terrain and regenerate it without loosing the sculpted data?
     
  27. Giantsmall

    Giantsmall

    Joined:
    Apr 28, 2019
    Posts:
    18
    Hi, I would like to get access to generator output in C# that I could query by coordinates (for instance to get height at (0,0)) - how can I do it?
     
  28. xercool

    xercool

    Joined:
    Sep 5, 2017
    Posts:
    90
    @Wright

    Is it real to make a loop with MapMagic map? I want repeat map generated by mapmagic instead of just endless terrain.

    Is it possible?
     
  29. SoloHonk75

    SoloHonk75

    Joined:
    Mar 27, 2016
    Posts:
    31
    @xercool
    I would copy the last row of terrains before the first terrain row. Teleport the character on the border.
     
  30. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Speaking of lakes, you can try using this setup:
    ScatterLakes.jpg
    I have no plans of creating river generators in scope of MM1 (however they might appear in MM2).

    It requires some kind of layers system like the one in ZBrush. I'm afraid it's a bit out of the scope of MM as a terrain generator.

    There's no way to do this unless you generate a chunk containing coordinates. The thing is that MapMagic doesn't generate per-pixel, some nodes like erosion or blur or cavity are using neighbor pixel data, so the simplest way to find some pixel height is to generate it's chunk.

    You can try blending the initial nodes (like noise and voronoi) so that they repeat the same pattern. The other nodes, being based on the initial ones, the results should be blended too. So I guess it's possible, however I haven't tried doing this myself, and guess it's not a trivial task.
     
    Giantsmall likes this.
  31. Zelre

    Zelre

    Joined:
    Dec 3, 2016
    Posts:
    55
    Here's a tip for anyone that wants to make use of the runtime Navmesh tools (https://github.com/Unity-Technologies/NavMeshComponents) in MapMagic, but don't want each AI generating a Navmesh (expensive).

    Create a Cube that's the size of 1 of your terrains. Attach the runtime Navmesh script to it and set the area that it creates the Navmesh to the same as the cube. Delete the render materials, mesh colliders etc. Also set the height to be higher than your terrain. Then spawn a single cube into your MapMagic, don't set the height to the terrain. Based on the size, it should automatically spawn it to the center of your terrain.

    This is a rough "guide" but you should get the idea. Instead of 100 AI making their own Navmesh on the go, you have one giant navmesh builder that creates a runtime navmesh as that terrain is generated, and all AI on that terrain can walk on it. This navmesh will also adapt to changes in the terrain at runtime.

    Have fun. :)
     
  32. FIllbiker

    FIllbiker

    Joined:
    Jun 9, 2010
    Posts:
    118
    Is it possible to make terrain height or texture paint changes on generated terrain by MapMagic? If I choose the tool from current terrain base tool I can see the blue pointer on mouse cursor over terrain but no changes made if I start to paint.
    Maybe it is not technically possible, just asking for sure. BTW I am usig MapMagic with Microsplat.
     
  33. SkandYxyz

    SkandYxyz

    Joined:
    Mar 13, 2015
    Posts:
    83
    Hi,

    In my case Map Magic and CTS2019 not seem to integrate very well on Unity 2018.4 standard pipeline or I am missing some workflow? Clicking on refresh in custom shader output not updates all material information. It not generates colormap or switches shader when ctg profile changes between advanced and tesselation. Instant checkbox also lacks of functionality, as changes in cts profile are not updated instantely. I guess it might have to do with cts not having a material stored as asset but being recreated and applied each change of cts profile. In case of map magic do I need to add cts scripts to each terrain as i do now?

    Best,
    Andre
     
  34. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Changing the terrain made with MM is possible and does not require additional action. Check your brush settings (like opacity). But keep note that you will loose your manual changes once you generate MM again, so it's better to disable or remove MM component as a precaution.

    Speaking of shader change you should change the material itself. Update Material copies the material properties only when the shaders match. In other aspects I recommend setting up CTS the usual way on some terrain tile, and then using it's material and profile in MM.
     
  35. SkandYxyz

    SkandYxyz

    Joined:
    Mar 13, 2015
    Posts:
    83
    My conclusion on MM + CTS2019 Standard Pipeline:

    I created a material asset and applied this material to the custom shader material slot along with the cts profile. I also added a cts script to each terrain tile and applied the cts profile. If i change the cts profile i only update it through MM custom shader notes update now button. This way I have no global Maps like normal or Color, but it seems quite stable.

    Best,
    Andre
     
  36. Daahrien

    Daahrien

    Joined:
    Dec 5, 2016
    Posts:
    100
    Any idea why my trees dont have collider? (The terrain does)
     
  37. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Is there any way to fix this?

    I want the back edges of terrains to go into the water
    upload_2019-8-29_20-23-21.png
     
  38. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    How do I call a function after the chunk is done generating and showing the terrain chunk?
    I need to call something on another script.

    EDIT:
    Nevermind I figured it out: I used OnEnable(){} in the script I wanted to call.
     
  39. Giantsmall

    Giantsmall

    Joined:
    Apr 28, 2019
    Posts:
    18
    Thank you, I will try with single chunk.

    I have more questions:
    1. Is there any way to set number of prefab variations for output? Or can any prefab need to be dealt separately?
    2. Can I pass any input value to Generator from C#? For example to set seed in noise?
    3. Can I integrate MapMagic with GPU Instancer?
     
  40. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    trees added to Unity terrains as trees will add any primitive colliders to the terrain collider itself. I'm not sure if it works with mesh colliders, but they combine into a single collider. Are there colliders on your trees before you place them? Are you using the Tree output and not Object? Are the collider primitive or mesh?
     
  41. Daahrien

    Daahrien

    Joined:
    Dec 5, 2016
    Posts:
    100
    Oh yeah, thank you. I had tried it with no collider and with mesh colliders, and it didn't work like that. I have to use primitive colliders for it to work. Now it does work nicely. :)
     
  42. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    How would I go about getting the edges of terrains and lifting them in the air?

    Think of it this way, any side of a terrain that isn't connected to a terrain - to lift it in the air - so I can create a sort of natural boundary (E.G. - Cliff).
     
  43. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    To emphasize what I asked above, this is what I mean..

    I can get it to work, but I don't want the middle cross section to be there, only the outer edges.
    upload_2019-8-30_20-41-45.png



    [Edit]
    I figured it out, I used a Simple Form, changed it to Pyramid, scaled it and then inverted it and applied some noise and such to break it up and got my boundaries :)
     
    Last edited: Aug 31, 2019
    camta005 likes this.
  44. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    Just wanted to say you've got to mask it with the Simple Form, either a circle (cone, for round terrains) or square (pyramid, if you want to leave it square). But glad you could sort that out yourself.

    You can use the Split node in random mode the way it's done in demo scene:
    TreesSplit.png

    Yes, here is a way to do it. Note that it's better to set the seed at the scene start, otherwise you'll have to re-generate all chunks again or get seams between the terrains with the new seed and the old one.

    Personally I haven't looked into GPU Instancer, but hope someone who tried to integrate it here could shed some light.
     
    Giantsmall likes this.
  45. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,277
    I could reproduce this issue in Unity 2019.1, and spend almost a day trying to figure out why it happens. Then I accidentally imported the project to Unity 2019.2 and found out that there's not a trace left of this bug, while everything other remained the same. It might be some Unity-related stuff, so it's worth trying updating your project, and if it won't help I will look further.
     
    Deleted User and Stardog like this.
  46. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    I upgraded to 2019.2.3 to test and it does work in build now. Thank you for that! However, I am still having an issue with MicroSplat not applying properly to loaded terrains. You can see the rocks are flat in my project. It seems to load the detail texture but not diffuse. Maybe it's an MS issue, not MapMagic...
     
  47. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    172
    I'm on 2019.2 and am having a similar problem with MM and Microsplat. The diffuse doesn't seem to be applying to generated terrains.

    MMSplat.png
    The 2 central terrains are pinned, the others generated in playmode. The splatmaps are generated (see highlighted terrain) and the components attached with the correct template material but no textures appear even though the slope mask is applied (see bottom left).

    MMSplat2.png

    If I press Sync All the highlighted terrain is updated (and some other random terrain or terrains depending on what I've clicked on but not necessarily still highlighted), but not all of them.
     
  48. Deleted User

    Deleted User

    Guest

    We switched from Unity 2019.1 to 2019.2.3f1 but it does not fix the Texture bug for us.
    Like Prod212 already described a picture of the issue: 2019-09-03 10_49_27-Stone Reverie.jpg
    It only appears in the build and only on generated terrains which were not generated in the Editor before, I hope this helps, we are also on the LWRP but saw this bug before in the Default RP, I stay tuned for future updates.

    But I know that some Unity Versions solve it, we also have got this situation.
     
    Last edited by a moderator: Sep 3, 2019
  49. Binary42

    Binary42

    Joined:
    Aug 15, 2013
    Posts:
    207
    Hi, how can i use existing (mesh/collider, non-MM-generated) objects as mask or consider them in any other way during generation? And how can i restrict generation to one axis for a 2D game?
     
  50. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Hello, apologies if these questions have been asked before but I am trying to piece the info in one place:

    1. Can this asset be used to create a terrain via a seed generated at runtime (and that specific seed number be stored say in a PlayerPref so it can be retrieved at a future point to generate the same terrain)?
    2. If so is an entire terrain generated from a single seed or is it a combination of procedural definitions including the seed that generate the terrain?
    3. Can a seeded terrain also have some regular pattern such as a zero edge so multiple seeded terrains can be tiled at the same edge height easily?
    4. Can specific graph nodes be references in code and values be changed at runtime?

    Many thanks :)
     
    Last edited: Sep 4, 2019