Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Map Magic World Generator - a node based procedural and infinite game map tool

Discussion in 'Assets and Asset Store' started by Wright, Mar 10, 2016.

  1. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    Yes - I've observed problems with refreshing too. In my case, I was trying to simplify my graph by gradually turning off some noise/blend generators to see if I could make generation more efficient while not affecting the output too much. Was surprised to see that I'd removed half of the graph before any perceptible change to the terrain and then, *boom* clicking on the the scene window rather than the mapmagic editor window suddenly made my terrain completely flat! I did occasionally have problems in earlier versions too, but clicking "Generate" seemed to resolve. Now I have to unpin and repin terrain to make it update correctly.

    A second, possibly unrelated bug I've encountered is in using the new Blend generator. EDIT - Actually, forget that, I've just realised the problem: I was combining several non-commutative blend operations (i.e. an Add and a Multiply) in a single blend generator, and assumed that the order in which blends happen is from top-bottom. Of course, it's not - it's from bottom-top, so I was getting the wrong output. This might need to be made more explicit somewhere!

    UPDATE - Weird. Now when I create a new Blend generator node, it has a default "Add" layer (greyed out) in the bottom slot, which makes is obviously the "Base" layer as used to be called in the old generator, and other blended layers are stacked on top of that. But when I first started using v1.7, that didn't appear - there were no layers present in the generator (just like when you create a new output generator), and I had to manually create the first layer specifying the Add mode (which is why I then created all the other layers assuming they would follow the first top-down, rather than bottom-up). Weird serialisation/caching issue following upgrade?
     
    Last edited: Nov 13, 2016
  2. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    I've just encountered another interesting bug/"feature" - up to now we've generally only been testing scenes in the editor, which is fine, but we're now getting to the stage of creating and testing standalone builds on Windows and OSX and we're finding that the terrain textures are not displaying correctly in builds. See attached example:
    MM_texturebug.jpg

    I'm not sure if this is a new bug or not, but looking back through this thread and some Google-fu found a solution - by setting Read/Write flag enabled on all splatmap textures it works correctly. This is the same fix as @terravires described in relation to grass prototype textures, and, like them, I find it's not an ideal solution if it uses up extra texture memory. I've also tried the other suggested solutions (ensuring that there's a pinned terrain in the scene with the textures assigned) but that didn't solve the issue.

    I'm guessing there must be something about the way in which MM is adjusting/applying the textures that requires the RW flag set, but I'm not sure what it is?! Any ideas @Wright?
     
  3. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,807
    It's just a height. Instead of output it to Height Output as made in demo scene I send it to portal to use for villages/

    Jesus, great screens!
    Recently I've toyed with DX11 instanced shaders and I must say that it's really a fast and inexpensive way to reduce the drawcalls. Personally I'm going to use them for batching Voxeland's LODded chunks - with a view distance 1000 and chunk size of 30 drawcalls were a real problem.

    Okay, I've got it, I'll think about including floating point solution in MMWG to work put of the box. Cannot promise that it will support particles and rigidbodies, but at least it will have some basic functionality. For now I'd like to recommend you using the script neoshaman mentioned: MMWG has no built-in floating origin feature, but there are plenty solutions on the Internet, and there are free ones among them. You can take a look at this script (http://wiki.unity3d.com/index.php?title=Floating_Origin).

    tanoshimi, what is your OS and Unity version? Are you using multi-monitor configuration with MMWG graph on the second monitor?
    Well, Add and Multiply are commutative operations, and the layer order does not matter in most cases except one - in case of background layer when they behave incorrectly. It's a bug, thanks for finding it!
    EDIT: Quick fix: MatrixGenerators.cs, line 1202 instead of
    Code (CSharp):
    1.             //preparing output
    2.             Matrix matrix = null;
    3.             if (baseMatrix==null) matrix = chunk.defaultMatrix;
    4.             else matrix = baseMatrix.Copy(null);
    should be just:
    Code (CSharp):
    1.             //preparing output
    2.             Matrix matrix = chunk.defaultMatrix;
    Version 1.7 had two minor patches (without version change), one of them involved blend generator. I don't remember exactly if background layer was added in initial release or in one of those updates.

    As far as I know all of the terrain textures internally have the "read write enabled" flag turned on - that's why your texture is not displayed in build - it's not perceived as a terrain texture by Unity and does not automatically enable this flag. Try profiling texture memory usage on a clean non-MM terrain - you can see that any terrain texture takes double memory - no matter if rw flag is turned on or off.
     
    Last edited: Nov 13, 2016
    neoshaman likes this.
  4. Hakazaba

    Hakazaba

    Joined:
    Jul 1, 2015
    Posts:
    111
    Hmm, That script seems a bit heavy, changing the floating point data every frame. I'm not sure if it will really help too much in this case either because even if you make the floating point origin where your action is, the map magic gameobject will still be floating in the far distance and possibly causing problems.

    Also, is there a way to send data into biomes? For example, getting the height of the terrain or a noise map generated in the parent nodegraph?
     
    Last edited: Nov 14, 2016
  5. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    Windows 10 64bit, Unity 5.3.3f1. Yes I am using a multi-monitor configuration and yes I do have the MM editor window on the second monitor! (impressive mind-reading there...)
     
  6. pigglet

    pigglet

    Joined:
    Aug 13, 2014
    Posts:
    113
    I hope this alghoritm could be implemented in the custom nodes of mapmagic! (in the ideal, better world) :D
     
    StevenPicard likes this.
  7. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    507
    thanks! i hope so too ;) but my post somehow dont get much attention it seams :p
    nevertheless, here is the more or less final result:

    carve.gif

    what happens there is the following:
    - calculating a path with A*

    - since now 1 path had around 200 waypoints, it gets shrinked down to around 11 (here is a small bug, sometimes either the first or last point gets destroyed while doing this - thats why the end are looking so bad. so if someone knows how to shrink down an array by 10% BUT keep the first and last point, please dm me :) )

    - then i draw a spline along these points with mega shapes(i guess you can do this with every spline solution or your own)
    - then i carve the terrain under the mesh to avoid overlapping terrain on the street.

    some notes:
    the most frame rate drops are during the mesh generation and carving. still try to optimize that. the best would be to not use a mesh at all, rather than "paint" on the terrain under the A* path.
    i tried to figure out how to do this (https://forum.unity3d.com/threads/terrain-paint-on-terrain-between-2-or-more-vector3.440641/) but: now answer == no progress
     
    protopop, XPAction and StevenPicard like this.
  8. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    720
    Der Kevin, I agree with pigglet. This would be a great feature in MM.
     
    Der_Kevin likes this.
  9. Hellhound_01

    Hellhound_01

    Joined:
    Mar 5, 2016
    Posts:
    86
    @Exbleative Thanks for the hint I will check this out. It's look like only the offset is reset when the game is started, also the generated terrain doesn't regard those settings. Because I'm actually sick, the fix could be take some more time ...
     
  10. vampir26

    vampir26

    Joined:
    Mar 29, 2010
    Posts:
    102
    Hello!

    Map Magic is very great "tool"!

    There is one question:
    I'm trying to plant palms at beach, but prevent them to grow under the water level. I cannot figure out, how I can solve this. Can somebody give me a hint?

    Thanks!
     
  11. Hellhound_01

    Hellhound_01

    Joined:
    Mar 5, 2016
    Posts:
    86
    Exbleative likes this.
  12. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    Run your terrain height into a curve generator that outputs 0 for all heights less than your water level, and 1 for all heights above. Then use the output of that curve as the "Mask" into your generator that places the palms.
     
  13. vampir26

    vampir26

    Joined:
    Mar 29, 2010
    Posts:
    102
    Thank you for answer. It's not working for me :(
    I did it like this:
    Portal Height Output -> Curve (straight line, height = sealevel) -> and now?!
    I tried lot of things. Currently I use "Blend" to subtract it from the "Beach Map" and use this as "Soil Map". But it dont work!
     
  14. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    It sounds like you're using the Curve incorrectly - see below: terrain height is on the x axis, and the mask which you're going to use to determine if a tree is produced is on the y axis. So you should output 0 for any height values below your water level (i.e. to the left of the vertical line) and output 1 for any height values above your water level.

    Note that the x value of that vertical line is the height of your water level, as a proportion of your overall terrain height.

    MM_trees.jpg
     
    malkere likes this.
  15. Henzu88

    Henzu88

    Joined:
    Feb 6, 2016
    Posts:
    19
    I was able to figure it out after some testing :)

    I came out with another problem. For some reason squares has sometimes different lightning as shown in picture. I don't know is it bug or no but how it could be solved. My settings are shown in another photo.


     
  16. pigglet

    pigglet

    Joined:
    Aug 13, 2014
    Posts:
    113
    As I remember, mapmagic have curve implementation for roads and rivers in a roadmap. Right after the integration with voxel plugin. So it will be solved inside mapmagic anyway (I suppose :) )
     
  17. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,316
    Is there a changelog? I wrote some custom generators and the underlying classes seem to be changing a lot; it would be good to have a short overview of what the changes are.
     
  18. vampir26

    vampir26

    Joined:
    Mar 29, 2010
    Posts:
    102
    Thank you very much :)
    My "curve" was horizontal not vertical...
     
  19. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,807
    As far as I can see it just evaluates the camera position every frame, but moves all of the objects only when position exceeds some threshold.

    It's not possible to send any data into biomes - biomes are separate independent graphs. They were designed to be able to be assigned as a main graph and work apart from any other graph in scene.

    I have a task to make world better in my schedule - at least at least at the part that concerns implementing splines :)

    Henzu88, I'm not sure what causes that bug, but I thinks it's worth trying to re-build scene lighting. Looks like terrains ambient/reflection cubemaps does not match.

    makeshiftwings, you can view the changelog in asset store by pressing on the version number. As far as I can remember there were no API changes in 1.7 - it was mainly a bug fix version. What your custom generators are complaining about - maybe I've just missed something in changelog?
     
  20. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    My custom generators all broke when upgrading from v1.3 - as I recall, the problem was that the signature for the Generate() method changed - it used to be Generate(Chunk) and became Generate(Chunk, Biome). This is not explicitly documented in the changelog anywhere.

    (Also, as I've commented in the past, the examples in the online manual are still incorrect and based on the pre-v1.5 syntax :)
     
  21. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,316
    Ah ha! Thanks.

    The changes were mostly in 1.6 and 1.5 I believe. A bunch of method signatures and interfaces changed. As tanoshimi mentioned, Generate takes a Biome, but also:
    Layer added guiHeight, changed OnAdd() and OnRemove() to OnAdd(int n) and OnRemove(int n), added OnSwitch(int n), DrawIcon() changed, Chunk.apply works differently, etc. I think I figured out what most of it means but a little more info in the notes would be good.
     
    tanoshimi likes this.
  22. Henzu88

    Henzu88

    Joined:
    Feb 6, 2016
    Posts:
    19
    I rebuilt my scene lightning but it didn't help but when I changed terrain material to 'Built In Legacy Diffuse' or 'Built In Legacy Specular' from Map Magic settings the problem was solved. :)
     
    malkere likes this.
  23. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,807
    I did not suppose that layers would be used by others - if only I could make them private (which is not possible because they are used by other classes) or internal (which has no effect since MM comes in source code) I would. I'm afraid that layers will change in the next version greatly - Voxeland uses Layout.cs too and it required the new approach: there will be no ILayer interface, and Add, Remove and Switch functions will be used as delegates.

    I thought about a way to use the standard EditorGUI functions in generator's OnGUI function so you can script anything you like using the familiar methods. But as a drawback such generators could not be zoomed out, so I don't really sure if it's worth it.
     
  24. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,141
    That trade-off wouldn't really be necessary since you'd have the best of both if you implemented something like the logic gates as described in my post here:

    https://forum.unity3d.com/threads/m...ite-game-map-tool.390920/page-19#post-2844090

    This setup would allow the best of both worlds.
     
    Last edited: Nov 18, 2016
  25. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    420
    I think there is a bug! when resolution is 4096 textures doesn't work at all, it will cover map only with base texture. but when I back to 2048 textures works again. please help thanks.
     
  26. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    I don't follow this... your previous post seemed to be about exposing arbitrary input values that could be used (and combined with logical operators) as generator inputs at runtime. How does that relate to the ability to zoom in/out of GUI elements in the MapMagic editor window?

    Have you tried creating a custom generator for your logic gates example? Doesn't seem like it would be too hard though I'm unsure of the example use case of e.g. a day/night cycle - are you proposing constantly regenerating all terrain chunks (even the one the player is currently standing on) every time the value changes?
     
  27. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,807
    Crossway, I don't know exactly when Unity made this change, but in 5.4 you cannot set terrain control map resolution larger than 2048. Try creating a new terrain and set it manually, not using MM - it just resets to 2048. I guess I should lock resolution of 4096 since Unity does not support it anymore.

    Hmm, it's unclear to me too. I don't really understand what do you mean by the "logic gates". How could the boolean logic be used with a map? Could you please make some sort of a scheme or pseudo-graph using a boolean gate?
     
    Crossway likes this.
  28. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    420
    My terrain is big I must use 4096. I had 25 tiled terrains each one was 4096 but there was no performance issue. frames locked on 60 fps. should I wait for new version of there is a quick fix? thank you.
     
  29. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,807
    This is the way Unity works - it does not support 4096 control maps. Unfortunately there's nothing I can do with it. The only thing I can recommend you is splitting terrains in 4. Btw applying control textures lag when using 4096 maps is rather noticeable, so switching to 2048 will make it more smooth.
     
    Crossway likes this.
  30. Henzu88

    Henzu88

    Joined:
    Feb 6, 2016
    Posts:
    19
    How I can prevent trees to go inside water like shown in picture below. I am using biomes and I make one biome so low that it makes a lake. How I can prevent that trees and grass would not go under water. Or maybe I should create a lake a different way.

     
  31. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    486
    Maybe make a lake biome?

    The other way is to reconsider how you're applying the water to your scene. If you're applying it universally, then that might cause issues unless the biomes are all pre-set to support lakes at that height.
     
    Henzu88 likes this.
  32. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    420
    Then I should create 100 tiles instead of 25 tiles :( why they did that. :(
     
    Last edited: Nov 20, 2016
  33. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    420
    I'm going to ask them to increase control map resolution again.

    When we still can set height map resolution to 4096 in unity why control maps resolution should be 2048?
     
  34. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    Oddly, I looked through all the recent release notes and can't find any mention of a change to the max terrain control resolution. Are we sure it's not an accidental regression bug?
     
    Crossway likes this.
  35. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    420
    I heard with World Creator we can create a map with resolution of 8192 :eek: how is that possible with world creator but not map magic?
     
  36. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,141
    Not quite. I would use logic gates to do things like swap between different textures displayed dynamically, say for example, with a shader, where the player is standing (I probably wouldn't do geometry changes there, but farther away would still be an option).

    In cases where geometry would need updating, I'd replicate what happens in the editor to display the current local (or some distant) terrain chunk by swapping node paths (similar to how layers work, except instead of combining them, you select between them using some logic gateway(s) to decide your path to the next node path). Sure it would require some time to compute, especially if you are affecting a LOT of terrain geometry, but for local stuff or some specific terrain, it would take as much time (or even less time) than it does in-editor.

    Changes to distant terrain, though, could be applied to the algorithm of the generated terrain at the time of the camera's approach to any affected terrain(s).


    EXAMPLE:

    Imagine if you're standing across the world with a remote-control and you set off a bomb far away, you could return to the area the bomb was previously and see it has impacted the shape of the land you were at. You could tell the player "you heard a large explosion far away, you should go check it out!" and they would find the terrain had been altered, exposing new areas or items based on the changes (props could be swapped out with ones that matched the new terrain vs. the old terrain.) The two terrains would already be in the MM nodegraph, but the only difference is the second terrain would be the one generated instead of the original (that happened BEFORE the bomb exploded). This wouldn't have to even be dynamic as long as the terrain is generated as you approach it.

    In the above example, you'd have two paths of terrain generation that could take place as the player approaches the area in question. The logic gate node would be displayed with a variable input, and a value + operation (greater-than, less-than, equal-to, and invert) + evaluation method (and/or), with each operation leading to each new branch of terrain generation (one WITH the crater from the bomb, and the other without that crater.) If one needed more logic, you could string another logic gate to each branch (such as the variable indicating whether there was an NPC nearby after the explosion, leading to generation of a crowd around the dead body and some dialogue options). The two versions could even be precalculated, with only the logic being dynamic, depending on how one wants to go about it. I'd prefer it to be more dynamic, but that's just me.


    So many possibilities.


    Basically, it has nothing to do with zooming-in/out specifically, but rather it has to do with maintaining the scriptable flexibility Wright proposed without having to lose the zooming abilities of the editor by using the editor itself to do the actual scripting via logic gates.
     
    Last edited: Nov 20, 2016
  37. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    Still not quite sure I follow, but nevermind! I already wrote a custom generator that randomly chooses one of an arbitrary number of inputs to send to the output. It sounds like you'd be able to get what you want by modifying that to accept a determinant variable of which input to choose instead?
     
  38. Hakazaba

    Hakazaba

    Joined:
    Jul 1, 2015
    Posts:
    111
    Hey, i figured out how to offset the chunks that are generated so that we can call specific chunk coordenates that we want to generate, It requires some manual coding though to edit map magic, ill post these in the hope that they become part of map magic.

    You will need to add an offset variable to MapMagic.cs and MapMagicEditor.cs (also add it to the ui at the bottom of this too)

    Then, in TerrainsGrid.cs, you edit these sections to be like this:
    Code (csharp):
    1.  [code=CSharp]
    2. public override void OnCreate (Chunk chunk, Coord coord)
    3.        {
    4.  
    5.   Coord newCoord = new Coord(coord.x + (int)(MapMagic.instance.offset.x), coord.z + (int)(MapMagic.instance.offset.y));
    6.          //creating gameobject
    7.          GameObject go = new GameObject();
    8.          go.name = "Terrain " + newCoord.x + "," + newCoord.z;
    9.          go.transform.parent = MapMagic.instance.transform;
    10.          go.transform.localPosition = coord.ToVector3(MapMagic.instance.terrainSize);
    11.  
    12.          //creating terrain
    13.          chunk.terrain = go.AddComponent<Terrain>();
    14.          chunk.terrainCollider = go.AddComponent<TerrainCollider>();
    15.  
    16.          TerrainData terrainData = new TerrainData();
    17.          chunk.terrain.terrainData = terrainData;
    18.          chunk.terrainCollider.terrainData = terrainData;
    19.          terrainData.size = new Vector3(MapMagic.instance.terrainSize, MapMagic.instance.terrainHeight, MapMagic.instance.terrainSize);
    20.  
    21.          //chunk settings
    22.          chunk.coord = newCoord;
    23.          chunk.SetSettings();
    24.          chunk.clear = true;
    25.          //if (!instance.isEditor || instance.instantGenerate) { chunk.start = true; }
    26.  
    27.          MapMagic.CallRepaintWindow(); //if (MapMagic.instance.isEditor) if (RepaintWindow != null) RepaintWindow();
    28.        }
    29.  
    Code (csharp):
    1. [code=CSharp]
    2.       public Terrain GetTerrain (int x, int z, bool onlyComplete=true) //for welding and neighbours
    3.        {
    4.          Terrain terrain = null;
    5.          
    6.          Chunk chunk = MapMagic.instance.terrains[x- (int)MapMagic.instance.offset.x, z- (int)MapMagic.instance.offset.y];
    7.          if (chunk!=null)
    8.            if (chunk.complete || !onlyComplete) terrain = chunk.terrain;
    9.  
    10.          return terrain;
    11.        }
    12.  
    There are probably a few bugs that will need squashing, but this works for what im doing at the moment, i hope this will be supported at some point.


    Also, Im planning to try and do something to ease up on terrain hight errors.

    Currently, if your terrain height is around 10000, You get terrain stepping visual errors. I'm not sure if this is mapmagic rounding or not, but im thinking that we could possibly have terrain height a bit less absolute.

    This is important for large terrains that move between underwater to hills to mountain tops across large number of chunks. Rather then ma6ping each chunk the same height, we could clamp the relevant sections, set the height to be appropriate for that clamped section, and translate the chunk up to where it needs to be.

    To put it simply, if we have 2 chunks next to each other with a gradient. x goes from 0 to 0.5 and the y goes from 0.5 to 1. x and y are both only using 0.5 of the total terrain height setting of 1. So we could improve it by having map magic set the terrain height of each chunk contextually. With this method, it would also be possible to make use of those values above 1 in map magic as well, which currently make mountains added to terrain via a blend mode with add make ugly caps once they reach the max terrainheight. Max works for this, but there are other reasons why someone might want to add instead.
     
    malkere likes this.
  39. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    486
    If your terrain height is 10000 you're 1.2km above the peak of mount everest and maybe need to rethink your game layout.

    Even giving a very generous 2km (for the abyssal plains which start at 2km-4km) depth beneath water, you should be able to convey hills and mountains to players with 3-4km above water for a total of 5-6km height range.
     
    malkere likes this.
  40. Hakazaba

    Hakazaba

    Joined:
    Jul 1, 2015
    Posts:
    111
    Consider that 10000 needs to fit deep underwater gauges as well as the peaks of Everest. It was just an example anyway, the stepping is noticeable past 4000.
     
  41. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    486
    OK, well doing the math, and assuming that using 16-bit heightmaps gives you ~65k distinct heights. 64k / 4k alt gives you 1/16, which is what, 0.08m or 8cm 'steps'. That's the minimum the height can change between pixels, and all height will be a multiple of that.

    If you go to 10k, that's 2.5x that minimum heightstep, so about 20cm, about 1/5th of a meter.

    Unless it's a 8-bit heightmap? That'd only give 256 heights, and surely it's higher than that.

    I could have fluffed my math though and it's not actually 65k heights?
     
  42. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,141
    Sure! I'd love to check it out if you don't mind! Maybe I could make some use of it!
     
  43. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,807
    I guess you've overlooked the sign bit - the negative values are not used in the terrain - so the actual step is 10k/32752 ≈ 0.305, which is confirmed experimentally:
    10kStep.jpg
    Hakazaba, as far as I know the height of 10000 is not very trivial for games. For comparison, Skyrim or Fallout: New Vegas game map sizes (in x or z axis, not in height) is just 5.75km, which is about two times smaller than your elevation difference. Guess you're using some kind of planetery-sized terrain, which could be great nontrivial USP, and nontrivial USPs require nontrivial solutions. For instance, MMWG work with floats, so you could still use it, but offset terrain transform height OnApply, reducing each individual terrain height.

    awesomedata, aha, now I follow you. Here is the example of the simple switch generator:
    Code (CSharp):
    1. [System.Serializable]
    2. [GeneratorMenu (menu="Custom", name ="Input Switch", disengageable = true)]
    3. public class InputSwitchGenerator : Generator
    4. {
    5.     //input and output properties
    6.     public Input inputOff = new Input(InoutType.Map);
    7.     public Input inputOn = new Input(InoutType.Map);
    8.     public Output output = new Output(InoutType.Map);
    9.  
    10.     //including in enumerator
    11.     public override IEnumerable<Input> Inputs() { yield return inputOff; yield return inputOn; }
    12.     public override IEnumerable<Output> Outputs() { yield return output; }
    13.    
    14.     public static bool on = false;
    15.  
    16.      public override void Generate (MapMagic.Chunk chunk, Biome biome=null)
    17.     {
    18.         Matrix m = null;
    19.         if (!on) m = (Matrix)inputOff.GetObject(chunk);
    20.         else m = (Matrix)inputOn.GetObject(chunk);
    21.  
    22.         if (chunk.stop) return;
    23.         output.SetObject(chunk, m);
    24.     }
    25.  
    26.     public override void OnGUI ()
    27.     {
    28.         layout.Par(20); inputOff.DrawIcon(layout, "Off", mandatory:true); output.DrawIcon(layout, "Output");
    29.         layout.Par(20); inputOn.DrawIcon(layout, "On", mandatory:true);
    30.         layout.Field(ref on, "On");
    31.     }
    32. }
    As an example I use static "on" variable for the simplicity so the switch could be turned on with InputSwitchGenerator.on = true anywhere in your code.

    tanoshimi, I've just checked Unity 5.2.1 - it's not possible to set control map size more than 2048 too. Now I'm not even sure that there ever was such a possibility. Sorry if misled someone.

    Henzu88, I guess water is placed below some level - in this case you can mask trees scatter by curve:
    ClampTreesByHeight.gif
     
    Henzu88 likes this.
  44. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,807
    Speaking further about switch generator - here is a modified ready to use code:
    Code (CSharp):
    1. [System.Serializable]
    2. [GeneratorMenu (menu="Custom", name ="Input Switch", disengageable = true)]
    3. public class InputSwitchGenerator : Generator
    4. {
    5.     //input and output properties
    6.     public Input inputOff = new Input(InoutType.Map);
    7.     public Input inputOn = new Input(InoutType.Map);
    8.     public Output output = new Output(InoutType.Map);
    9.  
    10.     //including in enumerator
    11.     public override IEnumerable<Input> Inputs() { yield return inputOff; yield return inputOn; }
    12.     public override IEnumerable<Output> Outputs() { yield return output; }
    13.    
    14.     public bool on = false;
    15.     public string tag = "Switch";
    16.  
    17.      public override void Generate (MapMagic.Chunk chunk, Biome biome=null)
    18.     {
    19.         Matrix m = null;
    20.         if (!on) m = (Matrix)inputOff.GetObject(chunk);
    21.         else m = (Matrix)inputOn.GetObject(chunk);
    22.  
    23.         if (chunk.stop) return;
    24.         output.SetObject(chunk, m);
    25.     }
    26.  
    27.     public override void OnGUI ()
    28.     {
    29.         layout.Par(20); inputOff.DrawIcon(layout, "Off", mandatory:true); output.DrawIcon(layout, "Output");
    30.         layout.Par(20); inputOn.DrawIcon(layout, "On", mandatory:true);
    31.         layout.Field(ref on, "On");
    32.         layout.Field(ref tag, "Tag");
    33.     }
    34.  
    35.     public static void Switch (string tag, bool on)
    36.     {
    37.         foreach (InputSwitchGenerator gen in MapMagic.MapMagic.instance.gens.GeneratorsOfType<InputSwitchGenerator>())
    38.             if (gen.tag == tag) gen.on = on;
    39.     }
    40. }
    It does not use static bool and iterates in mm generators automatically. It has a tag string parameter to identify switches, so you can call static function InputSwitchGenerator.Switch (string tag, bool on) to turn on or off all of the switches with current tag.
    Code (CSharp):
    1. InputSwitchGenerator.Switch("GreenGrass", true);
     
    boysenberry likes this.
  45. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    420
    So then can we texturing a 4096 map with map magic in next version? I don't understand about this kind of matters but how resolution of control map is related to map magic texturing?
     
  46. Wright

    Wright

    Joined:
    Feb 26, 2013
    Posts:
    1,807
    MapMagic is not a terrain engine, it just generates height, texture, grass, trees, etc for the standard terrain. Internally it uses the standard Unity terrains, so it's possibilities are limited with the standard terrain's scope. I plan to make MMWG work with the Voxeland terrain (in an addition to standard one) - it's a feature that I'm currently working on. It does not have a control map at all, but has it's own limitations - and in some aspects even more strict since it's voxel terrain.
     
    julianr and Crossway like this.
  47. Artaani

    Artaani

    Joined:
    Aug 5, 2012
    Posts:
    418
    Hello!
    The asset looks amazing!

    I have a question. I want to use it with my own, custom terrain (instead of default Unity terrain), so I need a height maps.
    Is there a way to use Map Magic to generate and extract height maps instead of instant applying to Unity terrain?
     
  48. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    507
    so, i just tried to do the road generation with easy roads and it works perfect. way faster then with megashapes. here a random mapmagic terrain:

    easyroad_gen_3.gif
    and now with erasing trees that are in the way
    roadgen_6.gif

    and the end result:

    ..wasnt that hard ;)

    so, yeah @Wright - if you are interested, i can sent you the stuff over? if not, ignore it ;)

    what i need to know for mapmagic:
    -how I can i define nodes - so how i can define the start and end point of a road (villages for example)
    - how can i connect paths on/to different chunks

    its pretty easy in the end - its just two scripts and you need A* pathfinding project (free) and easyroads
     

    Attached Files:

    Last edited: Nov 25, 2016
    XPAction, malkere and neoshaman like this.
  49. HittmanA

    HittmanA

    Joined:
    Jul 27, 2016
    Posts:
    45
    How can I make a biome? Is there a video on making your own biomes, or a tutorial? Thanks in advance!
     
  50. HittmanA

    HittmanA

    Joined:
    Jul 27, 2016
    Posts:
    45
    @Wright
    So MapMagic does not work with 5.5.0f1. The console is spammed with: The name `Profiler` does not exist in the current context. The errors are in Chunk.cs and Generator.cs. Can you fix this or is it a problem with Unity?
     
    pixelsteam likes this.
unityunity