[Released] Beyond Magic: GPU Nodes for MapMagic

[Documentation, Asset Store, FAQ]

GPU processing for MapMagic is out!

Beyond Magic add-on will give MapMagic many long awaited improvements such as dramatic speed-boost, water flow node and other new features. Speed improvements are done by enabling GPU processing and alternatively by including an optimized code and parallel CPU processing support for the nodes. This will enable running MapMagic at a fraction of the time, with no loss of MapMagic features.

Requires MapMagic!
MapMagic is a procedural node-based terrain generation library, required for the add-on. MapMagic World Generator | Terrain | Unity Asset Store

GPU processing and code optimization
The add-on currently features GPU processing support and an alternative CPU optimization.
All map nodes, as well as height, splat and grass outputs have been optimized.

Simple to use!
Automagically co-operates with MapMagic without separate setup. Contains one-click tool to automatically convert pre-existing MapMagic trees.
Always back up your data before attempting to convert pre-existing scene.

Expanded Functionality
Erosion node has been expanded further with alternative algorithms. New map nodes Flow and Curvature added.
The add-on is in active development with further features incoming!

Requirements
Parallel CPU boosts do not require compute shaders, works with MapMagic anywhere.
GPU processing uses compute shaders! Platforms where compute shaders work:

  • Windows and Windows Store, with a DirectX 11 or DirectX 12 graphics API and Shader Model 5.0 GPU
  • macOS and iOS using Metal graphics API
  • Android, Linux and Windows platforms with Vulkan API
  • Modern OpenGL platforms (OpenGL 4.3 on Linux or Windows; OpenGL ES 3.1 on Android). Note that Mac OS X does not support OpenGL 4.3
  • Modern consoles (Sony PS4 and Microsoft Xbox One)

Works with .NET Standard 2.0, .NET 4.x and .NET 3.5 equivalent (deprecated)
MapMagic is obviously required as well.

GPU vs CPU processing
GPU processing handles numerical data slightly differently from CPU processing. We have worked hard to get the GPU to produce nearly identical floating point results compared to CPU version, but some floating point values will still round slightly differently (such as 1.00000000043 vs 1.00000000044). This will normally look identical, but some nodes (such as ruffle in erosion node) use these values as seed values, which means that even a fraction can produce different results in later nodes.

Troubleshooting
Q: I’m getting an error that MapMagicWindow is not a partial class.
A: Make sure you have the latest version of MapMagic installed. Beyond Magic requires MapMagic v.1.10.4 or later to function.



2 Likes

[reserved]

@CodersFromBeyond Instant buy =) Really nice work :wink:

1 Like

Very nice!

1 Like

So I started going through my map’s tree which currently can take a very long time to work, and right clicking each node to Convert to Beyond. I got a few nodes in and then the whole things died :frowning: After converting a Blend node, the graph stopped working and stopped drawing properly and I see this error in the console.

EDIT: Its constantly spamming the console. I’m going to try closing and restarting.

NullReferenceException: Object reference not set to an instance of an object
MapMagic.BlendGenerator2.OnGUI (MapMagic.GeneratorsAsset gens) (at Assets/MapMagic/Generators/MatrixGenerators.cs:966)
MapMagic.BeyondBlendGenerator.OnGUI (MapMagic.GeneratorsAsset gens) (at Assets/BeyondMapMagic/Generators/BeyondBlendGenerator.cs:582)
MapMagic.MapMagicWindow.DrawWindow () (at Assets/MapMagic/Editor/MapMagicWindow.cs:560)
MapMagic.MapMagicWindow.OnGUI () (at Assets/MapMagic/Editor/MapMagicWindow.cs:340)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <23c160f925be47d7a4fd083a3a62c920>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
UnityEngine.UIElements.UIR.RenderChain.Render (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C:/buildslave/unity/build/Modules/UIElements/Renderer/UIRChainBuilder.cs:236)
UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C:/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:60)
UnityEngine.UIElements.UIRRepaintUpdater.Update () (at C:/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:48)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTree () (at C:/buildslave/unity/build/Modules/UIElements/VisualTreeUpdater.cs:72)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:636)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:240)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

Reload of the map didn’t help. My graph now seems to be broken and I can’t figure out how to recover it :frowning: Any thoughts?

I’ll message you, let’s see what the problem is.

So, the Beyond Erosion node doesn’t appear to be doing anything in my tests.

When switching over to GPU it gets even weirder. While now it appears to do – something – it seems very anomalous.

Could you send us the .nodes file? Having hard time reproducing this.

https://www.dropbox.com/s/2sqbmdd38o3n6p4/MM_BM_Erosion.nodes?dl=0

I did some more testing and found a couple things.

  1. If I set “Erosion” to “Cliff” rather “MM-Like” then I get results similar to what MM was giving.
  2. The erosion node with “Generate Changed” rather than “Generate All” does not appear properly deterministic. Once it gets into a bad state as shown above, it will remain that way even if you switch it back to a known working state until such times as I Force Generate All to fix it up.

I’m trying to nail down some consistent repro steps.

Hi,

Thank you for the .nodes files.

I’m the main coder in Coders From Beyond and I have identified few of the problems and started working on the fixes.

  • Beyond Terrace Node GPU version with larger than 0.999f input values was not deterministic.

If you need to contact me directly via Discord, please PM me.

Br,
Tommi

1 Like

Ok I need to walk back the statement about determinism. I don’t think that is what’s happening.

But GPU is definitely causing very bad results for me. I am running with a GTX 1080ti.

Parallel:

GPU:

Ah ok so there was something going on in there. Trying all sorts of things (and waiting between them) makes it dififcult to be sure exactly what is happening.

Ok with that bit of information, I removed the Beyond Terrace and went back to a standard Terrace, and now I can generate everything else in GPU mode without anomalies. Although “MM-Like” still doesn’t generate results like MM. I have to switch to Cliffs for that which seems wrong to me.

So something about that Beyond Terrace is breaking the GPU flow.

One last thing that I didn’t notice originally because of the overlay MapMagic draws is seams. The Beyond Erosion seems to be generating far larger seems than standard MM Erosion does.

Both these screenshots are with Safe Border set to 0, and “Margins” turned off in Beyond Erosion (What exactly is Margins supposed to do?) First is standard, second is Beyond.

Sorry to barrage you with all these issues :slight_smile:

We are working on better seam blending, but it is still heavily in development.

Erosion margins is option whether or not to use margins that the original erosion algoritm uses. All other nodes are calculated with the same resolution as the terrain (such as 512), but with erosion, additional 10 pixel margin is added to every side. This margin helps with border blending but GPUs are designer to work with power of 2 textures, such as 512. With margin the size is 532 x 532 and it is way slower to calculate that.

When generating multiple terrains, it is best to use margins. And usually have some safe borders, such as 10.

Tommi

Here are some erosion examples with different algorithms:


As you can see, original and MM like are not quite identical, but some approximation of the original algorithm.

But with tweaking the values, you can get pretty close.

Tommi

Blend node fixed:

  • Beyond Blend Node GPU and Parallel version: Blending now works without base layer.

We’ll gather bug reports for few days and post a patch during weekend.

Tommi

I’m still continuing to see some very weird results out of the Beyond Erosion node. It is definitely a LOT faster which is great, and lets me experiment a lot faster, but I’m just getting wacky results more often than not. Such as:

Compared to the same settings in standard Erosion:

EDIT: Not sure whats going on with the images. They show fine when I’m editing the post, but not after I save. Here are links:
Vanilla:


Beyond: