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.

Map Graph – Node-based Random Map Generation

Discussion in 'Assets and Asset Store' started by InScatterbrain, Aug 3, 2020.

  1. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    221
    Hello! Happy New Year!
    I spent the holidays playing around with Map Graph and I'm really enjoying, especially now that I feel I have a handle of it.
    However, it's unclear to me how to output a texture from Map Graph to be used by other Unity tools. I'd like to generate a terrain with Map Graph, taking that data to use in a tool like Polaris (https://assetstore.unity.com/packages/tools/terrain/polaris-2021-low-poly-mesh-terrain-editor-196648), which can generate a 3D mesh using Textures, or Unity Terrain Data, or RAW.

    I found this page in the manual: https://mapgraph.insanescatterbrain.com/manual/output_parameters.html... but I'm not sure what it does (or how it works).

    Ideally, when Map Graph Runner runs, it would write a 2D texture to a file, and then I could use the Processed() event to generate terrains with Polaris using that 2D texture file. Does that make sense?
     
  2. InScatterbrain

    InScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    222
    I think you're on the right track.

    First off, you'd need a Texture2D output parameter:
    upload_2023-1-8_13-57-0.png

    Then you'd need to assign to it in your graph. Map Graph works with its own TextureData object, so you'll need to convert that to a Texture2D before passing it to the output parameter. There's a node for that:
    upload_2023-1-8_13-57-51.png

    After that you can plug in to the OnProcessed event like in the page you linked to.

    The OnProcessed event gets invoked every time the graph runner has finished processing. You should be able to get the texture from the output parameters like this:
    Code (CSharp):
    1. var texture = outputParameters["Texture Output"] as Texture2D;
    After that you should be able to do whatever you want with the texture. :)

    Does this answer question?
     
    HeyBishop likes this.
  3. InScatterbrain

    InScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    222
    Map Graph v1.22 is now available.

    Changes:

    • Added weights to prefab, tile and tilemap set types. Changing the weight of an entry will change the probability of it being used when generating a map.

    • Min. and max. zoom level can now be set in the new settings window. Which you can find under Tools > Map Graph > Open Editor Settings.

    • Added the Subtract Mask node, for subtracting one mask from another.

    • Made modifications to the initialization scripts to avoid situations where the importing of Map Graph assets gets unnecessarily triggered in newer versions of Unity.

    • Manual: Added "Changing tile/prefab/tilemap set probabilities (weighted random)" page.

    • Manual: Fixed dead link on the Tilemap Sets page.

    • Manual: Added section about coordinate system to the "Creating your own nodes" page.

    Check out the complete changelog here.
     
  4. dhodvogner

    dhodvogner

    Joined:
    Feb 5, 2014
    Posts:
    3
    Hi,
    I try to use Map Graph for one of my projects, but when I try to create a Prefab Set the UI seems broken and I can't add prefabs to the types. (Unity 2021.3.16f1)
    Any idea why this is happening?
    Screenshot 2023-01-23 162208.png
     
  5. InScatterbrain

    InScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    222
    Yes, this is a bug in v1.22. Map Graph v1.22.1 has been submitted, but has yet to be approved. It should resolve this issue.

    In the meantime you can fix this manually, by importing the unitypackage file that's attached to this post.

    Sorry for this inconvenience.
     

    Attached Files:

    dhodvogner likes this.
  6. dhodvogner

    dhodvogner

    Joined:
    Feb 5, 2014
    Posts:
    3
    Thanks for the quick reply :) It's working now!
     
    InScatterbrain likes this.
  7. InScatterbrain

    InScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    222
  8. InScatterbrain

    InScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    222
    I've been getting reports about a bug that started showing up with Unity 2021.3.16. This seems to be related to the latest version of the Burst package. So right now, I'm guessing this is something that needs to be fixed on Unity's end, but I'll keep investigating for a solution on Map Graph's end.

    If you're running into the following error message, my advice would be to stick with Unity version 2021.3.15 or lower, for now.
    Code (CSharp):
    1. Failed to find entry-points:
    2. System.Exception: Unexpected exception while collecting types in assembly `InsaneScatterbrain.MapGraph.Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null` ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'QuikGraph_MapGraph, Version=2.5.0.0, Culture=neutral, PublicKeyToken=null'
    3.   at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in <ebb9e4250ed24cbfa42055e3532ef311>:0
    4.   at zzzUnity.Burst.CodeGen.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00039] in <a2dd15248a25411e914af2a2c82fb63f>:0
    5.   at Burst.Compiler.IL.AssemblyLoader.Resolve (Mono.Cecil.AssemblyNameReference name) [0x00079] in <a2dd15248a25411e914af2a2c82fb63f>:0
    6.   at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00038] in <ebb9e4250ed24cbfa42055e3532ef311>:0
    7.   at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00006] in <ebb9e4250ed24cbfa42055e3532ef311>:0
    8.   at Mono.Cecil.TypeReference.Resolve () [0x00006] in <ebb9e4250ed24cbfa42055e3532ef311>:0
    9.   at Burst.Compiler.IL.Server.EntryPointMethodFinder.CollectGenericTypeInstances (Mono.Cecil.TypeReference type, System.Collections.Generic.List`1[T] types, System.Collections.Generic.HashSet`1[T] visited) [0x0002f] in <a2dd15248a25411e914af2a2c82fb63f>:0
    10.   at Burst.Compiler.IL.Server.EntryPointMethodFinder.CollectGenericTypeInstances (Mono.Cecil.AssemblyDefinition assembly, System.Collections.Generic.List`1[T] types, System.Collections.Generic.HashSet`1[T] visited) [0x00057] in <a2dd15248a25411e914af2a2c82fb63f>:0
    11.   at Burst.Compiler.IL.Server.EntryPointMethodFinder.FindEntryPoints (System.String[] rootAssemblyNames, Burst.Compiler.IL.Hashing.CacheRuntime.HashCacheAssemblyStore assemblyStore, Burst.Compiler.IL.AssemblyLoader assemblyLoader, Burst.Compiler.IL.NativeCompilerOptions options, Burst.Compiler.IL.Server.ProfileDelegate profileCallback, System.Boolean includeRootAssemblyReferences, System.Boolean splitTargets, Burst.Compiler.IL.Helpers.DebugLogWriter debugWriter) [0x0019d] in <a2dd15248a25411e914af2a2c82fb63f>:0
    12.    --- End of inner exception stack trace ---
    13.   at Burst.Compiler.IL.Server.EntryPointMethodFinder.FindEntryPoints (System.String[] rootAssemblyNames, Burst.Compiler.IL.Hashing.CacheRuntime.HashCacheAssemblyStore assemblyStore, Burst.Compiler.IL.AssemblyLoader assemblyLoader, Burst.Compiler.IL.NativeCompilerOptions options, Burst.Compiler.IL.Server.ProfileDelegate profileCallback, System.Boolean includeRootAssemblyReferences, System.Boolean splitTargets, Burst.Compiler.IL.Helpers.DebugLogWriter debugWriter) [0x001d9] in <a2dd15248a25411e914af2a2c82fb63f>:0
    14.   at Burst.Compiler.IL.Server.FindMethodsJob.Execute (Burst.Compiler.IL.Server.CompilerServerJobExecutionContext context) [0x00133] in <a2dd15248a25411e914af2a2c82fb63f>:0
    15.  
    16. While compiling job:
    17.  
     
    Last edited: Jan 26, 2023
  9. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    221
    Pardon the late response! This has been very helpful! Thank you!
     
    InScatterbrain likes this.
  10. InScatterbrain

    InScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    222
    No worries, glad it was helpful! :)
     
  11. InScatterbrain

    InScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    222
    Map Graph v1.22.3 is now available.

    Changes:

    • Fixed bug that would draw lines on the Random BSP Rooms node's preview image and log an error, in situations where the rooms would be 1 in size in either dimension.

    • Fixed bug where the Replace Color node would throw an exception when find and replace colors were the same, whereas it should output the input texture and log a warning.

    • Fixed the "Connected Caves (Cellular Automata)" subgraph so that it now works correctly with non-transparent texture input.
    I forgot to post the changes for v1.22.2 so here's that change:
    • Fixed a bug that caused the weights on set entries to not get saved correctly, resulting in only the first entry being used.

    Check out the complete changelog here.
     
  12. InScatterbrain

    InScatterbrain

    Joined:
    Mar 7, 2017
    Posts:
    222
    Map Graph v1.23 is now available.

    Changes:

    • Added the Noise node. It's build around the FastNoise Lite library, which is now included with Map Graph. Check out the FastNoise Lite documentation for more information: https://github.com/Auburn/FastNoiseLite

    • Added a button to switch between a noise data preview and a texture data preview on the Perlin Noise Fill Texture node view.

    Check out the complete changelog here.