Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. 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. rickcollette

    rickcollette

    Joined:
    Mar 17, 2013
    Posts:
    304
    Code (CSharp):
    1. public class FallEnabler : MonoBehaviour
    2. {
    3.     public void OnEnable ()
    4.     {
    5.         MapMagic.MapMagic.OnApplyCompleted -= EnableFall;
    6.         MapMagic.MapMagic.OnApplyCompleted += EnableFall;
    7.  
    8.         Rigidbody rb = GetComponent<Rigidbody>();
    9.         rb.isKinematic = true;
    10.         rb.detectCollisions = false;
    11.     }
    12.  
    13.     public void OnDisable ()
    14.     {
    15.         MapMagic.MapMagic.OnApplyCompleted -= EnableFall;
    16.     }
    17.  
    18.     public void EnableFall (Terrain terrain) //checks if applied terrain contains object, and enables it's rigidbody if it does
    19.     {
    20.         Rect terrainRect = new Rect(terrain.transform.position.x, terrain.transform.position.z, terrain.terrainData.size.x, terrain.terrainData.size.z);
    21.         Vector2 pos = new Vector2(transform.position.x, transform.position.z);
    22.  
    23.         if (terrainRect.Contains(pos))
    24.         {
    25.             Rigidbody rb = GetComponent<Rigidbody>();
    26.             rb.isKinematic = false;
    27.             rb.detectCollisions = true;
    28.         }
    29.     }
    30. }
    any ideas on making this work with character controller? my object (in this case a player char) just falls right through the terrain before it gets genned completely. If i start in a pinned terrain, everything is as expected - but if the player leaves a session and returns to a generated terrain... falls right through...
     
  2. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    Could not make the character fall through the terrain, but I've got the idea why that could happen. Probably you make your character move with a disabled rigidbody on an inclined land - which makes the character cross the terrain plane sometimes. So you'll have to manage terrain moving along with a rigidbody.

    Just in case: this script should be assigned to the character object, not the MapMagic one.
     
  3. Martian-Games

    Martian-Games

    Joined:
    Jan 19, 2012
    Posts:
    43
    Has anyone else had trouble getting a WebGL build of the DemoScene to work from a blank project?
    Below is a screenshot of the result I get after building the Demo straight out-of-the-box.
    The only changes I made was:
    .. turned off Multi-threading (because it crashes with error otherwise)
    .. and allocated 1024 memory in Build Settings.

    (Stand-Alone and WebPlayer builds work just fine, this only happens in WebGL) upload_2016-7-1_5-8-44.png
     
  4. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    The Evaluation Version is fixed now.

    Martian Games, looks like it failed to build the first non-pinned terrain. WebGL puts it's own restrictions - very severe ones. I was making a demo scene to show various MM possibilities and was not aiming to make it run at all platforms. Someday I'm gonna make a simple demo for mobile platforms and WebGL, but now I'd like to recommend you using low terrain resolution (256), minimum map generators and avoid using heavy generators like forest or erosion.
     
    Sir-Spunky likes this.
  5. KrankyBoy

    KrankyBoy

    Joined:
    Mar 27, 2009
    Posts:
    737

    How did you get AQUAS to work with Map Magic? I get errors when I use the quick setup.
     
  6. Martian-Games

    Martian-Games

    Joined:
    Jan 19, 2012
    Posts:
    43
    Oh I see, but do you have any insight into what in particular might be breaking in WebGL? I have been doing a trial-and-error approach to isolate the WebGL problem by making several builds, (which takes lots of time). I did try extremely small resolutions, with forest,rocks,erosion,etc turned off but get the same result.
    EDIT:
    Since WebGL will not recognize System.Threading, I suspect the problem relates to your use of threading in MapMagic.cs
    For example:
    public bool running{get{returnthread !=null&&thread.IsAlive;}}
    ...Will get ignored by WebGL because it won't recognize the Thread class. :(
     
    Last edited: Jul 2, 2016
  7. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    That's a point. I'm adding looking into WebGL support to my to-do list, probably I'll add !UNITY_WEBGL directive to everything thread-relative.

    I've just used it out-of-the-box, but if you will take a look at the video you'll see that I was using it not on the terrain, but on a plane which was not related with MapMagic in any way.
     
  8. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    Map Magic looks awesome. Bought it a short while back, only just starting using it. I take it that when I use AI Unity NavMesh I bake these for the terrains that are not dynamic then those that are dynamic I make sure that the AI do not use the Nav mesh (waypoints and random destinations)? Once Unity 5.5 is out that supports dynamic navmeshes I'm assuming that Map Magic will support this feature?
     
  9. KrankyBoy

    KrankyBoy

    Joined:
    Mar 27, 2009
    Posts:
    737
    When trying to save my node data I am getting (look at screenshot) this error:

    Image1.png
     
  10. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Hi Wright, I'm wondering if you could share any insight into what you were planning for adding splines. For example you mentioned using them for rivers. Will there be some way to have it interpret the spline across multiple tiles somehow? Is there, for example, any way to have it generate random splines that span multiple tiles so you could have rivers on infinite terrain?
     
    iddqd likes this.
  11. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    137
    I've noticed that using stamp doesn't propagate to any tiles except the first one:



    Also, please tell that grouping will come in the nearest update? :)
     
  12. ToamoaStudio

    ToamoaStudio

    Joined:
    Jul 1, 2015
    Posts:
    13
    (Sorry for bad english)

    Hi,
    It’s an amazing plug! It worked very well but since this morning we have a little problem : we see tree shadows through the grass.


    The problem doesn't appear when we paint grass directly on the terrain and when we disable the directional light.


    Can you help us please? =)
     
  13. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    I plan to look into splines after I'll deal with biomes and voxeland integration. I admit that rivers should have an ability to flow through multiple terrains, it seems that they should use some noise-based algorithm to place nodes, but yet I have not looked into it.

    Grouping? Do you mean this one?

    It's already in the release :)

    I've encountered this bug a couple of times - even when was not working on MM. Unity can draw shadows over the grass, it happened when the grass was dense and was noticeable only from one direction. For me it was fixed with changing detail resolution per patch in terrain settings, and here is an advice to assign a cookie texture to the light.

    PyroStudios, smoluck: glad you are willing to test biomes! I'll make an announcement in this thread when the beta is ready.

    2All: I could have missed some post because of the forums switches, so do not hesitate to repeat the question of you have not received a reply.
     
  14. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    137
    Damn... I am blind :) I don't know how did I miss it :)

    Also, could you help with those stamps on the terrain I mentioned? Still can't get it to work on multiple tiles.
     
  15. Martian-Games

    Martian-Games

    Joined:
    Jan 19, 2012
    Posts:
    43
    For those wanting to use MapMagic for WebGL, a few things I learned:

    1. Threading must be turned OFF. (I do hope MapMagic may provide an IEnumerator (single-threaded) substitute to somewhat alleviate the lags. PreProcessor directives #if UNITY_WEBGL would be very welcome! :) Meanwhile, I am working on my own solution for this.)

    2. It turns out that for WebGL, if we have a pinned Terrain of higher resolution than the General-Settings>Resolution, we will encounter this index out of range error.
    Generate Thread Error:
    System.IndexOutOfRangeException: Array index is out of range.
    (So, maybe this is a problem for all platforms?, however in WebGL it completely breaks)
    So, this is a simple fix: just make sure that any pinned Terrains match the same resolution as in the settings. ;)

    3. If you do not want any pinned Terrains in your scene, (you want to generate everything at runtime), notice that Unity will strip all the Terrain Shaders at Build-Time if it doesn't find any Terrains in your scene, so your generated Terrains will look black!
    Solution: Copy a small prototype Terrain containing everything you need and just SetActive:false. Even though the Terrain is not visible, Unity will include all the needed Terrain Shaders in the build.

    4. As usual, consider the strict memory limitations of WebGL. (Use minimal assets, resolutions, etc)

    I hope this is helpful to others attempting to build for WebGL ;)
    Wright: Keep up the great work! :D
     
    Last edited: Jul 15, 2016
    Wright likes this.
  16. persistent

    persistent

    Joined:
    Oct 18, 2013
    Posts:
    4
    This looks amazing! Would love to know your tonemapping settings!
     
  17. Martian-Games

    Martian-Games

    Joined:
    Jan 19, 2012
    Posts:
    43
    By the way, I've found that Unity Editor will crash if MapMagic is active while attempting to change GeneralSettings>Resolution, if briefly the value reads 000 while for example trying to change 1,000 to 2,000.
    Maybe we need a check in case this value is 0, wait for some value greater than 0 before updating the Terrain?
    Current workaround: Disable MapMagic gameobject first, change value, then re-activate. ;)
     
  18. ToamoaStudio

    ToamoaStudio

    Joined:
    Jul 1, 2015
    Posts:
    13
    It worked very well, thank you! =)
     
  19. sarum

    sarum

    Joined:
    Mar 2, 2014
    Posts:
    212
    tonemap1.jpg

    tonemap2.jpg
     
  20. persistent

    persistent

    Joined:
    Oct 18, 2013
    Posts:
    4
  21. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    Oh, I see. Thanks for the bug report. It's fixed for the upcoming version, and now you can use the quick fix.

    Martian-Games, thanks a lot for sharing your WebGL and MMWG experience! I'm sure that many users will find it really helpful.

    However there are some moments that are not very clear to me:
    How could that be? The pinned terrains are generated using this setting, so their resolution should always be equal to the General Settings > Resolution value. Is there any way to generate a pinned terrain of a different resolution than the one in settings?

    Do you mean just switching resolution parameter? I could not make Unity crash by switching it on enabled component, no matter if the terrains were generated or not. Are there any special conditions? Does it always crash or it happens occasionally?
     
  22. Martian-Games

    Martian-Games

    Joined:
    Jan 19, 2012
    Posts:
    43
    Oh, I meant if you make a build with say just 1 pinned Terrain of a higher resolution like 512, but you change the setting to 64 for example just before making a build (without updating the 512 pinned Terrain down to 64) .. then the infinite Terrains will fail in WebGL with index out of range errors. I'm guessing it's related to terrains generated on-the-fly failing to stitch onto the higher res pinned Terrain. In any case maybe not a high priority issue as we ought to remember to keep things consistent anyways. ;)
    It could even be something indirectly related, as WebGL bug reporting is dismal. lol
    -----------
    As for the changing parameter, I meant to say the "Terrain-Size" parameter .. if auto-update is turned on, if the value in the Terrain-Size parameter sits on "000", the CPU will run full tilt and Unity Editor just will not respond (not a full crash, just hangs indefinitely).
    This is a common difficulty when a change in a parameter awakens a change-listener when trying to edit a value of 1,000 down to 2,000 .. because we need to change the 1 to a 2, the change listener for at least a moment thinks we want 0.
     
  23. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    287
    I've been working with MapMagic for a bit, and really like it. I've just set up my first scene using MapMagic to generate non-terrain objects (eg not trees/rocks etc), and I'm experiencing an odd issue.

    I'm using a Scatter to spread pickups around the terrain. Some of my terrain chunks end up with all the spawned gameobjects doubled, though this doesn't seem to happen immediately. When I look at the heirarchy, the terrains with doubled pickups have two "Unity54 Pool Hunk" containers in them, while the ones that are working properly have only one.

    After some more investigation, I figured out that it's somehow related to the terrain chunks being disabled and re-enabled. When I start the game, the heirarchy looks like this within a few seconds (only the first terrain is pinned - others are generated at runtime):



    Once I travel for a bit, some of the existing terrains go inactive briefly, and then re-enable themselves (I'm presuming they're regenerating?). Once this happens, the ones that do the brief disable/enable cycle end up with doubled pool hunks, and doubles of all the pickups:



    Do you have any idea why this might be happening, and how I can prevent it?

    I'm using Unity 5.4.0f1.
    In case my MapMagic settings are relevant, here they are:



    Thanks!
     
  24. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    CodeBison, thanks for your bug report, Object output can really duplicate objects when an object pool is used. I've fixed this bug for an upcoming version, which I plan to submit literally this day.
     
  25. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    287
    Excellent! I figured you'd get to it soon, so I moved on to other parts of development. I look forward to the new version.

    Currently I'm looking at changing the global seed at runtime so I can have different maps every game. It's not immediatly apparent what the best way to do this will be. Since it's a global variable I can just change it, but I'm not sure what else I should be doing to ensure everything gets rebuilt cleanly after the seed changes.

    I'm thinking of starting with the MapMagic object disabled, and enable it after the seed has been set, but I imagine there's a better way. What would you suggest?

    Thanks!
     
  26. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,043
    Hi Denis, Awhile back I asked about handles to aid in placement of nodes with offsets . Will this come any time soon?
     
    Last edited: Jul 17, 2016
  27. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,043
    Trying to use a Simple form - cone as a mask to a blend. I am not able to indicate a offset greater then 1, without generating a

    Code (CSharp):
    1. Generate Thread Error:
    2. System.IndexOutOfRangeException: Array index is out of range.
    3.   at MapMagic.Matrix2`1[System.Single].set_Item (Int32 x, Int32 z, Single value) [0x00000] in G:\Users\Glenn\Documents\U5 Projects\Mysterious Dev\MapMagicTest\Assets\MapMagic\Main\Matrix2.cs:293
    4.   at MapMagic.SimpleForm.Generate (MapMagic.Chunk chunk) [0x002a1] in G:\Users\Glenn\Documents\U5 Projects\Mysterious Dev\MapMagicTest\Assets\MapMagic\Main\MatrixGenerators.cs:495
    5.   at MapMagic.Generator.GenerateRecursive (MapMagic.Chunk tw) [0x000bc] in G:\Users\Glenn\Documents\U5 Projects\Mysterious Dev\MapMagicTest\Assets\MapMagic\Main\Generator.cs:288
    6.   at MapMagic.Generator.GenerateRecursive (MapMagic.Chunk tw) [0x00038] in G:\Users\Glenn\Documents\U5 Projects\Mysterious Dev\MapMagicTest\Assets\MapMagic\Main\Generator.cs:272
    7.   at MapMagic.Generator.GenerateRecursive (MapMagic.Chunk tw) [0x00038] in G:\Users\Glenn\Documents\U5 Projects\Mysterious Dev\MapMagicTest\Assets\MapMagic\Main\Generator.cs:272
    8.   at MapMagic.MapMagic+Chunk.ThreadFn () [0x000dd] in G:\Users\Glenn\Documents\U5 Projects\Mysterious Dev\MapMagicTest\Assets\MapMagic\MapMagic.cs:747
    9. UnityEngine.Debug:LogError(Object)
    10. MapMagic.Chunk:ThreadFn() (at G:/Users/Glenn/Documents/U5 Projects/Mysterious Dev/MapMagicTest/Assets/MapMagic/MapMagic.cs:761)
     
  28. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    I've made some research on the handles topic, and it seems that it will require plenty of work to implement. They are still in my "possible feature list", but I'll go on working on them once I deal with the biomes.
    Simple Form offset will be fixed in the upcoming version (quick fix is available here).
     
    ibyte likes this.
  29. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    137
    Just from curiosity - care to share that "possible feature list"? :)

    A few things that came to my mind:
    • It'd be good to make node windows a bit wider (or make them resizable). Sometimes it is hard to see a prefab/grass/tree name due to very small input field.
    • I'd suggest making portal a two-line layout: first line would contain two buttons and the second line would contain input field/dropdown. This way it would be much more readable, as now it is hard to see names longer than a few characters.
    • What do you think about extending a terrain loading system (see image below). My idea is that you could generate and create Unity terrain tiles (green area) in the close proximity to player (red dot) - and additionaly - only generate terrain tile data for terrains that are further (yellow area, described by other radius). These would be cached and hold in memory. As far as I know there won't be much performance hit, as the "yellow" terrain data would be calculated in separate thread (it could even have low priority), without touching Unity main thread methods.
      This way, when player moves, new terrain would be generated much faster because all needed data would already have been generated and cached. Like a planing a step ahead.
      I see this as a solution for fast moving players and fast paced games, when camera can travel large distances in a short time. I did something like this before and it behave quite well.
      What do you think?

     
    Wright likes this.
  30. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634
    Has anyone used this for Android?? Also when is the ETA on biomes. Thanks.
     
  31. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    kulesz literally everything you've said makes sense and could be implemented. It's really a pleasure to get feedback from the users that are developers themselves - everything is clear and to the point. I've added it all in my to-do list - I'm using wunderlist for that. Unfortunately they disabled the ability to make a list public, but shortly there are these features:
    - low resolution lods
    - RTP compatibility
    - above mentioned handles and gui improvements
    - list of bugs that should be fixed
    - organizational work: make WIP code available to MMWG users and move documentation to public wiki
    You can take a look at the list (at least top of it) screen if you're curious :) Sorry for some Russian entities - I did not initially mean to share it and used for my own purposes.

    recon0303, I was testing MMWG on Android, and it works on my old htc One, at least when the resolution and the map generators count is not high. But if you need to test it yourself email me a couple of words about your project and I'll provide you with a fully functional version to test.

    I plan to start biomes beta in a week or two.
     
    docsavage likes this.
  32. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    137
    Ohh, that's a big one - great to see it on the list :)
    Glad you liked my idea, thank you for sharing the list too (fortunately I know russian enough) :)
     
  33. mr_poyo

    mr_poyo

    Joined:
    Jul 5, 2016
    Posts:
    1
    Hi,

    Love this product. Did anybody figure out how to use the flatten generator? I would like to experiment with the limits of it but I'm still trying to figure out how to hook it up properly. Anybody have a brief "how to" or possibly a picture of all the generators connected and working? Thanks in advance.
     
  34. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    Thanks :) Here is the the simplest example of how flatten generator could be used:
    Flatten.jpg

    The current height (represented as a Height portal) should be assigned to the Canvas input, and the objects - please note that they should be floored - to the Objects input. You can find this scene here.
     
  35. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    Wow - this looks really impressive. Before making a purchase, can you please confirm whether all the map creation features work in runtime too, not just in edit time? (I'll be honest, I couldn't quite follow your distinction of "pinned" terrains and "locked terrains" and whether they relate to my question!).

    So, for example, what I'd like to do is to define a template set of parameters for several distinct environments e.g., a desert environment, woodlands, beach, arctic etc. and then to generate a terrain and place objects based on a selected template but a random seed chosen at runtime? Would that be feasible?
     
  36. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634
    Forgot to ask, has anyone used this with Unature yet?? Which is in beta itself, so many may not have yet.. But this has solved many issues with Unity and grass... when it comes t Frame rate for Android. .. I heard a few say no to me, but they used the free version, so not sure if that mattered...

    @Wright is there a way to test this with it?? before buying UNature is very important to our games..For Android... Thanks!
     
  37. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    The developer of uNature has stated that, although there's a "hack" to make it work with MapMagic, it's not officially supported. (uNature is only available in closed beta currently - I don't think integration with *anything* is officially supported yet! )
     
  38. recon0303

    recon0303

    Joined:
    Apr 20, 2014
    Posts:
    1,634
    Actually it works out of the box for TC2 and GAIA.. and I know the developer for UNature. I don't use hacks. But the reason i'm asking here as I have yet to get much feedback with this tool Yet about it with Unature and I know its in beta, but there are plenty that have used it so was hoping to find someone.
     
  39. Kubold

    Kubold

    Joined:
    May 10, 2012
    Posts:
    358
    Hi,

    I bought the plugin and so far it is amazing! I got a few questions though:

    1. Are the terrains disappearing behind player's back unloaded from memory? Are they saved somewhere on disk and re-loaded when character goes back? Or are they just destroyed completly and re-created again from scratch if player backtracks? Or maybe they are still in memory... (that would be disastrous after generating 100 terrains with thousands of prefabs)? Are all pinned terrains all in memory?

    2. Let's say I changed something on the second, not-pinned terrain in gameplay (for example chopped down some tree prefabs and they are not there now). I traveled far away, so the terrain disappeared, and then I got back. Will the trees I chopped down re-generate? Is there a way to save what I did to this terrain in gameplay, save it somewhere (out of the box or maybe with playerprefs or Easy Save or whatever method), and re-create the terrain again with the changes I made in gameplay? I guess it depends heavly on the answer to my 1. question...?

    3. Is there a way to create a different terrain every time I launch a game, by, for example changing the Seeds numbers and other values in runtime? If not, maybe you could add a "random seed" option, so our terrains could be truly random every time?

    So bottom line - if I make a game using MapMagic, is there a way to save a game (minecraft style - it's procedural on start, but changes can be saved to disk and loaded back) and is there a way to create random terrains at runtime?
     
    Last edited: Jul 20, 2016
  40. CodeBison

    CodeBison

    Joined:
    Feb 1, 2014
    Posts:
    287
    Random terrains at runtime is easy. I'm doing that with my current onegameamonth project. I just launch the scene with the MapMagic object disabled and set its global seed to a random value before enabling it. There may be a better way but this was quick and easy.

    Note that without a pinned terrain to start on you need to wait for the first terrain to be generated before spawning in your player. Thankfully this is easy too. You can link to callbacks to tell you when terrains are generated etc.
     
  41. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    Hi! I have created a locked terrain which has flat terrain exits, when I pin a terrain to generate it and see what it looks like next to the flat exit on the terrain that is locked there is a big drop when the terrains stitch together, so to compensate for this I have increased the height weld margins, which does the job nicely however the trees and rocks from the pinned terrain are floating in the air. Any ideas to avoid this?
     
  42. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    The terrains that are out of the generate distance are unloaded and completely destroyed. They will be re-created if the player decides to return to them, and re-created terrains will not differ in any way from the old ones. The pinned terrains are always loaded, both in editor and playmode, they are just disabling when they are out of the generate distance, but not destroying.

    The easiest way to keep the terrain changes is to pin the terrain before the change was made. The more advanced way is to log all the changed objects - and substitute the object created with MMWG with a changed one using OnApplyCompleted event. For example, you can keep list of all the stumps created after the tree has been chopped. And if the tree position matches stump position it is replaced with a stump from the list.

    Creating unique terrains every time the scene starts could be done using this:
    Code (CSharp):
    1. void OnEnable ()
    2. {
    3.    MapMagic.MapMagic mm = FindObjectOfType<MapMagic.MapMagic>();
    4.   mm.seed = newSeed; //you can use something based on System.DateTime.Now here
    5.   mm.ForceGenerate();
    6. }
    julianr, what are the flat terrain exits? If you flattened the borders of the pinned terrain - try to leave some unchanged space from the terrain edge.
     
  43. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    1,015
    Hi @Wright,

    1.4 is now on the asset store. Can't seem to find the changelog. Out of interest any new features? Thanks:)
     
  44. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    The new version brings mostly the bug fixes:
    • object pool duplicating fix
    • further Raw Input lag fix
    • Raw Input now reads r16
    • curve undo
    • copy component to terrain fix
    • Simple Form offset fix
    • Stamp, Blob and Flatten now work on all terrains
    • other minor fixes
    and some new generators:
    • Clean Up Objects - to remove objects with a mask
    • Intensity/Bias - like brightness/contrast in image editing tools
    • Invert - the one from the manual
     
  45. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    1,015
    Thanks:)
     
  46. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    137
    Sometimes I got strange artifacts on generated terrain - did anyone seen something like this?



    Textures on terrain look fine



    I suspect some NaN in matrices (maybe from blending with division) but I cannot confirm it now.
     
    Last edited: Jul 22, 2016
  47. Cleverlie

    Cleverlie

    Joined:
    Dec 23, 2013
    Posts:
    219
    Hi Wright, first of all I have to say I love your asset, it is very intuitive and has really nice features, plus it is very customizable, love the possibility to do custom nodes, I have a few suggestions and question for you if you can answer when you have some time, I'll leave them here:

    Suggestions:

    • It would be great if you can update the Manual/Documentation of the asset with all new and modified features, for example I have no idea what the flatten and blob nodes are meant to be used, they are practically the same as the stamp node, also you could add more examples of custom nodes or maybe you can create a forum thread posting and promoting the community to share custom nodes, this way I think your asset will have a popularity boost and with community contributions it will be a lot more useful.
    • comments and XML summary comments of methods: this will make your code base a lot more understandable as by now the only way to learn how to do custom nodes with some specific features not explained in the manual, is to read through your code and try to understand how you manage to do things
    • Grouping: it would be great if one can change the color of the group window so you can visualize by color different groups of nodes, also the groups feature is having various bugs, like if you delete a group sometimes other groups or random nodes are deleted and you can't undo this.
    • more integration with RTP: I'm using your asset to create runtime procedural maps that use RTP to texturing and shading of the terrain, right now this is a little tricky, I had to create some scripts that updates splatmaps and switch layers when you switch layers in the textures node, because RTP doesn't know you had moved layers, also every change you do on the mapmagic script keeps resetting the terrain settings and making it use the built-in shader so I have to manually set it to custom shader and go to RTP menu, do some change to make it use the RTP shader again
    • ULTRA MEGA WANTED: GPU nodes, I have been researching papers to implement erosion on gpu for example, but simplier things can be done, for example there could be a GPU blur node that just do a graphics.blit() of the map matrix into a render texture and do the blur in gpu like 200x faster, also I'm planning to implement whatever node I can in gpu with compute shaders because for realtime generation in a RTS game (that's my case) you can´t let the user wait like 3 minutes to generate a map, so in this case I have a few questions regarding how the multithread architecture works, these are below.
    Questions:

    • How do the multithreading works? because I thought that every chunk you receive in the Generate() method is like a tiny part of a terrain, so you can use multithreading in a single terrain, but then I realized that every chunk is entirely a terrain, so if you are not using multiple terrains and just use a single terrain pinned (in my case the RTS map) multithreading will be of no use? or do you process multiple nodes that not depend on each other concurrently?
    • What would be the best way to implement gpu based nodes? I wanna do at least a gpu blur node that makes the matrix into a render texture of type depth (16bit per pixel) and apply a blur shader to this texture, then receive the texture blurred and apply it again to the matrix, but also I want to do some other things, or maybe you are planning to create gpu nodes for next version (that would be AWESOME)
    • I need to import on runtime different map magic sets of nodes, because I need to allow the user to choose like different biomes, then a seed, and then when he plays start I load maybe a prefab or something on the scene containing the map magic object with the node combination for that biome and assign the seed, then generate the map (later I have to do some manual sync with RTP as I explained before, also create navmeshes and stuff for the IA). I couldn't find a way to import on runtime like previously saved presets of map magic, I have to load an entire different scene with the map magic object in it, I tried dragging and dropping the map magic gameobject to the assets folder in order to create a prefab but this broke things and I almost lose all my nodes.
      If there is no way to do this in a simple way already it would be great if you can implement it for the next version, because if I have to keep one scene per different biome (and scenes are like 250mb in size probably because you save all intermediate textures and matrices) I will have a build that occupies 2 gb just for a couple of scenes that holds different biomes, is a waste when the idea is to generate everything procedurally on runtime.

    Im sure I have more questions I cannot remember right now, I've been using your asset for like a month by now and is amazing work, keep on making it great and I hope the MapMagic community grows! Cheers
     
    kulesz likes this.
  48. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    137
    It seems that is is the division (see image below).
    I think it cannot be simply "fixed", as division by 0 and NaN/Inf may always happen in case of specific input. Maybe some kind of warning icon in the node window, that results in such value - just to inform user?
     
  49. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,043
    After upgrading to Unity 5.4f2 and then upgrading to MapMagic 1.4 I get the following error in my projects now

    Serialization error:
    System.ArgumentException: Object type MapMagic.BlendGenerator+Algorithm cannot be converted to target type: MapMagic.BlendGenerator+GuiAlgorithm
    Parameter name: val
    at System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) [0x000a0] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoField.cs:148
    at System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/FieldInfo.cs:150
    at MapMagic.Serializer.Retrieve (Int32 num) [0x00137] in D:\Users\Glenn\Documents\U5 Projects\Mysterious Dev\MapMagicTest\Assets\MapMagic\Main\Serializer.cs:270
    at MapMagic.Serializer+SerializedObject.GetValue (System.Type type, System.String name, MapMagic.Serializer ser) [0x003dc] in D:\Users\Glenn\Documents\U5 Projects\Mysterious Dev\MapMagicTest\Assets\MapMagic\Main\Serializer.cs:123
    at MapMagic.Serializer.Retrieve (Int32 num) [0x00103] in D:\Users\Glenn\Documents\U5 Projects\Mysterious Dev\MapMagicTest\Assets\MapMagic\Main\Serializer.cs:267
    UnityEngine.Debug:LogError(Object)
    MapMagic.Serializer:Retrieve(Int32) (at Assets/MapMagic/Main/Serializer.cs:268)
    MapMagic.SerializedObject:GetValue(Type, String, Serializer) (at Assets/MapMagic/Main/Serializer.cs:123)
    MapMagic.Serializer:Retrieve(Int32) (at Assets/MapMagic/Main/Serializer.cs:267)
    MapMagic.SerializedObject:GetValues(Type, Serializer) (at Assets/MapMagic/Main/Serializer.cs:142)
    MapMagic.Serializer:Retrieve(Int32) (at Assets/MapMagic/Main/Serializer.cs:248)
    MapMagic.GeneratorsAsset:OnAfterDeserialize() (at Assets/MapMagic/Main/GeneratorsAsset.cs:246)
     
  50. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,227
    Cleverlie, each thread generates one terrain from scratch to the final result. So if you have only one terrain multithreading simply does not work. Maybe it's worth dividing your single terrain in 4?

    The reason I prefer multithreading to GPU calculations is that it fits dynamically generated infinite terrain better. GPU generating usually looks great in the editor, but in playmode, when GPU load is usually 100% it can squeeze graphics calculations and produce a some lag. While in most cases the processor cores are not so loaded (maybe except the main unity thread), which allows to use them almost unnoticeable. But in your case, when you have to generate everything before showing the scene it's really a burden.

    I do not have plans for implementing GPU calculations - at least before biomes and Voxeland support - but I think I an toy with them a bit more. Anyways I would not expect 200X performance gain - the last time I tried to make erosion GPU calculations for Erosion Brush it worked at about the same speed with CPU, but complicated everything a lot. Maybe I'm just not cool at GPU programming and optimizations.

    I guess that 250Mb size of your scenes is caused by a pinned terrain. MMWG should not serialize internal procedural matrices, so try unpinning the terrain and saving the scene. Or you can save the data as an asset file in General Settings, and just switch the data on level load using
    Code (CSharp):
    1. MapMagic.MapMagic.instance.gens = yourSavedData;
    2. MapMagic.MapMagic.instance.seed = customSeed;
    3. MapMagic.MapMagic.instance.ForceGenerate();
    kulesz, yap, that's a divide mode of the Blend Generator. I'll deal with the ibyte's problem btw and issue a quick fix.

    ibyte, could you please send me your scene or data asset?
     
    Cleverlie likes this.