Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

MapMagic 2 - infinite procedural land generator

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

  1. valentinwinkelmann

    valentinwinkelmann

    Joined:
    Nov 3, 2014
    Posts:
    187
    Hello Denis, I have a strange issue with the spline output, I get the center tile with the spline output in the right place, but the surrounding tiles are all offset from their actual position. I am using the latest version of Mapmagic and Unity 2022.3.4f1.

    I don't know if this is just a gizmo problem, or the spline object is really getting incorrect information.
    upload_2023-9-24_10-14-4.png

    The Mapmagic graph is not complicated at all. upload_2023-9-24_10-18-0.png upload_2023-9-24_10-18-13.png


    Edit:
    Okay I created a script that places me gizmos at each splineObject.splineSys.lines along the segments. So it seems to be only a bug with the display of the orange spline gizmos of your SplineObject component and not the real positions. So it should not bother me but maybe still useful to fix it.

    A feature request here: It would be great if you could provide a way to output the MapMagic splines as Unity splines, now that we have a decent spline system with unity it would be great if they could be generated directly from MapMagic, that would be super useful.
     
    Last edited: Sep 24, 2023
  2. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    you should be able to write a custom node that caches the splines and does this conversion in an external script you write allowing you to work with them as unity splines, kinda gonna be looking into doing this myself soon
     
  3. valentinwinkelmann

    valentinwinkelmann

    Joined:
    Nov 3, 2014
    Posts:
    187
    Of course, I just mean it would be really useful to have this in the MapMagic spline module right out of the box, because the spline module of map magic is really handy and so is the one from unity, making it combinable by default would just offer a lot of possibilities especially since it's just the official spline package.
     
  4. unity_Ea0raybWi2x2QA

    unity_Ea0raybWi2x2QA

    Joined:
    Sep 21, 2020
    Posts:
    4
    Finally back on this. Here's the code I am using:

    Code (CSharp):
    1.  
    2.                 if (mm != null)
    3.                 {
    4.                     float x = playerTransform.position.x;
    5.                     float z = playerTransform.position.z;
    6.  
    7.                     relevantTile = mm.tiles.FindByWorldPosition(x, z);
    8.  
    9.                     //Check Biome
    10.                     if (relevantTile != null)
    11.                     {
    12.                         DirectMatricesHolder matricesHolder = relevantTile.GetComponentInChildren<DirectMatricesHolder>();
    13.  
    14.                         if (matricesHolder != null)
    15.                         {
    16.                             if (matricesHolder.ValueAtPosition("Snow", x, z) > 0)
    17.                             {
    18.                                 CheckIfStepOrLand(0, footPos);
    19.                             }
    20.                             else if (matricesHolder.ValueAtPosition("Ice", x, z) > 0)
    21.                             {
    22.                                 CheckIfStepOrLand(1, footPos);
    23.                             }
    24.                             else if (matricesHolder.ValueAtPosition("Gravel", x, z) > 0)
    25.                             {
    26.                                 CheckIfStepOrLand(2, footPos);
    27.                             }
    28.                             else if (matricesHolder.ValueAtPosition("DarkCliff", x, z) > 0)
    29.                             {
    30.                                 CheckIfStepOrLand(4, footPos);
    31.                             }
    32.                             else
    33.                             {
    34.                                 CheckIfStepOrLand(0, footPos);
    35.                             }
    36.                         }
    37.                         else Debug.Log("No biome holder!");
    38.                     }    
    39.  
    I think this code works as intended though. I know the code isn't pretty at all, but I have just been messing around. I think the true issue though lies in how I am using matrices. Obviously I have this:



    I use these matrices to check biome, and do things with that, like change music. But for footsteps it would be too generic of a use, too many different surfaces to walk on in a single biome.

    So I tried to do something like this:



    It sorta works, although it has trouble identifying any but the most prevalent textures, such as snow and cliff. Also, the values returned with a debug for each matrix are very small. Like 3 decimals small. Sometimes it's zero at a certain point, and then as I move away from that spot, the value starts going up again. This may just be an effect of me using matrices in a way I am really not meant to.
     

    Attached Files:

  5. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    this should help :


    Code (CSharp):
    1.     /// <summary>Get number of textures added to the terrain</summary>
    2.     /// <param name="worldPos"></param>
    3.     /// <param name="terrain">Terrain to check textures</param>
    4.     /// <returns>Array containing the relative mix of textures on the main terrain at this world position.</returns>
    5.     public static float[] GetTextureMix(Vector3 worldPos, Terrain terrain)
    6.     {
    7.         var terrainData = terrain.terrainData;
    8.         var terrainPos = terrain.transform.position;
    9.         // calculate which splat map cell the worldPos falls within (ignoring y)
    10.         int mapX = (int)(((worldPos.x - terrainPos.x) / terrainData.size.x) * terrainData.alphamapWidth);
    11.         int mapZ = (int)(((worldPos.z - terrainPos.z) / terrainData.size.z) * terrainData.alphamapHeight);
    12.         // get the splat data for this cell as a 1x1xN 3d array (where N = number of textures)
    13.         float[,,] splatmapData = terrainData.GetAlphamaps(mapX, mapZ, 1, 1);
    14.         // extract the 3D array data to a 1D array:
    15.         float[] cellMix = new float[splatmapData.GetUpperBound(2) + 1];
    16.         for (int n = 0; n < cellMix.Length; n++)
    17.         {
    18.             cellMix[n] = splatmapData[0, 0, n];
    19.         }
    20.         return cellMix;
    21.     }
    22.  
    23.     /// <summary> Get most dominant texture given a world position on a terrain </summary>
    24.     /// <param name="worldPos"></param>
    25.     /// <param name="terrain">Terrain to check textures</param>
    26.     /// <returns>Zero-based index of the most dominant texture on the main terrain at this world position.</returns>
    27.     public static int GetTerrainTexture(Vector3 worldPos, Terrain terrain)
    28.     {
    29.         float[] mix = GetTextureMix(worldPos, terrain);
    30.         float maxMix = 0;
    31.         int maxIndex = 0;
    32.         // loop through each mix value and find the maximum
    33.         for (int n = 0; n < mix.Length; n++)
    34.         {
    35.             if (mix[n] > maxMix)
    36.             {
    37.                 maxIndex = n;
    38.                 maxMix = mix[n];
    39.             }
    40.         }
    41.         return maxIndex;
    42.     }
     
  6. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,260
    Thanks for letting me know, I will look into it. Just a quick question: do you have scale applied to MM object?

    Interesting package, wasn't aware of it. Don't know how is it popular, but since it's Unity official stuff I guess it would be a standard, so yes, going to implement it's support.

    I totally agree, it should have this package support.

    I see. Do you see it would be convenient if we will have one matrix - not of floats, but of flags (bytes). And instead matrix holder there will be a monobeh that will do like this:
    Code (CSharp):
    1. string stepsSoundName = thatMonoBeh.GetDominantName("MyStepSound");
    2. //returns "clatter" or "shuffling"
    3.  
    4. string musicSoundName = thatMonoBeh.GetDominantName("MyMusicSound");
    5. //returns music name
    6.  
    And the graph will work like this:
    upload_2023-9-28_9-51-32.png

    Actually permanently storing (I mean after generate process) a couple of matrices of bytes is way better than dozen matrices of floats.
     
  7. valentinwinkelmann

    valentinwinkelmann

    Joined:
    Nov 3, 2014
    Posts:
    187
    No the terrain is scaled to 1000 as default.
    Here 1000:
    upload_2023-10-1_13-45-37.png

    Here 500:
    upload_2023-10-1_13-47-11.png

    So it occurs regardless of scaling of the terrain and always leads to this bug. But I'm glad you're taking a closer look at the problem and adding the Unity Spline integration. If in the future more assets will use the Unity Spline system, this will certainly facilitate the integration with MapMagic, for example, the generation of a river water mesh based on a spline.
     
  8. Rio_TFF

    Rio_TFF

    Joined:
    Aug 4, 2019
    Posts:
    21
    Hello, is there a way to change the edges of a procedurally generated map so that it is not infinite? (e.g. a sudden cliff drop on the edges or something)...

    I love this asset but really don't need it to be infinite. And I don't want to use invisible walls cause that just pisses people off when exploring.
     
  9. launemax

    launemax

    Joined:
    Feb 14, 2013
    Posts:
    16
    Hy @Wright,
    I'm looking for some sort of infinite Terrain, but with limited size.
    Let me explain: I want to create a repetition after a specific size. So you can run infinite to one direction, but will seamlessly get the same terrain over and over again, like in real world, when you go around the globe.
    I just need to show the other end of the terrain sticked to the current terrain and will, after stepping over, teleport the player to the actual point at the other end. its just for a visual illusion.

    Is there a way to repeat the graph at a certain distance to the origin?

    Thanks for your ideas and thanks for this awesome tool :)
    Kind regards,
    Launemax
     
    GreaserMonkey likes this.
  10. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,260
    There's no such feature in MM, but I get requests for it from time to time.
    The problem here is not in repeating terrain tiles - there's no problem to make some tile be generated with offset coordinates. The problem is in blending and reducing seams between repetitions. How we can make terrain start with the same height as the end?

    Cliffs surrounding some area and infinite generate are not that bound together. You can have a limited playable area while using infinite terrain generate. You can use Simple Form with large scale to create your play area bounds and leave it in infinite mode - MM will be able to generate land out of them although no one will ever reach it.

    I meant scale of MM object itself - but from your screenshot I can see it's not scaled. I have it in my to-do list, and will fix it for the next version (that hopefully will get Unity splines support too).
     
  11. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    quick update of where im at with my project...

    Unity_dHBRNKub9O.gif
    upload_2023-10-4_5-41-42.png qhMdSppGCt.jpg pkCKcqzJyM.png
     
    Last edited: Oct 4, 2023
    User414322 and Wright like this.
  12. User414322

    User414322

    Joined:
    Jul 9, 2019
    Posts:
    27
    Scripting question:

    I am generating a terrain in real time for an RTS-like game. Of course, I probably should not do the raycasts for deciding the spawn positions until the terrain has finished generating, so I've tried to subscribe to OnAllComplete as the FAQ indicates. This is my script:

    Code (CSharp):
    1. void Awake()
    2.     {
    3.    MapMagic.Terrains.TerrainTile.OnAllComplete += TerrainGenerationComplete; // Event Subscription
    4.     }
    5.  
    6. void TerrainGenerationComplete(MapMagicObject mapMagicObject)
    7.     {
    8.         BattleManager.SpawnSystem.SpawnPartyUnits(BattleManager.FriendlyTroopCount, BattleManager.SpawnSystem.FriendlySpawn);
    9.         BattleManager.SpawnSystem.SpawnPartyUnits(BattleManager.HostileTroopCount, BattleManager.SpawnSystem.HostileSpawn);
    10.     }

    However, TerrainGenerationComplete does not appear to ever be called. How can I fix this?

    I suspect that I need to feed it a specific map magic object in my scene for it to know when it has finished, but I'm not sure how to do that.
     
  13. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,557
    Image.PNG

    Thank you so much @TheSniperFan - Grass is back in the build:)!

    This has been plaguing me all summer and hindering an update to Unity 2022. Grass was not showing up on terrain on iOS unless I instantiated a terrain in editor first. Since the whole point is procedural generation that wasn't a feasible solution.

    I'm using MapMagic 1, but this was straightforward to back port.

    And thank you to Denis for making MM code open and not locked behind DLLs. This kind of situation is a big reason I chose MapMagic in the first place, and I really appreciate it.
     
    Wright and User414322 like this.
  14. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    create and add a spawnlocation to your pool of placed items using mm nodes - rarify it as necissary, then when it comes time to spawn search the game area for your spawn placed object, and spawn around hat object within a circular radius of 1.
     
  15. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    its not integrated but it can definately be done fairly easily too... kinda...
    if you dont care what your results are its mostly easy for you to generate your tiles and then once you reach a desired x / z then turn off infinite terrain generation,
    catch your players reaching this edge you defined... then theres a few options at this point :
    move the terrain tiles behind the player so they line up with the new "edge"
    or
    make a duplicate draft of the first tile once you can see the edge, and just put the player back on the original tile location once you reach that edge

    what you want to do can be done, you just have to code the handling of the placement of either the char or generated world, honestly the char location is the easier route i think
     
  16. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,260
    I've used this code to check if it works - it does for me. Could you please check it too?
    using UnityEngine;
    using MapMagic.Core;
    using MapMagic.Terrains;
    namespace MapMagic.Tests
    {
    [ExecuteAlways]
    public class OnAllCompleteTest : MonoBehaviour
    {
    public void OnEnable ()
    {
    TerrainTile.OnAllComplete -= Print;
    TerrainTile.OnAllComplete += Print;
    }
    public void Print (MapMagicObject mmobj)
    {
    Debug.Log("OnAllComplete");
    }
    }
    }

    I'm using OnEnable instead of Awake (in Awake MM might be not fully initialized. However it should not prevent subscribing. IDK)
    Also I use ExecuteAlways attribute - just for test purpose, to run it not only in playmode.
    And I'm unsubscribing first to avoid calling Print several times.

    You do not need to provide MM object - more than that, it will give you what MM object has completed generating (if you have several) as mapMagicObject argument by itself.

    These changes are already in MM2 in last version. However, I admit, they were not added to MM1.
    Yes, thanks again @TheSniperFan for finding this way!

    [heart smile]
    Actually MM core uses dll just for the reason it's faster than c# script, but you can find it's code here:
    https://gitlab.com/denispahunov/tools/-/tree/master/
     
    protopop likes this.
  17. User414322

    User414322

    Joined:
    Jul 9, 2019
    Posts:
    27
    Sure thing.

    I gave it a try and unfortunately, it did not work. If this worked for you, then I'm a bit concerned as to why it's not working for me...

    Here are some images of my test (thumbnails, I think they resize to full image). I also tried it in playmode but it had the same result as in-editor.
    upload_2023-10-9_22-40-12.png upload_2023-10-9_22-40-48.png generate-in-editor.gif
    I also have it recorded in video, if you'd like to see it, I can share it via DM or discord or something if that's okay with you.

    That's a rather good idea, though without being able to have my script know when the map is finished generating, I believe this would (or could on slower PCs) cause the object to not yet exist when the script tries to fetch it.
    I could attach a script to that object that then sends the event that the map is ready to be used, but that feels a bit hacky, I'll use it as a backup if I can't subscribe to the MM events in the intended way. Thanks!
     
  18. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    941
    I'm using MM to generate some very low-poly terrain by setting the resolution to _33. However, I notice that grass is then greatly reduced in density compared to more detailed terrain. Is anyone familiar with the generation enough that they know where the grass is applied? I'd like to tinker around with it to increase the density but I feel like I'm looking for a needle in a haystack.
     
  19. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    941
    There is nothing hacky about waiting for the generation to complete and then notifying your other systems when ready. This is just standard operating procedure for any kind of asynchronous work. Not doing it this way is just asking for catastrophic failure.
     
  20. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    mm b like that right? ;)

    to solve this without digging for that - cache your matrix output heights from draft,
    and instead of generating terrain on the high res graph, load in your cached low res heights data.
     
    Sluggy likes this.
  21. User414322

    User414322

    Joined:
    Jul 9, 2019
    Posts:
    27
    Apologies, I did not mean to insult Greviouss method. It's not a bad approach, rather I meant to say that it felt "hacky" on the basis that it is not the "intended" method of doing it, seeing that the official documentation says that c# events can be used for this.
     
    Sluggy likes this.
  22. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    941
    I've determined that it's Unity's fault (I mean, as a once-asset dev myself when is never NOT their fault, amiright?). Their terrain grass density calculations are completely busted. Sweet, yet another reason for their terrain system to be nominated for 'Most Useless Feature in Unity awards' for like the eighth year in a row.
     
  23. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,260
    I don't get it. I tried to reproduce your case, turned off infinite, used several MMs, even the graph with no outputs, restarted Unity several times - but still can't get rid of OnAllComplete. Could you please email me your scene?
     
  24. launemax

    launemax

    Joined:
    Feb 14, 2013
    Posts:
    16
    Thanks for this great idea! Will look into this.

    But as Wright already mentioned. What about stitching these Tiles together? What, if there is a big difference in the height map? I thought about combining this with Terrain Stitching Assets, but I'm not sure, if this is working, also blending or textures in mind. Its a bit more complicated as I tought ^^
     
  25. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    941
    So I managed to track down where the detailResolution for the grass is applied but changing the value results in absolutely no grass.

    I decided to try a quick n dirty naive approach to what you suggested but it's giving really bad results.

    Code (CSharp):
    1.  
    2. var srcHeightMap = Src.terrainData.heightmapTexture;
    3. var destHeightMap = Dest.terrainData.heightmapTexture;
    4.  
    5. Graphics.Blit(srcHeightMap, destHeightMap);
    The high resolution geometry is way off in both shape and position. My guess is that there is some interpolation going on. I'm pretty new to using Unity's terrain system so I don't really know what all they are doing with the data. Any suggestions on how I could get the geometry to match up exactly? Essentially I'd like to have the benefit of the greater subdivisions of the highres terrain so that textures look better but still keep the exact planes that were generated with the low resolution terrain.
     
  26. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    941
    Nevermind. I just ended up writing a simple blit routine myself and handled the scaling manually. Unfortunately, the result is about as bad as I expected with grass clipping above and below the ground due to the differences between the lowres and high res geometry. Back to the drawing board.


    EDIT: Nevermind again, looks like I was being a dummy and looking at the wrong terrain the whole time. Apparently, I can easily change the data and get the grass and whatnot to match with the new heights. Looks like meat's back on the menu, boys!
     
    Last edited: Oct 13, 2023
    Greviouss likes this.
  27. GreaserMonkey

    GreaserMonkey

    Joined:
    Feb 10, 2019
    Posts:
    65
    Hi. For some reason when I preview scatter on terrain it goes like this. Previewed points do not match the terrain tile size. I noticed kind of same thing with splines when I try to preview Interlink node but there preview is offset to the terrain tile. I'm using Unity 2022.3.5f1 and MapMagic 2 Bundle 2.1.14. MapMagic object is not scaled. It's 1:1:1.

    upload_2023-10-14_22-29-6.png



    upload_2023-10-14_22-34-25.png
     
  28. brenchleyderek

    brenchleyderek

    Joined:
    Sep 20, 2019
    Posts:
    4
    Hi @Wright! I'm attempting to use the scatter and stamp nodes to place a stamp around the map. The import node is working when it is directly connected to the height node:

    Dunes Normal.png

    However, when I connect the stamp to the scatter, adjust, and stamp nodes, I can't get the stamp to work as it does in the documentation:

    Dunes.png

    I have tried playing with the density, scale, size, tile v. clamped, offset, intensity, etc., but I'm not having any luck. Do I have the nodes set incorrectly? The source image is quite large, 4096 x 4096. Could that be an issue? Thanks in advance for your assistance! I'm loving this asset -- one of the best I've used!
     
    Last edited: Oct 18, 2023
  29. timothee_le_corre

    timothee_le_corre

    Joined:
    Sep 20, 2023
    Posts:
    9
    Hello, I encounter the same issue as Tarmack. On my side even if my server & my client is on the same computer it's still not give the same result, I found a workaround for the terrain, I send the height map data through the network and apply it in a HeightOutput. But I also have different values generated for objects placement without changing the code or the graph, when I restart the scatter give differents positions but not each time like 1 times/5 my objects are not placed at the same place and the seed doesn't change at all. It's really important in my design that the objects stay at the same place everytime I launch the game. Do you have an idea what can cause this issue ?
     
  30. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    well i cheated - i wrote a 4d node that i have wrap on the x axis to solve my wrapping issue...


    :D:cool:
     
  31. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,260
    It could be used similar to biomes. It will just load the same graph with offset similar to the biome, and will blend it in using automatic map. It's worth thinking over.

    Scatter node generates objects on terrain margins AND scatter additional margins (that's what they are for. You can change them in Advanced), this is why scatter field is bigger than terrain. It also doesn't clamp generated randomized positions with terrain+margin sizes. Preview on terrain shows all the positions generated by scatter - just to let you know that they are here.

    Oh yeah, spline preview on terrain issue for non-zero tile, already fixed for the next version, but thanks for letting me know anyways!

    Might it be that you are using Size of 1 meter? Try setting 100 in Stamp Size, and 0 in Size Factor

    It might be a performance impact, but theoretically it should work. But it's also worth trying to check something of a small size.

    Is it server that generates incorrect positions 1 of 5 times? Is there any way to reproduce it on the client? Does the same happens with C++ disabled?
     
  32. timothee_le_corre

    timothee_le_corre

    Joined:
    Sep 20, 2023
    Posts:
    9
    It's the server that generates incorrect positions, the client doesn't spawn those objects because they are networked. I didn't try to disable C++, how can I do that ?
     
  33. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    @Wright
    Since i could not fniggle an easy way to get microsplat 256 to seemingly be acknowledged by mm, I have moved to the full megasplat package and in doing so I noticed some issues ...

    1 - all the materials seemingly populate incorrectly, they iterate based on thier position in the layer, changing the selected texture does nothing, and swapping positions forces the swapped material to display, but that does not match up with the selected texture, and i dont think that is working as intended?

    2 - if you exceed adding the layers in excess of the texture count you get a hard error that breaks your graph... ctrl z will undo that, if you dont freak out that your graph just randomly broke...

    I have checked that its not just my project, this behavior appears in your sample scene in a new project. and while i hate to post what is probably useless debug data, maybe it will help?
    i have also included the image of it assigning texture display by pos id, but they all are the same texture selected...

    begin debug data :
    -----------------------------------------------------------------------------------------------------------------------
    IndexOutOfRangeException: Index was outside the bounds of the array.
    MapMagic.Nodes.GUI.GeneratorDraw.DrawGeneratorOrPortal (MapMagic.Nodes.Generator gen, MapMagic.Nodes.Graph graph, System.Boolean isMini, System.Boolean selected, System.Boolean activeLinks) (at Assets/MapMagic/Nodes/Editor/GeneratorDraw.cs:56)
    MapMagic.Nodes.GUI.GraphWindow.DrawGraph () (at Assets/MapMagic/Nodes/Editor/GraphWindow.cs:363)
    Den.Tools.GUI.UI.Draw (System.Action drawAction, System.Boolean inInspector, UnityEngine.Rect customRect) (at Assets/MapMagic/Tools/GUI/Editor/UI.cs:245)
    MapMagic.Nodes.GUI.GraphWindow.OnGUI () (at Assets/MapMagic/Nodes/Editor/GraphWindow.cs:227)
    UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <25578071f6e44201aac745680e5c8dfc>:0)
    UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <25578071f6e44201aac745680e5c8dfc>:0)
    UnityEditor.DockArea.OldOnGUI () (at <25578071f6e44201aac745680e5c8dfc>:0)
    UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7b67ea7a31af4ddfa668bdaf9d8bf0c8>:0)
    UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7b67ea7a31af4ddfa668bdaf9d8bf0c8>:0)
    ---------------------- clipped the bottom end cause im sure......
     

    Attached Files:

    Last edited: Oct 21, 2023
  34. LongCon

    LongCon

    Joined:
    Jun 30, 2018
    Posts:
    7
    Hey everyone, having an Android specific build issue with mapmagic related to duplicate NativePlugins.lib file (screenshot below, Unity 2022.3.11f).

    upload_2023-10-22_0-9-31.png

    The only way I could get it to build to device was deleting some files in Mapmagic > Tools > Plugins, i randomly chose the x86 folder and the game works but the infinite terrain generation doesnt work (some areas are randomly completely flat).

    Anyone have experience here and know if these problems are related, and the proper way to solve them? Thanks!
     
    Last edited: Oct 21, 2023
    Wuan23 likes this.
  35. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    ok having worked with this for a few hours now I have a better comprehension of what is going on :

    2 is a fact - if anyone were to add more layers than base textures and Poof... its broken... its definitely counting something wrong there...

    As for 1.... the map magic node is finding indexing and providing the base color name that is stored in the texture names of the texlist.

    ....Instead it needs to be grabbing the clusters list, as the clusters are the actual textures that are going out to the terrain, and you can create custom combinations of the actual textures to be placed out in the world as "a" texture...

    it is currently painting the clusters in the world properly and all... which is the intended action.

    now this all works fine for any and everyone, if they havent altered the clusters at all, and leave it all at default matching names etc to the texture list, cause they are in the same order it works on the surface...

    however... start adding additional clusters or renaming them... either case causes additional issues... Resulting in entries not found that are actually there as unity errors, or just missing textures from the list for the node.. both cases bad... :

    Texture entry on top - cluster on right, terrain painted by mm (with using single cluster for painting) but mm reporting the textures name in node and not listing any custom cluster:
    upload_2023-10-21_10-56-35.png
    upload_2023-10-21_10-51-4.png

    clusters seemingly even give a convinent preview field of the final cluster texture that can be used in the megasplat node in the cluster entry icon field i think:
    upload_2023-10-21_11-34-10.png
     
    Last edited: Oct 21, 2023
  36. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,260
    When you try to run the server graph in editor, does it always generate same objects or produce incorrect results 1 of 5?

    You can try disabling C++ libraries in MM by turning off C++ Native Code in Window - MapMagic - Settings.

    If you describe the steps to reproduce this issue using MM's MegaSplat demo scene I will try to look into it and probably fix - however can't promise I will do it soon. Compatibility issues are usually very troublesome.
     
    LongCon likes this.
  37. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    steps to repeat 1:
    go in your demo scene and just add layers to the megasplat node... boom it will break.
    steps to repeat 2:
    go into your demo scene and open the texture array config, change a name on a cluster - then go look at your node.

    The plugin works and works fine. There are no compatibility issues.
    However it would work better, and more like you intended, if it was not pointing to the wrong variables to populate the node layers with.

    This actually seems easy enough to fix that im gonna TRY to do it myself tonight, im sure ill fall short, but imma try... if i get it i will post the code changes
     
  38. LongCon

    LongCon

    Joined:
    Jun 30, 2018
    Posts:
    7
    Thanks I've disabled C++ Native Code however still have issues with infinite terrain where new tiles fail to load (specifically the first one loads completely flat, but i can see properly loaded tiles beyond that in the distance).

    This may be due to my test phone (LG G6, Android 8) being quite old but wondering if there's any other options to try?

    FYI i found an identical thread but about webGL here, thanks! https://www.reddit.com/r/Unity3D/comments/pwpm3e/webgl_and_infinite_terrain_generation/
     
  39. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    mm

    ill send you a copy of the edits i used to fix this with
     
    Last edited: Oct 23, 2023
  40. timothee_le_corre

    timothee_le_corre

    Joined:
    Sep 20, 2023
    Posts:
    9
    On the server it produce different results 1 of 5. I try to turning off C++ Native Code and now it produce different result everytime. For more precision it's only object placement that is different everytime.
     
  41. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,260
    Yes, I see. Will try to make it better, but can't promise soon. Thanks for steps to reproduce!

    Oh yeah, WebGL. It applies such a strict memory limitations that it's hardly anything decent is possible to generate. Last time I tried it I could make it work with just a couple of nodes and lowest resolution. So I'd rather say MM here doesn't work than it does.

    Have you tried disabling multithreading like this solution recommends?

    Is there any way I can reproduce this and get different results every time, or at least 1 of 5?
     
  42. brenchleyderek

    brenchleyderek

    Joined:
    Sep 20, 2019
    Posts:
    4
    Thank you! I played around with the size, and it worked well.

    I have a few more questions (if you have the time):

    (1) Is there a way to scatter biomes? I've watched your informative video about distributing biomes according to a X or Z gradient, but I would like biome placement to be scattered around the map. I suspect functions would be useful, but I haven't been able to find a good solution. Here is a (not-so-good) solution that I've come up with, but I think I'm missing something. Any suggestions?

    Biome Setting.png

    (2) If functions aren't a good way to blend biomes, I've considered using the X/Z gradient using the BiomesSet200 node, but I would like to randomize the order of biome layers on Start(). I've played around with setting biome layers of the BiomesSet200 node, but I receive a "NullReferenceException: Object reference not set to an instance of an object" for the last line of this code:
    Code (CSharp):
    1. Generator biomesSetNode = mapMagicObject.graph.GetGeneratorById(14017309804167430227);
    2.         BiomesSet200 biomesSet = (BiomesSet200)biomesSetNode;
    3.  
    4.         BiomeLayer[] biomeLayers = new BiomeLayer[1];
    5.  
    6.         biomeLayers[0] = new BiomeLayer();
    7.  
    8.         biomeLayers[0].graph = myNewGraph;
    9.  
    10.         biomesSet.layers[0] = biomeLayers[0];
    (3) My final question is less important (but if you've run into a similar question, I'd love to know). I'm trying to create the effect of rock layers in cliffs. I've played around with the slope, selector, mask, and contrast nodes to assign different textures to different levels of the terrain, but I haven't had any luck. The textures seem to mesh together regardless of the selector values. Here is a picture of the graph and the terrain that is within the 0 - 0.2 selector zone.

    Textures.png

    Thank you for all of your assistance! Again, amazing product, and the more I use it, the more excited I get about the possibilities for my game. Thank you!
     
  43. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146

    This is very possible and i have posted several shots of what i think is atleast a loosely well done implementation aimed at being a planet.
    But...
    You have to custom code your own series of logic that leads up to that biome selection to get the vision you see in your head...
    Yes you can mix and match the nodes in mm to get a loose scattering effect, but mm being an axis neutral infinite terrain generation tool does not natively take into account any of the landscape rules by default without custom logic from you, It does not see your vision, or your final intent... you need more datapoints that you can use to define the biome placement rules, then still, you probably would end up also coding out a biome logic node that understands the data you generate....
     
  44. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    toy around with the smooth range, smaller values are more precise, work your way up - the default 30 settings is usually way to high for most of what ive done
     
  45. allaith

    allaith

    Joined:
    Jan 13, 2017
    Posts:
    4
    hello there,

    first of all great plugin I got the full bundle as it was amazing! I was wondering if there is anyway I can use the flattening node to generate a rectangle flattened shape rather than a circle, or if you can provide me with a simple code so I can make my own node that can do that

    I was playing around with the code here, but its too complicated haha
     

    Attached Files:

  46. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    recently i posted a generic blank node template to the mapmagic discord server, grab that - gut the caps fillers and point to what you need to do...

    welcome to map magic node coding... have fun :)
     
  47. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    I know you want the map magic answer, but if it takes 50 nodes to achieve a look, "is it worth processing?" is a fair question to ask yourself - when you could go the route of global texturing in microsplat for next to zero processing cost...
     
  48. Greviouss

    Greviouss

    Joined:
    May 27, 2016
    Posts:
    146
    why does that not work...
    i think because u need this instead :


    Code (CSharp):
    1.      
    2.         var b1 = new BiomesSet200();
    3.         var c = b1.layers[0] as BiomeLayer;
    4.         c.gen = new Function210(); // your function here... not the layer... its a layer.....
    5.  
     
  49. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,260
    You probably need a mask with simple dots of biome appearing here or there. For such maps I recommend using Noise with low detail, with contrast and brightness adjusted.

    If this is the way you want to randomize your land - it's better to change biome mask seeds rather than changing biome order.
    But if you still want to modify the order - try picking already existing layer, not create new one. Default constructor is for the serialization purpose, new layers are created with editor factory. Try looking into GeneratorDraw.cs AddLayer. In short it generates new id and assigns itself value:
    Code (CSharp):
    1. unitLayer.SetGen(gen);
    2. unitLayer.Id = Id.Generate();
    Textures and MicroSplat outputs use layered masks. They stack them like Photoshop blends layers - higher one atop of the layers below. Probably all of your Selector nodes should have From set to 0 (or Top to 1, depending on the order) to overlap each other.

    If you want to stamp some custom shape it might be worth looking into the Stamp node

    This also might help:
    Writing custom node
     
  50. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    2,260
    New version is available at the Asset Store: 2.1.15

    Here is what it brings:
    • New node: Unity Splines package output - exports generated result to native package splines (enable in Window/MapMagic/Settings)
    • Improvement: Non-uniform Simple Form - allows creating non-square initial shapes
    • Bug fixes:
      • Fixed trees becoming white on SRP
      • Fixed splines preview positioning
      • Megasplat error on layer add fixed
     
    Greviouss likes this.