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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

MapMagic 2 - infinite procedural land generator

Discussion in 'Assets and Asset Store' started by Wright, Apr 24, 2020.

  1. Erlend1

    Erlend1

    Joined:
    Dec 18, 2019
    Posts:
    20
    Thanks for the help last time. Now I'm struggling a bit with getting wetness from MicroSplat to work with the MM2-generated terrain. I've gotten it to work on a separate, flat terrain with the aid of MicroSplat's terrain FX painter, but that method doesn't seem to work with the MM2's main terrain.

    There are no issues with the snow, just the wetness.

    mm2-microsplat-how-to-enable-wetness-masks-snow-with-mapmagic2-2.jpg
    When I tick off the box for "Wetness Masks Snow", the snow disappears. So my issue is foremost that wetness doesn't work, and I would like to have the rain (wetness) cancel out snow.

    mm2-microsplat-snow-wetness-issue.jpg
    For reference, here's a screenshot of how it would look like with full wetness. The environment becomes very dark with the snow/rain effect in Cozy Weather. From this angle, it also looks like snow, but that would make the whole cliff white.

    I don't think assigning a snow mask is crucial (?), because I didn't do it for the other microsplat material, and rain + snow works on it.
     
  2. Erlend1

    Erlend1

    Joined:
    Dec 18, 2019
    Posts:
    20
    Disabling snow didn't do anything about the wetness.
    mm2-microsplat-disabling-snow-didnt-fix-the-wetness.jpg

    So at the moment, I can only adjust wetness manually.
     
  3. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    329
    Hi,

    I'm using MapMagic brush and noticed it takes a lot of RAM once I add all my terrains to the MapMagicBrush component. I understand it's because it's creating a cache that the system will use.

    I know it's a stretch, but could it be possible to affect the terrains without building a cache? Simply painting directly to it? I know it's made to do way bigger things that require the cache, but if I use it just to paint textures on my terrains, could we bypass this and just... paint? Because the tool is amazing.

    Thanks!
     
  4. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    72
    Feature request : a right click on an empty spot of a graph gives an option to set that point as the new "center"

    This way when you are working on things in visual studio and come back and it reloads your graph - you dont have to fight with it to put it where you want or need it every time, or when you go into a function it also becomes centered where you decide your work is and not some point that is not anywhere near that.
     
  5. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    Unfortunately I'm not a big expert of all the MicroSplat features, and can't advice anything specific, except general rule: to enable extended MS features use Apply Type: Both in MicroSplat output - Advanced to do this. This will export splats together with textures, and make terrain similar to the one created manually.

    Hmmm... the point of cache is to make it paint. And it mostly contains exactly texturing information. It might take up to a couple of settings to create it (depending on stroke size and terrain resolution). So without cache it might take seconds to apply each and every brush stamp.
    Cache is created in editor only. Brush is not working in build, and will not take RAM for final game user.

    What do you think about serializing a position+zoom, and returning to the same place after each script reload? Or centering can come in handy for some other use cases?
     
  6. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    329
    I know, it's just that in order to paint, my level designer has to load over 32gb of cache in RAM, which is far from ideal, while our previous painting tools didn't use that at all. We are working with a lot of terrains. It's fine that clicking takes a couple seconds, but taking the computer's resources entirely is where it hits us...
     
  7. Devosaurr

    Devosaurr

    Joined:
    May 10, 2017
    Posts:
    1
    I have an issue with tile seams, and idk how to fix that - on my tile border i have a little wall, that looks like a asdjacent tile do not blend to my tile, where i need to look at? i don't use the splines, and this problem appear more if i usind 2+ "Flatten" nodes at the row, but without it this problem are still appears.
     
  8. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    I got your point, will think of the way to reduce cache size. Maybe enable cache for closest terrains only, or cache on first click.

    Can you please post/send a screenshots of a seam and your graph?
     
  9. Lewsk55

    Lewsk55

    Joined:
    May 22, 2021
    Posts:
    11
    Hello! Hopefully an easy question: is there a way to create an infinite downhill terrain? Looking to create this for an endless mode in my game. My current workaround is a simple form (Gradient Z) with a huge height and downward sloping curve with the infinite terrain feature. But after my character travels forward for a few minutes of downward sloping tiles, the downward slope eventually runs out and the rest of the infinite terrain has a flat slope. Any suggestions? Thanks!
     
  10. avidwriter

    avidwriter

    Joined:
    Dec 21, 2021
    Posts:
    9
    EDIT2 - fixed by setting downscale to 1 and density to 1000

    EDIT- I'm now getting a stacktrace trying to add or edit my existing working grass layer, restarting unity or deleting the grass node didn't help
     
    Last edited: Jan 24, 2023
  11. JustinFelce

    JustinFelce

    Joined:
    Dec 1, 2022
    Posts:
    3
    Didn't see it mentioned in here, but I wonder what it would take to save changed to an infinite map (chopped trees, holes dug, ect...), and reload from a given map chunk and location within, while applying previous changes. Just got this asset today and haven't looked at the source code or know if such a thing be done with some type of plug-in.
     
  12. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    72
    another approach would be to just move the nodes to the center using the same thing

    user : right click, select set center
    unity : determine what the current offset is for all the nodes in the current graph from that click and what should be the graphs actual center, and move all of them that offset
     
  13. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    I'm afraid it's not possible directly - Unity terrain has maximum height and can not go down below zero (related to terrain origin).

    MM has no built-in functionality for this - it highly depends on your game serialization system. So this will require to create it.

    Just in case: you can center to nodes any time with this small button:
    upload_2023-1-26_18-18-7.png
     
  14. dragon_slumber

    dragon_slumber

    Joined:
    Jun 11, 2017
    Posts:
    26
    Hey there,

    I've been using MapMagic 2 for a while, it generally works great but I seem to have hit a pretty big issue. I change the seed of my MapMakerObject at runtime to generate random worlds, then .Refresh. It works fine in the Unity Editor, but in a build, a lot of the parameters never get set, including the height of the map. I've tested getting Noise directly to HeightMap, it works fine in Unity but not in a build. Scatter works fine and I didn't do extensive research on the other parameters.

    Any ideas on how this could be solved? Thanks.
     
  15. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    Could you please paste a code of what values do you change and how? Just in case, here (Scripting FAQ) is how you can change the seed. I recommend changing seed (or other values) on scene start/awake only - otherwise it won't be blended well together with generating or existing chunks.
     
  16. dragon_slumber

    dragon_slumber

    Joined:
    Jun 11, 2017
    Posts:
    26
    Thank you for your swift reply. I've been using this when I generate my map. I don't do it on Enable currently, I do it on "New Game":

    Code (CSharp):
    1. //_seed is a value from 1000 to 30000
    2. mapMagicObject.Graph.random.Seed = _seed;
    3. mapMagicObject.Refresh(true);
    I tried replacing the seed change to a random Noise but it didn't resolve it.
    Code (CSharp):
    1. mapMagicObject.Graph.random = new Den.Tools.Noise(_iSeed, permutationCount: 32768);
    Also the example script on the scripting FAQ you provided isn't available, the dropbox link is dead (https://www.dropbox.com/s/qb7u9wqn8mh6ig8/NewSeedOnStartup.cs?dl=0).

    My project only has one scene, but before I start changing the whole architecture I'd like to confirm that the scene is the issue
     
  17. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    This seem to be the right way to set the seed. The main thing is when New Game occurs - do you have MM scene loaded at this moment?

    Oops, here is the link: https://www.dropbox.com/s/bi65lun22mcs58o/NewSeedOnStartup.cs?dl=0
    Fixed on FAQ page, thanks for letting me know!
     
  18. dragon_slumber

    dragon_slumber

    Joined:
    Jun 11, 2017
    Posts:
    26
    Everything is loaded at the start of the game, and in fact Scatter seems to work correctly from what I've tested. Everything works without a hitch in the editor, it's just when I make an actual build that I have issues, and there's no error message either which is unfortunate. I also did some further testing using the provided examples and adding only a Scatter into Objects, and it's also not working. I also did it on Scene load at start, that also didn't work. Again, only on builds, works fine in the editor.
     
  19. Sicra

    Sicra

    Joined:
    Jun 28, 2021
    Posts:
    2
    Hello, I've just sent you an email regarding a very troublesome bug with IL2CPP, I'd really appreciate it if you could check it out. Thanks.
     
  20. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    93
    Hello, I made a unity terrain and exported the package. How to import it into Map Magic 2?
    Thanks
     
  21. mailfromthewilds

    mailfromthewilds

    Joined:
    Jan 31, 2020
    Posts:
    204
    i get tons of NULLS errors whenn working with MM but the issue is...

    I lost my project from yesterday when i restarted Unity.
    I thought i removed it by accident but then i tried to remake it, And MM folder dissapeared again when i restarted Unity.

    im using unity 2022.2.2f1 URP and newest map magic bundle version


    (edit seems its cuz of URP im wrking on non-urp and its working fine so far but i need urp for my project)
     
    Last edited: Jan 31, 2023
  22. NestorVG

    NestorVG

    Joined:
    Feb 12, 2019
    Posts:
    24
    I have been working on other things and I have come back to Map Magic not allowing me to pin or unpin tiles. I have restarted my entire computer, uninstalled, reinstalled, and nothing. I can press play and have it to generate the tiles at runtime.

    I click the game object that has the map magic component on the exact same scenes I had before, I click on pin new tile, and it just doesn't show the grid to pin the tiles or anything. Same for unpinning or drafting tiles, it's just not doing it.

    I was using 2021.3.4f1 and now I'm using 2021.3.16 I'm not sure if that has anything to do with it. I will try to investigate this further and in a blank project with my current setup. Also, I'm using the latest version of the asset and the render pipeline is URP.

    Thanks a lot for the support in this forum BTW, it has helped me a lot in the past from similar experiences that other users had and were resolved, but I don't think this has happened to other people before (or at least I haven't found inquiries about this when looking for keywords)
     
  23. Sicra

    Sicra

    Joined:
    Jun 28, 2021
    Posts:
    2
    Your gizmos may be disabled. The button to disable/enable them is in the top right of the scene view, by the eye and camera.
     
    Wright likes this.
  24. NestorVG

    NestorVG

    Joined:
    Feb 12, 2019
    Posts:
    24
    That was it! Thanks a lot, I didn't realize that, it looks like the asset behaves differently when using gizmos and not. If they are disabled, if you select the option to pin/unpin/draft tiles, and then click on the scene, it deselects the object (as well as not showing the tile position)
     
  25. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    What happen in build? Is MM still generating terrain, but only with the old parameters? Could you please make a development build and see if there is any error in a build console?

    MM usually generates terrain from scratch. How do you want to use it on your existing terrain?

    I will really appreciate if you could let me know when these errors occur - and I will try to fix all of them in next version.

    Are you sure it happened because of MM - not package manager or anything? MM has no functionality to remove any files or folders, and it doesn't deal with assets in general - except maybe displaying graph icons. If you will encounter this issue again - could you please memorize and write here what were you doing before to reproduce it?
     
    Last edited: Feb 4, 2023
  26. NestorVG

    NestorVG

    Joined:
    Feb 12, 2019
    Posts:
    24
    I was wondering if there's a way to rarefy objects by "cherry picking" according to certain properties like the height of the object, so that, for example, the object at the highest relative location in a certain radius is kept while the others are removed. I have implemented this myself but I'm looking for the most optimized way to do this.

    For context, I'm trying to use two map magic elements at once: a single map tile with a huge size for the placement of "monuments" (big structures like an oil rig or a fortress), and then using the same terrain generation to create the normal terrain that the players would walk on (offsetting them so that the big tile has its center in the 0,0,0 of the scene and the terrain in the big tile matches the terrain in the smaller tiles) The smaller tiles would have a higher resolution and would be generating the smaller objects. This way I would be able to first place big structures, their splines, and other features that are incompatible with several terrain tiles since they generate individually (which doesn't allow me to obtain relative locations of objects that are very far away or connect them properly with splines).

    What I'm currently doing is generating the overall shape of the terrain with some perling and voronoi (with mountains and seas) and dividing it into "layers" with selectors (I'm currently using only the two deepest layers). Then, on the object side (see image below) I place object locations with scatter, apply slope with the preheight, and use stroke and mask in the order of several "depths" or "heights" I start removing the objects in the least "extreme locations", so that only the objects in the further places from the coast remain. After that, I can use rarify with a radius less aggressive than the one used in the masks and I get some locations that are either in the most extreme locations, or far enough from each other.

    upload_2023-2-2_5-6-46.png

    With this system, I want to add enemies or fortress locations, rare items, etc. in these hard to reach places, which I want to be spread so that they are uncommon, but not to the point where you could generate a confined 4x4km map without these locations present, which might cause issues or lock the progression if a key item cannot be obtained because, out of bad luck, the generated world doesn't happen to have X location which is the only place where this can be obtained (and yes, I could add other ways to obtain these through a deux ex machina but it wouldn't make much sense).
    upload_2023-2-2_4-47-36.png
    This is the result of the currently displayed graph to get underwater locations (the red dots are the locations where I would place these, the area is 16384x16384 units (4 tiles like the one I want to have for the generation of monuments, I added more for display purposes), and the square at the right is 4000x4000 which is the approximate size of a confined game area) I'm probably going to do the same for mountain locations after retouching a few values around.



    If anyone with more experience than me can find a better way to do any of this, I would appreciate the feedback.
     
  27. mailfromthewilds

    mailfromthewilds

    Joined:
    Jan 31, 2020
    Posts:
    204
    Unity_dtZS3IMXTx.png
    more:
    https://i.imgur.com/7BMgV03.png
    https://i.imgur.com/SBZpUWY.png

    why these things happen? these things spawn sometimes and regeneration doesnt always fix them. using 2021 LTS this time. (BTW, i didnt add any nodes that would intentionally create these)
    theyre kinda disrupting the workflow to say the least
    (in this case though (as in, now), regeneration helped.)

    i also sometimes get nulls and other errors when i work with MM.

    loving the asset though. the whole contept of runtime regeneration + randomness + seeds and infinite terrain/hiding faraway terrains is just awesome. these features are very well thought

    edit, some more:
    (this time neither regeneration or seed change helped)
    https://i.imgur.com/W7OAx2D.png
    (ok i got it now, the default draft resolution was too low so i raised it by one and it fixed it, as in, regeneration fixes it now, but these things still appear)
     
    Last edited: Feb 2, 2023
  28. dragon_slumber

    dragon_slumber

    Joined:
    Jun 11, 2017
    Posts:
    26
    In the build MM doesn't generate height, I just get a flat Terrain with the topmost texture, but adding objects with scatter still happens. There are no error messages in the developer console. And again, works absolutely fine when I run the game in the editor.

    I'm including a graph of my current state, hopefully that helps.
    upload_2023-2-2_12-37-39.png
     
  29. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    As far as I remember it iterates all objects based on their id - this way earlier created objects go first. And it removes objects with higher id nearby. This way the it leaves earlier created objects, removing later ones.

    I will appreciate if you could note and write here when these errors occur - I will fix them for next release.

    Hmm, as far as I can see you got no input connection for the Blend node. Theoretically it should not generate anything. Could you please send me the graph so I could look into it?

    Aren't you using Interpolate in height output? What is your Height value?

    There are additional height settings in MM object - Output Settings - Height. I guess it's worth trying change Apply Type for main tiles - SetHeights should be the most reliable, TextureToHeightmap is very different.
     
  30. dragon_slumber

    dragon_slumber

    Joined:
    Jun 11, 2017
    Posts:
    26
    I have no interpolate set in my height output and my height value is 250. Also, I did to use some of the example graphs provided with the assets and encountered the same issues.

    For the MapMagicObject, Height is also set to 250, and I tried both Set Heights and Texture to Heightmap, to no avail. I'm including a display of the settings for the object.

    upload_2023-2-5_21-36-2.png
     
  31. JohnnyRobert

    JohnnyRobert

    Joined:
    Dec 8, 2022
    Posts:
    16
    So the asset itself can't do it but how would one go about generating caves that would work with MM2 ?

    Can we use something like a script that would work alongside MM2 generated chunks for example the script would check if any chunk has been generated then once a chunk is generated it will start generating caves ?

    Is it possible to have a cave that spreads across 2 chunks or more even if the cave initially spawns inside 1 chunk ?

    Just trying to make sense of how such a system could work and if it's even possible or what would be its limitations given the usage context (it has to be compatible with MM2) and procedurally generate the caves at runtime and it would have to work with the same seed that MM2 uses.
     
    Last edited: Feb 6, 2023
  32. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    72
    upload_2023-2-7_2-42-38.png
    recent 66*66 render of my planet building attempts on a 8*16 tile grid...

    takes WAY TOO LONG to do distance calcs for the waterlines currently...
    one biome that borders the desert should have water not in it - but thats a i havent done it yet thing...

    @Wright is there a faster way to calc waterdistance?
    Or an easy way to upscale a matrixworld?
     
    Last edited: Feb 7, 2023
    Tim-Wiese likes this.
  33. mailfromthewilds

    mailfromthewilds

    Joined:
    Jan 31, 2020
    Posts:
    204
    Hey, theres a chance im wrong but it seems that theres no way to set Tag to NULL (maybe adding an empty tag would achieve it, if its even possible, though not sure)

    And also the BOOL genAroundObjsTag is visible in inspector but its not used by any script
    meaning if we change genAroundTag from default value (null) to anything, we wont be able to change it back in inspector:


    again maybe im wrong but it doesnt really seem like genAroundObjsTag is used by any script, and it doesnt turn off the "Generate around tags" feature, according to the code

    if im right then i think even if we can achieve the null option with empty tag, this option is misleading:



    for example here, it doesnt check the bool at all:
    Code (CSharp):
    1.  
    2.                 GameObject[] taggedObjects = null;
    3.                 if (genAroundTag != null && genAroundTag.Length != 0)
    4.                 {
    5.                     taggedObjects = GameObject.FindGameObjectsWithTag(genAroundTag).Where(tagged => tagged.scene == holder.gameObject.scene).ToArray();
    6.                 }
    7.  
    8.  

    its in TileManager.cs
    Code (CSharp):
    1.         public bool genAroundMainCam = true;
    2.         public bool genAroundObjsTag = false;
    3.         public string genAroundTag = null;
     
  34. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    72
    5 mil eve isk says the functionality you cant find is buried in the c++ somwhere and does happen behind the scenes...
     
  35. mailfromthewilds

    mailfromthewilds

    Joined:
    Jan 31, 2020
    Posts:
    204
    oh i see
     
  36. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    72
    this is the approach i am looking at doing, figured id clarify this a bit cause this seems promising speedwise for me ...
    what im unsure how to do is PROPERLY create an upscaled version of a tile (MatrixWorld) on the fly so i can put the upscaled data into it from the lower resolution i am currently sitting on? <--- this is what i need to know how to effectively do plz? (i dont need to use this on the map - this larger matrixworld gets saved off for loading later, I just need the right way to create it so i have a "larger resolution copy" of the tile of my lower resolution tile to apply my upscaled data to)

    I know how to upscale the contents, but what i aim to do is get to a certain node in my graph, then hand that off to upscale the whole tile behind the scenes - (cause upscaling this specific map is gonna be much faster than the time it takes to do the math to even get a low res (66!!!) version of what the node produces, with 128 pushing 30 minutes for a full map to complete.) - then save it to a save file for later...

    once i save that tile data upscaled, i can generate a custom import node if the proper resolution data exists for the current world create it, if not upscale it from the data on hand in the save, and then go from there (making all the super taxing stuff i did a first time world data load i can skip and load in, and improve over time as the process to load this from ram is instant, and i can load in upscaled data as it does not need to be perfect, and move on for now)..

    I considered saving just the contents of the array as a float[,], but that would add additional conversion and creation time to loading and saving during generation that i can bypass by just copying the matrixworld data as a whole in.
     
    Last edited: Feb 7, 2023
  37. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146
    Any MapMagic experts looking for contract work? Please ping me :)
     
  38. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    It depends on what system would make meshes and display caves. What data it would require (voxel? layered heightmap?), in what format, etc. It might be that it won't have chunks at all, or they will be quite tiny compared to usual terrain.

    Nice work!

    It depends on how exactly do you calculate waterdistance, and how precise the result should be. If you iterate in all pixels within radius and see if it's below water level then it's worth trying decreasing resolution, or take every n-th pixel. The better approach might be convert heightmap to contrast 0/1 map, and then per-line calculate fading (1-1-1-0.9-0.8-0.7...0.1-0-0-0) in 4 directions, then combine it all using max. Take a look at MapMagic's MatrixOps.SpreadLinear method.

    And after all you can convert it all to C++. For MatrixOps it increases performance up to 5 times.

    Hmmm, it seems that you are right, it checks genAroundTag==null instead of a checkbox. Thanks for letting me know, I will fix this!

    Currently I'm trying to implement something like that out of the box. It's not so easy as it seems - and it's not about upscaling - it's about saving and accessing from other tiles. How can we make sure that the result is saved? How can we make sure that it's the last version - especially when we start generating several times per second, like when we move the slider. How can we use it for drafts? So, it's very complicated task that requires a lot of design change in MM in general. Should I call this MM3 on release?

    And for upscaling - take a look how Import node works (MatrixInitial.cs, 320). In short: `MatrixOps.Upsize(readMatrix, readPos, readSize, dst);` and `MatrixOps.Downsize(src, smallMatrix);`
     
    Greviouss and mailfromthewilds like this.
  39. dragon_slumber

    dragon_slumber

    Joined:
    Jun 11, 2017
    Posts:
    26
    Did you have further suggestions for me? Anything I can test or logs I can provide or something?

    I've been doing additional tests and when I build from a new project, I can change the seed without any issues, the height changes are being applied appropriately.. In my project, even in an otherwise empty scene, changing the seed dynamically once I create a build makes it ignore various nodes, like set height. This is while keeping as many other parameters the same as I could (same MapMagic graph, same code to change the seed, same Unity version). I've also compared both Project Settings but nothing stood out as being different between my project and a new one.

    Something seems to be interfering at a project level, is there anything else I could look up to compare?
     
  40. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    The only thing I can suggest is transferring all of your project to the new one. I will appreciate if you can make it part by part and see what breaks the project, but anyway it would be better to start with transferring all first just to see that it will really break the project.

    Just to clarify: no, I won't be calling it MM3, and I don't plan to release new MapMagic in near future. All MM2 Bundle owners will get cluster system for free.

    I just want to highlight that cluster system requires a lot of design changes, and some are already implemented. Each new MM2 version has something from clusters under the hood, a change that is needed to make them working.
     
    Greviouss and khushalkhan like this.
  41. dragon_slumber

    dragon_slumber

    Joined:
    Jun 11, 2017
    Posts:
    26
    This is a very big project, it would take me a significant amount of time to transfer this to a new project. I would appreciate if there were another option, like some debug outputs or something of the sort. I'm definitely willing to work with you on this, I've already done a lot of trials on my side, so if I can get some debug tools, I'm definitely willing meet you half way.
     
  42. dragon_slumber

    dragon_slumber

    Joined:
    Jun 11, 2017
    Posts:
    26
    I have an update to my MapMagic 2 issues, maybe you'll know how to solve this. The problem is that Objects don't seem to be generating correctly in Builds, from Scatters. My code previously used GetComponentsInChildren<MapMarker>() to find everything generated by MapMagic 2, which worked fine in the Editor but not as a Build. I've since changed it to directly access the pools from the ObjectPool, but that also is returning Empty in the code. So my guess is that Objects either never spawn, or are deleted immediately after mapMagicObject.IsGenerating() is turned to true.

    Is there a setting I can change to resolve this, a parameter that manages how objects are processed in the Editor compared to a build? Thank you for your patience.
     
  43. Pflosch

    Pflosch

    Joined:
    Aug 22, 2021
    Posts:
    4
    How can I make a prefab from a generated terrain?
    I generate and texture the terrain with MM, then I add some features manually in Unity Terrain,
    At this point I do not want the terrain to be regenerated, and I need to save it as a prefab.
    In runtime, one terrain gets chosen depending on level, and is instantiated.

    If I just drag the MM terrain object to my assets, then drag it back into the scene, the terrain is "invisible" (Objects are in the hierarchy, but nothing's visible)

    What am I missing here?
    There's a group of (green) buttons in the settings/tiles section("save terrain data", "export cluster"...) which I cannot find any documentation on... seems like they could be related? Is there any documentation?
     
  44. mailfromthewilds

    mailfromthewilds

    Joined:
    Jan 31, 2020
    Posts:
    204
    When using BiomeSets, is it possible to stop grass from biome1 appearing on cliffs on biome2 ?

    i tried to exclude it with Slope and Contrast nodes, so that it grass only spawns on flat terrains, but biome2's cliffs are considered 'flat terrain' by biome1.
    Biome1 behaves as if it wasnt merged with mountains at all, it still sees flat ground where theres a cliff, and spawns the grass.

    Is it unavoidable? Or maybe theres a fix or workaround that i dont know about.
     
  45. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    72
    It depends on how exactly do you calculate waterdistance, and how precise the result should be. If you iterate in all pixels within radius and see if it's below water level then it's worth trying decreasing resolution, or take every n-th pixel. The better approach might be convert heightmap to contrast 0/1 map, and then per-line calculate fading (1-1-1-0.9-0.8-0.7...0.1-0-0-0) in 4 directions, then combine it all using max. Take a look at MapMagic's MatrixOps.SpreadLinear method.

    And after all you can convert it all to C++. For MatrixOps it increases performance up to 5 times.
    -------
    And for upscaling - take a look how Import node works (MatrixInitial.cs, 320). In short: `MatrixOps.Upsize(readMatrix, readPos, readSize, dst);` and `MatrixOps.Downsize(src, smallMatrix);`[/QUOTE]

    currently i am creating a subcoordinate grid and saving the coordinates into the dictionary that represent a waterline,
    then i preprocess these into a hashset collecting the subcoords that contain waterlines are closest to them within x range,
    then i run on the cell level selecting the predetermined subcoords and mathing that list to find which one of the closest hashsets of coords have the closest distance to the current cell...

    ive tried cell counting, its not friendly to neighbor tiles, if so, only to neighbor distance +1 usually, and i have tried caching locations on neighbor tiles and counting across those as well, much more neighbor friendly but not very fast or accurate...

    not as easy as it seems is a fair statement.....

    FMM was the solution i was looking at, as this definately requires c++ for the speed to get it done.
     
  46. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    72
    i looked at matrixops, and it would suffer from the same problem i have with everything else, if i do not use an extreme margins i cannot range water very far off the current tile.

    with my slow as garbage method.. i get infinite range and perfect accuracy :


    my theory is to map this out in 66, then upscale and save it to deploy for larger resolutions, as calculating this in 66 takes 6 minutes for the whole world (8*16 tile grid)

    This was also calculated using code that skipped over the margins, with a global mm margin of 5
     
    Last edited: Feb 17, 2023
  47. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,177
    Hmmm... Let me see. I'm going through all UNITY_EDITOR defines that might be related to objects somehow (not brush, debugging or preview):
    • MapMagicObject.cs, 104: makes Update to be called in editor and monitors playmode change
    • MapMagicObject.cs, 124: removes update on MM delete
    • MapMagicObject.cs, 133: updates editor in editor
    • MapMagicObject.cs, 145: switches isPlaying - in playmode it's true by default
    • ObjectsOutput.cs, 131: switches FinalizeIfHeightFinalized subscribe method on initialization for objects output
    • ObjectsOutput.cs, 330: same, but for trees output
    • TerrainTile, 144: switches draft/main in non-playmode
    • TerrainTile, 382: switches between destroy/destroyImmediate for tile remove
    • ObjectsPool, 94: same, but for objects
    • ObjectsPool, 224: same, on clearing
    • ObjectsPool, 204: switches between spawning prefab in editor and instantiating in playmode
    I guess it's worth trying to start with the last three. May I ask you to remove all the code from starting from #if UNITY_EDITOR to #endif inclusive to see if error happens in editor?

    By default MM tile terrain data is saved in scene, so it can't be loaded in other scene to be used as prefab. But you can manually save terrain data as an asset with this button:
    upload_2023-2-18_17-35-34.png
    Once done, you can create a prefab.

    I'm afraid it's currently not possible. I'm thinking of two ways to resolve this:
    - make grass output biome blending selector the similar to objects output: random/scale/pure
    - provide biome mask to inside biomes, so it could be read and used to modify internal generated results
    However probably I'll start to work on it after finishing cluster feature, so not soon.

    Greviouss, you are doing pretty advanced stuff, and I'm afraid I can't imagine anything that could speed it up further.
     
  48. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    72
    @Wright
    Upscaling allowed me to have a waterline, but the interpolation is not quite the level of accurate i need sadly... I was able to actually load a 1024 tile in an amazingly short amount of time and it was ... close, but there were clear breaks in the consistency from tile to tile in some places.

    So... I have looked into the spreadlinear solution you gave me, and if it does what i think, which is angles terrain to the edges giving a slope that defines the farthest regions from the edge - this is exactly what i have been trying to solve, but on a GLOBAL level.... i think if i can merge all the matrixworlds into one giant matrixworld and run spreadlinear, then break up the large matrixworld into the tile sized bits and pass the them back to thier respective tile, this might work.

    I have been poking at this and am hoping for the best on it. I have errors...
    instead of me chipping in the wrong and slower c# direction is there a solution to do this easily somwhere in the asset?

     
  49. Tim-Wiese

    Tim-Wiese

    Joined:
    Jul 7, 2012
    Posts:
    68
    Cluster system? Is there a link to this new feature that explains what it does?
     
  50. FuriousEX

    FuriousEX

    Joined:
    Mar 13, 2014
    Posts:
    47
    Hi there - is there a way to expose a vector3 array to a graph? It would be quite helpful to pass in a set of positions for map magic to operate on. Thanks!