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

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I am generating infinite terrain while using Amplify Simple Terrain Shader in the custom slot. When I reach the "Remove Range" distance, I receive this message:

    Destroying assets is not permitted to avoid data loss.
    If you really want to remove an asset use DestroyImmediate (theObject, true);
    UnityEngine.Object: DestroyImmediate(Object)
    MapMagic.Chunk:OnRemove() (at Assets/MapMagic/Main/Chunk.cs:155)
    MapMagic.ChunkGrid`1: Deploy(CoordRect[], CoordRect[], Object, Boolean) (at Assets/MapMagic/Main/ChunkGrid.cs:380)
    MapMagic.MapMagic:Update() (at Assets/MapMagic/Main/MapMagic.cs:246)


    Is this something that concerns MapMagic or should I be asking Amplify about it?
     
  2. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    It seems that your material for each of the terrains is saved as an asset. I mean, for each of the chunks new file is created. I'm not sure whether it's MM or Amplify Shader, but if it's really MM then it's unexpected behavior no one has been reported yet. You can try commenting out line 155 of Chunk.cs, it will fix the error but you've got to look for the spawning of material files in asset database.
     
  3. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Is it possible to get MM working in 2019.2 beta? (Currently using b6) and HDRP? Generated terrains are all pink, and the underlying Unity Terrain object has no material assigned. Adding Texture outputs in MM graph does nothing.

    Actually this is the first time I tried working in HDRP so it might be an issue with HDRP and not Unity beta. I've used MM before in older Unity without HDRP.
     
  4. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,521
    HDRP is not final yet, most shaders don't work unless converted.
     
  5. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Yeah I understand that. But this doesn't appear to be a case of a bad material but rather NO material being assigned to the underlying terrain by MM. Plus I thought I saw mention of preview HDRP support added to MM when I skimmed the release notes?
     
  6. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Ok creating an HDRP terrain material by hand and applying that works, sort of. It works in game view but strangely the terrain in the scene view becomes invisible.
     
  7. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Ok decided to just use CTS since it supports HDRP but still can't get it working properly with MM. Is the MM support for CTS still valid?

    A standard Unity terrain with the CTS component added works properly, but an MM terrain with Custom Shader set to the CTS profile is pink.
     
  8. Binary42

    Binary42

    Joined:
    Aug 15, 2013
    Posts:
    207
    Can somone point me in the direction how to generate infinite, not squated terrain? Usecase would be a sidescroller or an infinite runner. So far i have explored the option to generate around an object tagged and keep it in a position, so the axis not needed isnt generated. That doesent work that well.
     
  9. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Would you be able to give a bit more info on how you got this to work? I just keep getting pink terrains. If I manually add the CTS component to the terrain it works, but not when CTS is left to handle it.
     
  10. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    I can't say anything about 2019.2 beta, have not looked into it yet, but HDRP works fine with MM in 2019.1. You've just got to assign a custom material with the shader the common HDRP terrain is using.

    You've got to use custom shader output in order to use CTS. Here is the instructions list.
     
  11. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    I did this but while that fixes the terrain in the game view, the scene view becomes invisible, making it hard to work with.


    Yes this is what I've done.
     
  12. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    You were talking about CTS component, that mislead me, sorry for that.

    Do you have any error in the console while using custom shader output?
     
  13. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Sorry I've been trying BOTH ways. Honestly just trying to get something that works lol. I'm preparing some screenshots to show my setup, but imgur is being stupid. Give me a few minutes.

    No errors that I noticed, but I'll double check.
     
  14. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Ok on Imgur: https://imgur.com/a/7dbryjZ?

    Three screenshots showing what I've attemped. First is Map Magic with a custom HDRP/Lit Terrain material added under Terrain Settings. Second is with the Custom Shader output set up for CTS. Last is the terrain showing properly with CTS if I manually add the CTS component to the underlying unity terrain object (Same CTS profile used in both cases)
     
  15. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    When doing the MapMagic custom HDRP/LitTerrain material option there are no errors.

    When setting up for CTS, one error occurs while clicking through the various "Fix" buttons in the node, specifically the one that says "Assign Custom Material is on". When fixinf that, it for some reason seems to throw an error and then loses the CTS material that was in "Custom Material" which brings back the fix option for "No CTS Material is assigned as Custom Material in Terrain Settings" but clicking Fix on that oen will once again set it, so while the one error occurs it seems if you just keep clicking the Fixes it eventually gets the settings correct, at least so far as it looks in the Inspector.

    That one error is:

    ArgumentNullException: Value cannot be null.
    Parameter name: source
    UnityEngine.Material..ctor (UnityEngine.Material source) (at C:/buildslave/unity/build/Runtime/Export/Shaders/Shader.bindings.cs:122)
    MapMagic.CustomShaderOutput+<Apply>d__28.MoveNext () (at Assets/MapMagic/Generators/CustomShaderOutput.cs:541)
    MapMagic.GeneratorsAsset+<Apply>d__13.MoveNext () (at Assets/MapMagic/Main/GeneratorsAsset.cs:571)
    MapMagic.Chunk+<ApplyRoutine>d__40.MoveNext () (at Assets/MapMagic/Main/Chunk.cs:242)
    MapMagic.ThreadWorker.CoroutineFn () (at Assets/MapMagic/Main/ThreadWorker.cs:604)
    MapMagic.ThreadWorker.UpdateApply () (at Assets/MapMagic/Main/ThreadWorker.cs:176)
    MapMagic.ThreadWorker.Refresh () (at Assets/MapMagic/Main/ThreadWorker.cs:143)
    MapMagic.MapMagic.Update () (at Assets/MapMagic/Main/MapMagic.cs:284)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:303)
     
  16. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
  17. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Ok I'm still debugging this but best I can tell, MM will not work with CTS 2019 and I'm not sure how it is working for others. The material that MM applies for CTS is not the correct one for CTS 2019 from what I am seeing. Or at least, it isn't the one that CTS itself applies.

    Anyway as I said still digging into it and once I get to the bottom of it I'll see what it takes to update MM for this.

    Update 1: Got MapMagic hooking into the proper material now. It is a bit hardcoded but to do it properly there would need to be a control added I think to select the base CTS material. Once you have that string, there is a static class you can call to get the proper material for a given profile.

    Code (CSharp):
    1.                             Material cts_shader =
    2.                                 CTS.CTSMaterials.GetMaterial("CTS/HDRP/CTS Terrain Shader Advanced", ctsProfile);
    3. //                            shader = Shader.Find("CTS/CTS Terrain Shader Basic");
    4.                             MapMagic.instance.customTerrainMaterial = new Material(cts_shader);
    5.  
    However now instead of a pink terrain I get a black terrain lol. But at least I can see the right material on the terrain so I'm guessing I need to dig deeper into the properties set on the material. Maybe something changed in CTS 2019.

    Update 2: Apparently the black texture was caused by the option "Optimize Empty Maps". When I turned that off, it started working.
     
    Last edited: Jun 23, 2019
    camta005 likes this.
  18. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Ok so I have this mostly working now with the patches I've made to MapMagic.

    One thing I can't figure out however is how to make CTS think the profile is "active". Apparently the way MM hooks things up to CTS, the profile never gets set active so it can't be edited. Right now my work around is to put a plain terrain in the scene, add the CTS component, and apply the same profile there. Then the profile can be edited.
     
  19. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Hi Wright,

    I have updated the CustomShaderOutput to properly support both CTS and CTS 2019. It involved adding a new Mode for CTS0219 because some of the code is different. The material lookup, plus CTS 2019 supports up to 16 textures.

    Is there a way I can get this patched file to you?
     
  20. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    So I'm in the initial planning stages here and wondering if there is a way to handle wrapping around map tiles? Not spherical world, but just you go say X direction and after so many tiles it wraps back around to where you started. Same in Y. So a flat map that wraps around on itself.
     
  21. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I have since tested this with a normal material using the Nature/Terrain/Diffuse shader (built-in) and it is still occurring. I have attached a screenshot of my settings to see if you can spot an obvious error on my part. I am not modifying the terrain at runtime in any way.

    Screenshot.jpg
     
    camta005 likes this.
  22. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    I'm asked CTS 2019 makers for a voucher and going to look into integration as soon as I get one.
    I'd be grateful if you could email me you work, guess it would really speed up the integration development. Thanks in advance!

    It could be relatively easy done with a single tile using the custom generator, but if you are going to tile the terrain across multiple tiles the things will be far more complicated. It should be something biome-based, and generate the 'seam' tile twice (or 4 times for corners), each time with different coordinates.

    Seems to be okay in 2019.1.4. Just in case here is the short instruction list on how to use MapMagic with HDRP (in case we are appliying them different ways).

    I could reproduce this issue and fix it for the next release, thanks for reporting it! (fix)
     
    JohnnyFactor and camta005 like this.
  23. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Yeah that is what I was thinking. Use a custom generator to essentially mirror the tiles from one side to the other, so that the player visually sees it looping back around, then when they approach that "mirror" tile, physically move them back to the real one.

    But when I looked into the documentation it didn't appear as though the custom generator had access to tile data other than the one it is currently drawing. So it wasn't clear to me how this would work. If you say it can be done though then I will take another look.

    Is there documentation on Biomes? The link on the Wiki for them just leads to a blank page.
     
    Last edited: Jun 25, 2019
  24. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Hey @Wright , hope you're having a good day. But I'm kinda needing your help with this.
    From the videos I've seen on your tutorials for Voxel Land, the blur node should well - blur the two textures together.

    (not sure where to post this as it's two different products from you), but came here as Blur node is in map magic.
    hand painting textures don't have this issue in Voxel Land, it's only in map magic.

    But as you can see in my image (they are very sharp jagged edges). I've (never) gotten it to work inside mapmagic before, ever. And I'm kind of really wanting to try using Voxel Land and MapMagic together.
    upload_2019-6-27_10-20-10.png

    And your result:
    upload_2019-6-27_10-22-40.png
     
    patchworkx likes this.
  25. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    jwvanderbeck, I mean, there is no straightforward way of doing it and currently I've got no ideas of how to implement this feature. It could not be achieved using biomes, for sure. Just wanted to say that if someone will venture to create tile node then he should take biome node as a base.

    N1warhead, Voxeland sets it's textures depending on the block type. And the block type cannot be partly cliff, partly grass. It's either cliff, or grass. The only thing the Blur node does is bringing the more rounded look, but yet still contrast with the sharp edges.

    Aren't you confusing it with the Blend node?
     
  26. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    214
    @jwvanderbeck try using the raw height bitmap option, just make sure the edges of the heighmap bitmap match on opposite sides of the image (top-bottom and left-right). You should be able to scale this across multiple tiles and it should repeat. If you use some noise to add randomness it might make the joins more obvious unless you can get the noise to match or reduce near the edges.
     
  27. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    That would only work if I was using a raw heightmap with no further MapMagic .. err.. stuff on top of it. Which would defeat the purpose :)

    For now I'm just going to wimp out and have water all around. I'll look at tackling this after prototype if it becomes necessary.
     
  28. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    So guys, help me with my workflow here. I've watched the excellent tutorial on YouTube making the two islands and now I'm working out how to bring my own map to life through MapMagic.

    I am working from an existing 2D map of several islands. I've taken this into Photoshop and roughed out the various heights on each island. Just very roughly. Built up the general areas I want mountains, and cut down the areas I want lakes, flatlands, etc. Any details smaller than this I feel is where MapMagic comes in.

    So my big question is what sort of workflow do people use for rivers? I feel rivers is at a level smaller than I want to work by hand, but I'm not sure the best way to procedurally generate them. I have in my heightmap the areas cut out where I want lakes to be, and I know roughly where I want rivers to start and end, but I don't care too much about how they get from point A to B.

    Also looking at using Cascade for rivers and lakes. Has anyone tried using this with MapMagic?
     
  29. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @Wright But you're still getting a nice blended transition between each texture, I'm not.

    The bottom image is your result, hand painting gives the literally same exact result as yours.
    But my result with Map Magic is 100% either one texture or the other, no blending between them.

    I assumed it had to deal with the blur node as that's the only node you used aside from noise and curve.

    Example (The dirt splotch in the middle is hand paint). I love the nice lovely blend between dirt and grass.
    But, then you have the rock on the right, it's jagged and no blending whatsoever between each texture.
    upload_2019-6-28_3-28-34.png
     
    Last edited: Jun 28, 2019
  30. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,910
    I have a bug with infinite terrain generation. The grass detail is non-transparent, unlit and not animated on all new terrains it generates:

    Capture.PNG

    Unity 2019.1.3f1, latest MM.
     
  31. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @Stardog I've also seen that bug before. Well not me personally - it worked fine for me entirely. But my friend who tested my game didn't have the best GFX Card in the world. So i chopped it up towards being not enough memory or something on the GFX Card. I believe she was on like a GTX 960 or whatever it's called. As I've never been able to replicate it my self with my RX-480.

    So my opinion it has something to do with your graphics card most likely not able to handle all the material data at once.. I could be way off though. Only @Wright could possibly answer this question as he designed it and may know a work around.

    Try changing the detail density down on the grass and see if that helps it, it might start working and if it does it's either a MapMagic bug or a Graphics card not able to draw the higher counts you are using.
     
  32. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Can the distance at which new terrains are generated and removed by changed dynamically at runtime? IE As the player gets higher in height they need to see more terrain tiles, and as they get lower, they need to see less.
     
  33. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Ok so when trying to work with multiple terrain tiles via pinning in the editor I am seeing this: "Bottom neighbor of the terrain has a different heightmap resolution. Stop neighboring." and the terrains don't appear to be generated properly.

    EDIT: hmm. I deleted the MapMagic object and recreated everything. I'm still getting the warning but the map is generating now.
     
    Last edited: Jun 29, 2019
  34. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    172
    Hi Denis, I'm using the custom splatmap option with Map Magic and Microsplat and either MS or MM isn't refreshing the splatmaps when the terrain is regenerated with new texturing options (this is intermittent and only seems to happen after the second splatmap is generated). I have a Microsplat node with 5 textures and it generates fine, drop that back down to 2 textures and it still uses the old textures that have been removed from the generator and still generates 2 splatmaps.
     
  35. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    What is the trick to getting the Preview option to work? It always seems to be greyed out for me. It would be really helpful to be able to see a 2d image of what my heightmaps look like, especially when trying to tweak them with curves.

    EDIT: Ok after digging through the code I figured it out. Rather non intuitive, but I guess it could make sense in hindsight. To get the preview you have to click specifically on the Output dot inside the node you want to preview.
     
    Last edited: Jun 30, 2019
  36. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    I have seen this happen when pinning multiple terrains and 'Instant Generate' is un-checked. If the terrains are not generating properly you can either check the option again or click 'Force Generate All' or 'Generate Changed'.
     
  37. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Instant Generate is enabled, and I have used Force Generate All many times throughout working. The warning persists all the time, but doesn't "appear" to be causing issues unless it is without my knowing.
     
  38. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    Had you un-checked it when the pinned terrains stopped generating properly?
     
  39. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    No. I didn't even know of the setting until you mentioned it :)
     
    camta005 likes this.
  40. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    If you could send me the scene with the grass texture I can look into it to find out if it's related with the video card or MapMagic

    I guess this issue is caused by Voxeland, not MapMagic. It should not display the transition between blocks this way. I can take a look if you send me the Voxeland scene or data file.

    Could reproduce this warning. Seems to be related with the recent Unity terrain auto-connect feature. Doesn't seem to affect anything, but I will try to find why it occurs anyways.
    EDIT: fixed for the next release

    I'm afraid there's no way to do it out of the box, but you can change the mapMagic.generateRange value with scripts. Probably some additional actions should be required like resetting deploy rects (mapMagic.deployRects = null), I don't know, haven't ever tried this.
     
    Last edited: Jul 1, 2019
    camta005 likes this.
  41. CodersFromBeyond

    CodersFromBeyond

    Joined:
    Apr 14, 2019
    Posts:
    20
    camta005, Djayp and Wright like this.
  42. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    From a performance standpoint, if my goal is to generate a lot of terrain, then stream it in as needed, is it better to use larger tiles or smaller ones? I can see advantages and disadvantages both ways.

    Smaller tile means more precise streaming, not streaming in sections you don't need, but smaller tiles also means more tiles visible at any given time which presumably has larger overhead.

    Larger tiles means presumably less overhead, but you have a coarser control over thew streaming.

    Right now my gut based on what I'm, seeing in the editor with pinning is that less tiles is better, so using larger tiles would be better for performance. Is this correct?
     
  43. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @Wright : I have sent you the email with node graph, also the email is quite informative so you don't have to come back here to find out my issue so it's easier to find.
     
  44. CodersFromBeyond

    CodersFromBeyond

    Joined:
    Apr 14, 2019
    Posts:
    20
    Performance depends more on actual Unity terrain rendering, 1k, 2k or even 4k resolution terrains are quite performance hungry to render. Newer instanced rendering can help with this and make even 2k maps perform well.
    As for the MapMagic and GPU generation, fewer larger terrains generate more quickly than lots of small terrain. This is opposite for CPU generation, in which usually lots of small terrains generate more quickly than fewer larger ones.
     
  45. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    My concern is more with the performance in game, since the terrain will already be pre-generated in MM, pinned, and streamed in tile by tile as needed.
     
  46. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    Does anyone know what texture assets were used for the snow in this?

     
  47. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    825
    I'm curious what the bug was? Seems odd that Unity is saying the heightmap resolutions don't match. Why would they be different? I looked at a couple tiles and they all indicate they are at the same resolution.
     
  48. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,267
    When the new terrain data is created via script it's height resolution is 65. MapMagic changes the resolution this same frame so you can't see it, but the thing is that Unity fires the internal auto-connect event right after creation, i.e. before the resolution is changed. It's not convenient, but I've been expected something like that, so it's not a big deal. I was using disabling game object before adding terrain component as a workaround - events are not called by the disabled objects - and enabling it once the generation is done.

    The dark and bright cliffs are from the demo scene, as well as the sky. The only texture set left is the snow, it's rather simple - light noise both for diffuse and normal.

    Oddly enough, but I get a bit better performance when using 16*16 terrains with resolution of 128 rather then when using single 2048 terrain. It should not be the frustum culling since all of the terrains were on screen. Funny thing, will try to find out why this happens someday.
     
  49. Kesarium

    Kesarium

    Joined:
    Dec 3, 2014
    Posts:
    56
    I just started using MapMagic and my Texture Output node doesn't have a place for a normal map nor does it have any settings for any texture. It only shows the Filename and two connectors for each texture. I also cannot use plain textures anymore, I have to manually create a Terrain Layer for each texture I want to use in the Texture Output. Is there something I'm doing wrong? Or is there a problem going on with MapMagic?

    *Edit - I'm using Unity 2019.1.8f1.
     
  50. MagiSoftworks

    MagiSoftworks

    Joined:
    Feb 12, 2019
    Posts:
    124
    Hi - Just picked up Map Magic , Powerful asset - Thank you for looking out side the box. I started cranking on it with Veg Studio Pro and all was well- I did add few asset later (Mainly Vegetation). Now in editor I cannot move my nodes around or right click to add node. Everything is still functional except for this. Is there a "Lock" or something I am missing? Is there a way to "refresh" editor? Thanks!
     

    Attached Files: