Search Unity

World Building MegaScatter - Easy Procedural object placement

Discussion in 'Tools In Progress' started by SpookyCat, Jan 28, 2014.

  1. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Submitted an update to the Assetstore over the weekend this makes MegaScatter fully compatible with Unity 5.5, and we also added an option for runtime scatters to happen over multiple frames so you can avoid any long delays for complex scatters.

    Changes in v1.30
    • MegaScatter now fully Unity 5.5 compatible.
    • Added new option to 'build on start' for Scatter Mesh, Scatter Object, Scatter Mesh Texture and Scatter Object Texture so it can be spread over multiple frames, if the option is selected the scatter will be done by a CoRoutine and the amount scattered per frame is set by the 'Num Per Frame' option.
     
  2. Nick-Carver

    Nick-Carver

    Joined:
    Feb 20, 2016
    Posts:
    13
    Is it possible to scatter objects on X and Z axes? I want to populate meshes on the sides of my chosen surface objects, but when I set the axis of the Megashapes to anything other than Y (set in the Megashape script), it doesn't scatter any objects. Is this currently supported?

    Thanks!
     
  3. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    We have submitted an update to the Asset store, this makes MegaScatter fully Unity 5.6 compatible, and we also fixed am issue when building for Windows apps. We have also brought the version of MegaShapes included up to date by adding the all new spline editing features and spline smoothing system making it much nicer and easier to edit your splines. We also added an undo system for the spline editing making it simple to back track over any changes made to your splines. You can see a video of the new spline editing features below.



    Changes since v1.30
    • MegaScatter is fully 5.6 compatible.
    • Added new improved spline smoothing, you can now choose between old and new smoothing modes in the Shape Inspector. New method will produce a perfectly smooth spline through all the control points.
    • Added option to auto smooth the spline when you drag a knot, this will recalc the knot control points if you have changed any.
    • Rewritten the spline editing bit, making it easier to select and move spline knots and handles.
    • Move gizmos are now only shown for the currently selected knot.
    • To edit a spline knot you just need to click the green sphere for the point you want to edit, that will then select that point.
    • Option to freeze y movement when editing spline points, useful if using the free move handle type.
    • No need to click and drag mid point gizmos to add a new point you can now just click the circle to add a new knot.
    • Move handles now point along the spline.
    • Added extra circle gizmo at end of open spline for easier creation of splines by easily allowing addition of knot on the end.
    • Add Undo system for spline editing, you can now undo any changes made to a splines knots by clicking the Undo Edit Spline button.
    • Added option to set the max Undos that can be stored.
    • Fixed bug that caused splines to get corrupted if you tried to use the Spline animation builder on a spline with an imported animation.
    • Added the missing SetHandles method to the MegaShapes API.
    • Fixed error when target platform is Windows App.
     
    OnePxl likes this.
  4. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Just to let you know we have an update coming that will fix the problem some people are having using PositionHandles when editing splines, ie they cant be selected and dragged for some reason. There seems to be some bug in Unity causing the problem, we have tried 3 different ways of doing it and they all have issues, so we have written a custom PositionHandle that works. Just so you know if you are having problems then switch to Free handles as they work fine.
     
  5. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Just submitted an update to address the problem with PositionHandles not working. The new update uses a custom PositionHandle to get around the problem that seems to be internal to Unity.

    Changes in v1.33
    • Fixed a problem with the Position handles when editing splines.
    • Splines now default to Free Handle mode for editing.
     
  6. Fatalis

    Fatalis

    Joined:
    Sep 9, 2013
    Posts:
    52
    Greetings, I've begun testing Mega Splatter. I already have textures masks that I use to define biomes on my terrain and have viewed your video tutorial on how to set this up, but I am encountering a problem where objects are using the wrong color on the texture to spawn. It is spawning on the black color and not the green color. I've tried reversing the colors in the color sampler, but then no objects are placed.
     

    Attached Files:

    Last edited: Mar 8, 2017
  7. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    @Fatalis - If you could submit a support ticket at the website we can help you out.
     
  8. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    Hi there. I'm shopping for a procedural placement system. Megascatter looks great. I was looking through the docs for a way to vary the chance of scattering by noise. It looks like the texture mask color range, which is where I thought I'd find it, is just a boolean test, though. Does Megascatter have a noise filter of some kind?
     
  9. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    @Marble - There is no direct noise filter in the system at this time, but could you not just add the noise to the mask texture or am I missing what you need. If you can email me or message me with what it is you need to happen I can see whether it can be done with the asset as it stands or whether I can add it in.
     
  10. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Just submitted a small update to the AssetStore and our website. This update adds the option to the texture based scatters to use the Alpha channel as a density map so allowing you to control how often an object is placed, so high values in the alpha channel will mean more objects will be placed than in places with low alpha values. We have also fixed the depreciated methods for the final Unity 5.6 release.

    Changes in v 1.34
    • Added option to the texture scatter layers to use the alpha channel in the mask texture to control scatter density.
    • Changes made for the latest Unity 5.6 obsolete methods for the final release of Unity 5.6
     
    Marble likes this.
  11. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I have procedurally generated tiled world with mesh ground objects in runtime.

    I was wondering if this tool can scatter objects like in the example video on them. So basically random placement of objects on the mesh grounds (not just one ground object but a lots of ground mesh objects) and also able to supply the list of objects that should be avoided (ie rocks).

    All of that needs to be done by runtime api.

    Also, after scattering, does the tool support draw call optimization in runtime as well?

    Is it possible?
     
    Last edited: May 5, 2017
  12. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    same here. can some tile/hexagone can be avoided by mega scatter ?
     
    Last edited: May 5, 2017
  13. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    That could be done via scripting you would just need to add the components and fill in the values, or alternatively other users have prefabs of various scatter types which they then randomly choose and instantiate as a child of the tile object and then scatter. So it can be done.
     
  14. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Hi. Just bought and been using it. But there is one problem.

    I have set my object (prefab) to be lightmap static only for my internal development reason but populated objects from scatter tool can only have either everything static or nothing. It should really try and follow the prefab's setting if it can. (possibly as an option)

    Can we please add this feature?
     
  15. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    @castor76 - I will look at adding the option to set the static flags or optionally to use the prefabs static flags if they are set.
     
    MikeUpchat and castor76 like this.
  16. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    @SpookyCat
    Also, I found that if I use raycast and needs ground option, positional random offset does not apply on y axis.
    I can understand this, but I think it is much more useful if random offset on Y is kinda works as additional after ground check. This would be super useful for things like some flat decals on the flat ground. Where you don't want the ground to z fight with decals. I have tried to give random y offsets like from 0.1 to 0.5 (hoping this is enough to cause the decals to not be on the same z) but all of them seems to be stuck at the same level.

    Here is another one :D

    This is minor stuff, but the combined batched object does not respect the rendering setting of the original prefabs such as shadow options. I can manually change them in the editor on the batched object, but I think this should follow the prefab setting. Because what if you want to do this in runtime? :D
     
    Last edited: Nov 7, 2017
  17. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    If I have second uv channel created in say Maya for lightmap, will NOT turning on "lightmap enable" be using my custom lightmap uv? (this is for static batching) or will it ignore my lightmap uv and then lightmapping will not work anymore?

    I need to be able to static batch the scattered object using my custom uv channel.

    This is for the mesh scatter.
     
  18. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I am not exactly sure how the color variation works for the object scatter. The manual says it is modifying the mesh info, but it doesn't really do anything. If option to add colors are there, it should be doing something? I thought if I enable static batching, it will embed the color variation info into the mesh and batch it. But no.. I can't understand how the color variation works for the object scatter.

    After some experiment, it looks like color variation is applied at object material color, not on vertex color like the document suggested. But if you plant say 100 plants, then all of them will have the same color. :( which is kinda defects what the tool is trying to do?

    I can understand that if I am not statically batching the variation color can't be applied to the vertices, because well, I am not creating a new mesh. But when you statically batch, you create a new mesh anyway, so it should be possible to apply vertex level color changes.
     
    Last edited: Nov 7, 2017
  19. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    301
    Hi,

    I do not want to combine objects, and I cant find the option

    Regards
     
  20. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    @castor76 - If you could submit a support ticket with your feature request and other questions so we can get it put in the queue.
    @MoribitoMT - Again if you could submit a support ticket at the website we can help you out.
     
  21. Keaneo

    Keaneo

    Joined:
    Mar 7, 2015
    Posts:
    99
    Hi - is it possible to scatter objects on a ceiling instead of a floor? Raycast, with a "surface obj" only wants to raycast "down" :-(

    I'm trying to scatter object on the inside roof of a tunnel.

    Thanks!
     
  22. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Hey SpookyCat, is there a limit on the size of a megascatter volume you could create? Could you create a scatter volume that envelopes a very large terrain?
     
  23. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    In theory there is no limit to the size of the area to scatter into, so you could scatter over a huge terrain if you wanted but bare in mind scattering to a very large area would require scattering a very very large number of objects potentially which could take a while but it is possible.
     
  24. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Submitted an update to the Asset Store. This makes MegaScatter fully compatible with Unity 2018 and 2018.2, we have also fixed a few bugs in the MegaShapes spline system.

    Changes since v1.34
    • MegaScatter made fully Unity 2018 compatible
    • MegaScatter made fully Unity 2018.2 compatible
    • Fixed an issue which stopped spline editing from working in Unity 2017.4
    • Fixed an issue in Unity 2017.2 that stopped the spline knots from being moved.
    • MegaScatter made fully Unity 2017.2 compatible.
    • MegaScatter made fully Unity 2017.3 compatible.
    • The Undo for MegaShapes now recognizes adding and deleting of knots as well other the other options that change the spline such as Autocurve, scale etc.
    • Fixed a bug where splines were being deleted if the 'Add' option was used when Loading a spl file.
    • MegaScatter made fully Unity 2017 compatible.
    • Updated MegaUtils.cs so if MegaScatter and MegaFiers used together there wont be missing methods.
     
  25. drsmetamoto

    drsmetamoto

    Joined:
    May 8, 2017
    Posts:
    12
    Hi,
    Just purchased megascatter. Will MS scatter prefabs or speedtrees as well? I'm using scatter mesh along and don't seem to be able to use it to place them. Scatter mesh along works fine if I'm using unity primitive meshes or a simple mesh. Thanks

    EDIT - doh! just realized i should have been using Scatter Obj Along. thx!
     
    Last edited: Jan 31, 2019
  26. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Yes it can scatter objects or prefabs such as Speedtree trees, you just need to use the Scatter Object components instead of the Scatter Mesh ones which will combine the meshes for you reduce drawcalls but obviously you will then lose any components attached. Glad you found the Object options.
     
  27. drsmetamoto

    drsmetamoto

    Joined:
    May 8, 2017
    Posts:
    12
    Hi. One additional question - I can't seem to find how to not combine objects. With objects combined (for example when placing speed trees) - the LOD doesn't seem to work any longer.

    EDIT - Solved - my prefab had LOD Group Disabled....
     
  28. drsmetamoto

    drsmetamoto

    Joined:
    May 8, 2017
    Posts:
    12
    Hi Chris,
    Question regarding importing SVGs which are created from Illustrator. What SVG format is MegaScatter expecting? There are a number of different SVG Profiles/Settings that can be set on export from Illustrator.

    Also, is it assumed that an SVG should be a certain number of paths (e.g. one).

    When Importing SVGs I'm getting ArugmentOutOfRangeExceptions, etc. Thanks in advance,
     

    Attached Files:

  29. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Just submitted a small update to the Asset Store to make MegaScatter fully compatible with Unity 2019 and 2020.
     
  30. diccon

    diccon

    Joined:
    Sep 13, 2013
    Posts:
    22
    I'm finding that when I scatter objects that have a nested prefab, the nested prefab connection is lost, so when the prefab is updated the scattered objects do not update. If I press Update on the scatter object then the prefab does correctly update but it is not really practical to do this in large scenes where I have many scatter objects. Is there a way for me to set up the prefab so that this will work?
     
  31. bergolli

    bergolli

    Joined:
    Apr 12, 2014
    Posts:
    3
    Diccon, you can do it like this:
    change line 400 in MegaScatterLayer.cs
    Code (CSharp):
    1. GameObject cobj = (GameObject)GameObject.Instantiate(obj, p, qr);
    to this:
    Code (CSharp):
    1. GameObject cobj = PrefabUtility.InstantiatePrefab(obj) as GameObject;
    2.         cobj.transform.localPosition = p;
    3.         cobj.transform.localRotation = qr;
    add this to the top of the file:
    Code (CSharp):
    1. using UnityEditor;
    Next time you hit update, the generated instances are prefabs. Prefab instancing only works in the editor. I'm not totally sure if MegaScatter does any generation in realtime. if so, have to add #if UNITY_EDITOR checks to the code, but in my testing didn't need to do that.

    Hope SpookyCat adds this functionality to MegaScatter.
     
    Last edited: Apr 8, 2020
    diccon likes this.
  32. diccon

    diccon

    Joined:
    Sep 13, 2013
    Posts:
    22
    Thanks so much for your reply, it works really well! I don't need this to run in real time so this is fine for me. I submitted a support ticket so hopefully they will add this to the official package, it doesn't seem like a big change to make.
     
  33. Aurecon_Unity

    Aurecon_Unity

    Joined:
    Jul 6, 2011
    Posts:
    241
    Hey, I am encountering a weird bug - if I hit 'Update' with something in the scene causing the objects to not scatter (such as if I forgot to re-enable the ground surface mesh), then they won't scatter even after I've fixed the issue - the only way to get a scatter again is to delete all the source objects and re-add them. Has anyone else encountered this?
     
  34. Revan3192

    Revan3192

    Joined:
    Mar 28, 2018
    Posts:
    8
    Hi @bergolli!, I've tried to change this part of the code but is still not spawning my prefabs. Do you think I could be missing something?
     
  35. netpost

    netpost

    Joined:
    May 6, 2018
    Posts:
    388
    @SpookyCat

    Hi,

    I am not sure if I should post here or In the Mega-Fiers forum since Mega shape is featuring in both assets...

    When creating a megashape spline the handles are not showing even if "show handle" is enabled . I also can't modify the knots for all megashapes.

    I tried with both Unity 2020.1.17f1 and 2020.2.1f1 with the same results. It works fine in Unity 2019 (can't see the gizmo but I can modify the knots)

    Can you tell me if this asset is compatible with Unity 2020 or not?

    Thanks for your help!
     
  36. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Quick update for MegaScatter which makes it fully compatible with Unity 2020.3 as well as 2021.
     
  37. netpost

    netpost

    Joined:
    May 6, 2018
    Posts:
    388
    @SpookyCat This is great news. Thanks for the update!
     
  38. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    322
    Hello, I'm not an experienced coder and I need help to add all active terrains at runtime.
    Con please someone help me? :oops:

    [Edit]
    Hey, Looks like I'm not so bad at the end :D

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. [ExecuteInEditMode]
    4. public class MegaScatterTerrainUpdater : MonoBehaviour
    5. {
    6.     MegaScatterObject megaScatterObject;
    7.     MegaScatterCollisionObj collisionObj;
    8.  
    9.     System.Collections.Generic.List<MegaScatterCollisionObj> collisionObjList = new System.Collections.Generic.List<MegaScatterCollisionObj>();
    10.  
    11.     // Start is called before the first frame update
    12.     void Start()
    13.     {
    14.         megaScatterObject = GetComponent<MegaScatterObject>();
    15.         collisionObj = new MegaScatterCollisionObj();
    16.  
    17.  
    18.         for (int t = 0; t < Terrain.activeTerrains.Length; t++)
    19.         {
    20.             Collider terrainCollider = Terrain.activeTerrains[t].GetComponent<TerrainCollider>();
    21.  
    22.             collisionObj.collider = terrainCollider;
    23.             collisionObj.active = true;
    24.  
    25.             collisionObjList.Add(collisionObj);
    26.         }
    27.  
    28.         megaScatterObject.surfaces = collisionObjList;
    29.     }
    30. }
    31.  
    32.  
    But it looks it's not enough 'cause trees won't get spawned unless I uncheck Needs Ground :confused:
     
    Last edited: Aug 28, 2021
  39. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    322
    @SpookyCat Can I tell to MegaScatter to place object on some specific terrain texture or avoid other one?
    I'm using it to create forest, but it spawn trees in the middle of the road, and the terrain is procedural generated via MapMagic2 and I'm using MicroSplat for the texture, so I can't assume where the road will be placed.
     
    Last edited: Sep 20, 2021
  40. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Submitted an update to the store today that fixes an issue with some of the scatter layer types not working in the editor, MegaScatter is also now fully compatible with Unity 2022.

    Changes since 1.42
    • Fixed a bug where some scatter types would not Update when the green update button in the inspector was clicked
    • MegaScatter made fully Unity 2022 compatible
    • Added a Spline Sub Div value to Scatter Mesh and Scatter Object, this allows more accurate scattering inside the curves of the spline, use 0 for simple straight lines between knots, higher values will do more accurate scattering to the spline shape
    • Fixed an issue where scattering over frames was not working for Scatter Mesh and Scatter Object layers.
     
  41. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    IMG_20221224_001436.jpg Hello, I already own and bought Megascatter and think is really very good, awesome and well done

    Please can you be so kind if Megascatter can also use PNG photos with transparent background as scatter objects? Using splines as mask for the shape to be filled with the photos

    I have about 50 flower photos cutout with transparent background and want to import them in Unity and use them as scatter objects inside megascatter as shown on the image above with nonoverlapping

    So my idea is to simulate shapecollage.com photo collages, because the problem is that this tool does NOT have a control of non overlapping and any of the mega scatter features, so I have thought about using Unity instead and as it has no overlapping it could be even better to make 2D photo collages with splines

    But all the manual and videos and description of mega scatter is all about using 3D objects for scattering, so what I want is to use 2D photos instead but do not know how to do it.

    Another thing is that the photos are NOT simple rectangles or squares, they are cutout irregular flowers with transparent background

    So, please can you be so kind to help and tell if there can be used PNG photos with Megascatter and HOW to use it with 2D objects.

    Maybe if it is not possible in 2D, I could paste the photo into A 3D object with invisible material

    Thanks very much if you can help in some way

    Merry Christmas and happy new year 2023
     
    Last edited: Dec 23, 2022
  42. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    There is a new version in the Asset store. This makes MegaScatter compatible with the new MegaShapes included with MegaFiers 2 and in the main MegaShapes asset. Before installing MegaScatter to a project comntaining either of those assets already would result in some errors. This is now fixed.
    You only need to update if you are wanting to use MegaScatter in a project which includes MegaFiers 2 or MegaShapes. This update could break some scripts that use MegaScatter or MegaShapes functions so please backup your project before updating.

    Changes in 1.46
    • This updates means MegaScatter now uses the MegaShapes included with MegaFiers 2. This will stop errors when importing MegaScatter into a project which already includes MegaFiers 2 or MegaShapes.
    • This update is only needed if you need to use MegaScatter in a prject with MegaFiers 2 or MegaShapes in it.
    • This update is likely code breaking in a couple of places so please backup your project before using this update.
    • When installing MegaScatter in a project install MegaFiers 2 and or MegaShapes first as required, then install MegaScatter, and then dont import any asset that is marked as already in the project.
     
  43. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    A small update is in the store now, this fixes an issue with the Scatter Object Along and Scatter Mesh Along layers when the spline had height to it, objects would not be placed correctly along the whole length of the spline only at the lower points.

    Changes
    • Fixed an issue in the Scatter Object Along system where if a spline had height then the objects might not get scattered near the top.
    • Fixed an issue in the Scatter Mesh Along system where if a spline had height then the objects might not get scattered near the top.
     
  44. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,767
    Just submitted an update to the store to make MegaScatter compatible with Unity 2023

    Changes in v1.49
    • MegaScatter updated to be compatible with Unity 2023