Search Unity

[FREE] Procedural Terrain Painter

Discussion in 'Assets and Asset Store' started by StaggartCreations, Feb 12, 2021.

  1. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    Paints terrain layers through a rule-based modifier stack. Making it easy to quickly, and non-destructively, texture entire terrains and achieve natural results, without any manual painting.

    Core features
    • Stackable and re-orderable modifiers, with blend modes
    • GPU-accelerated, parameter changes are fast and instantly visible
    • Heatmap visualizer to highlight the areas where a layer takes effect.

    Modifiers:
    • Height range
    • Slope range
    • Curvature range
    • Noise
    • RGBA Texture mask

    Limitations:
    • Manual texture painting will be overridden when respawning
    • Only supports square terrains, laid out in a grid.
    • Component can't be prefabbed (serialization limitation)

    This is not a terrain shader, but modifies the terrain splatmap data directly. As a result, this'll work with any asset store or custom terrain shader. MicroSplat integration is included, to sync the terrain layers to its texture array

    Included terrain layers are for demo purposes and fall under the CC0 license. Text file includes source links.
     
    Last edited: Feb 17, 2021
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    Submitted v1.0.1

    Added:
    - Auto repaint option in Settings tab. Repaints a terrain when its height is modified.
    - Option to refresh Vegetation Studio Pro when terrain is repainted

    Changed:
    - Renamed namespace to "sc.terrain.proceduralpainter" for consistency between other terrain tools

    Fixed:
    - Heatmap preview highlighting wrong terrain layer in some cases
     
    Last edited: Feb 27, 2021
  4. Swyfft

    Swyfft

    Joined:
    Mar 14, 2019
    Posts:
    53
    Looks interesting.. thank you..
    Great timing.. will have weekend to play with it.. and can see what it looks like with some of your other assets.
     
  5. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    873
    Hi, i just wanted to make sure it's not user error.
    It looks like in 2020.3.3f1 some things are not working as they should;
    when i select a modifier, no controls are shown below, the space only resizes, but nothing else happens:
    upload_2021-4-9_15-15-24.png

    And when i toggle Heatmap, the terrain seems to render the sceneview including toolpanel ontop of it:
    upload_2021-4-9_15-16-34.png

    Is this to be expected (does it require a lower unity version) ?
     
  6. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    873
    Ok, the first issue seems to come from an incompatibility with Odin Inspector (thirdparty asset), excluding your namespaces/types in its settings makes the editors show up.
     
    StaggartCreations likes this.
  7. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    Some one else had the same issue, where the settings aren't drawing. It's unfortunately something I haven't been able to reproduce. It's possibly related to the angle of the sun and position of the planets, and what you had for breakfast.

    The scene view GUI drawing into the heatmap can happen sometimes, a bit of a matter of timing since the heatmap also renders along with it. It nudges back into place whenever you select a different layer, or change any settings.
     
    Flavelius likes this.
  8. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    If anyone has the issue where settings for the selected modifier aren't showing, this is due to a conflict with Odin. A workaround is to exclude the namespace, so Odin will let the default inspector draw:

    upload_2021-4-18_11-39-8.png

    I've meanwhile implemented a fix for this, but currently have a hefty workload, so will probably get around to including in this in an update in 1-3 weeks.
     
    Flavelius and firstuser like this.
  9. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    Submitted v1.0.2

    Added:
    - Callback event for when a terrain is repainted (TerrainPainter.OnTerrainRepaint)
    - A warning is now displayed if any terrain references have gone missing

    Changed:
    - Adding a new modifier now automatically selects it

    Fixed:
    - Texture modifier not aligning correctly if a terrain had a large negative position
    - Modifier settings not drawing when Odin is installed
     
    Fibonaccov likes this.
  10. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,175
    This is really really great! I would love to switch to it (since what I've been using, Terrain Composer 2 and GAIA, each have some significant flaws)....but any chance you're planning to add a few more filters?

    1) Blur: This is extremely valuable in general, and especially for blurring the noise patterns.
    2) Better noise options: Simplex creates fairly artificial QR-codelike shapes. And Gradient just seems to make a polka dot pattern, but I might be doing it wrong... But any chance for other noise patterns that would look more natural?

    thanks!
    Dave
     
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    Thanks for the suggestions, Dave!

    Blurring has implications for seamlessly applying a filter across neighboring terrains, so the result would be that the filter on edges of a terrain turns into a blurred black edge. The "radius" parameter from the Curvature filter suffers from the same issue. However, most filters have a "falloff" value, which largely achieves the same as a blur, since it smooths out the ranges.

    I'll see if I can expose more options for the noise, such as depth. You can combine multiple noise modifiers, each with a different tiling size, then set the blending mode to "Max", in order to achieve more complex and less repetitive patterns.
     
    gecko likes this.
  12. hauwing

    hauwing

    Joined:
    Dec 13, 2017
    Posts:
    61
    Hi, I want to say this is a great tool. May I know it is possible to save the layers setting into a config file or something that can be used later on? since after the procedural texture, most likely it needs to be manual paint for details, so need to "disable" the procedural painter. Also how to disable the procedural painter properly as it seems like it is always hooked to the terrain even though I have disabled the painter gameobject and unchecked auto repaint. Thanks.
     
  13. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    Glad you like it! It wasn't until I had pretty much finished everything that it occurred to me that saving everything into an asset file may have been more beneficial. But it would require the entire data structure to change and I wasn't willing to throw out two weeks of work, so that's a lesson learned

    It however only repaints whenever you change a parameter in the inspector, so once you start using the terrain tools it won't interfere. The auto-repaint option only applies if the terrain height is modified.

    But the TerrainAPI synchronizes the terrain data only once you save the scene or project. So it's possible if you use the Terrain Painter component, manually paint something, then save, the changes are going to be overwritten with the painting data that was still queued for saving.

    A way around this is to use File-Save Project after you're done using the Terrain Painter component. Not entirely sure, but if I automatically do this once the Terrain Painter loose focus, it should get around such issues.
     
  14. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,175
    I'm trying this in my game scene now (8x8 grid of terrain triles) but two issues, small and big:

    Small: The "layers" subpanel on the Terrain Painter inspector is so short, shows only four layers. Can that be enlargeable? I have 12 layers and the short panel is pretty annoying.

    Big: I'm using Microsplat, and already set up all that, so manually added layers to Terrain Painter by selecting the existing layers. Then I can see those on each terrain, all good...until as soon as I click a modifier for one of the layers and suddenly those 12 layers are added *again* to each terrain. So now I have 24 layers on each terrain, and the terrain turns black because...well, I'm not sure exactly why the terrain turns black, but presumably because there are these 12 new layers on the loose. No console errors (though earlier the error below appeared, but not sure when).

    Presumably I'm doing something wrong, but I have no idea what.... any ideas/suggestions?

    Note: I did not do the TP>Microsplat Copy action, because I didn't want to alter the MS config setup. I just matched the order of the layers in TP and MS Config.

    thx
    Dave


    ArgumentException: Getting control 10's position in a group with only 10 controls when doing ExecuteCommand
    Aborting
    UnityEngine.GUILayoutGroup.GetNext () (at <fe7ee1881b524b0d9443f74417fb598b>:0)
    UnityEngine.GUILayoutUtility.DoGetRect (System.Single minWidth, System.Single maxWidth, System.Single minHeight, System.Single maxHeight, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at <fe7ee1881b524b0d9443f74417fb598b>:0)
    UnityEngine.GUILayoutUtility.GetRect (System.Single width, System.Single height, UnityEngine.GUILayoutOption[] options) (at <fe7ee1881b524b0d9443f74417fb598b>:0)
    UnityEditorInternal.ReorderableList.DoLayoutList () (at <7d90b28560b644ce87b8263efcc36eed>:0)
    sc.terrain.proceduralpainter.TerrainPainterInspector.DrawLayerModifierStack () (at Assets/ProceduralTerrainPainter/Editor/TerrainPainterInspector.cs:801)
    sc.terrain.proceduralpainter.TerrainPainterInspector.DrawLayers () (at Assets/ProceduralTerrainPainter/Editor/TerrainPainterInspector.cs:490)
    sc.terrain.proceduralpainter.TerrainPainterInspector.OnInspectorGUI () (at Assets/ProceduralTerrainPainter/Editor/TerrainPainterInspector.cs:233)
    UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <7d90b28560b644ce87b8263efcc36eed>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  15. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    In the TerrainPainterInspector script at line 398 you can increase the x4 multiplier to allow more layers to show. I could simply add a slider for this in the future!

    As far as MicroSplat goes, the component is designed to handle terrain painting and layer management, so it won't be possible to do this the other way around without creating conflicts or unexpected behavior.

    The error about GUI is tricky, haven't found the exact cause. Went over the entire scope, but I assume the error is because adding a new layer alters the GUI while it's still drawing, which usually isn't an issue. So it's unfortunately a minor nuisance.
     
  16. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,175
    Thanks for the reply and tip about the subpanel! Ideally, it would be great if it was drag-expandable like some other inspector subpanels.

    Okay, so....I'm unclear on how I should proceed. Remove Microsplat from the terrains until I'm completely done with the painting? (I hope not, because MS affects the splat texture appearance and I do a lot of tweaking to the splat rules due to that.)
     
  17. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    Yes, that would be the ideal scenario. The combination of this tool with Microsplat unfortunately remains finicky, since they both describe terrain layer data differently, hence there is no "Copy from" button. The documentation has more details on this.
     
  18. jarosss78

    jarosss78

    Joined:
    Feb 26, 2016
    Posts:
    1
    Hi,
    your tool is great but I cannot make the CURVATURE modifier work. It just blends the complete layer in and does not take any curvature of the terrain into consideration. Whats fun is that in the sample file it works fine. What am I doing wrong?
     
  19. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    The curvature filter is something that depends on the resolution of the terrain's heightmap. If its too low (eg. 512px for a 2x2km terrain) the accuracy of the modifier suffers and tends to result in very broad strokes. But if the terrain is relatively flat (very shallow dents/crevices and no edges/peaks) it won't be much use either.
     
  20. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    142
    I am testing your tool and can't use it at all with Microsplat. Any idea?

    Unity 2020.3.17 HDRP, the terrain was made using MapMagic2.

    upload_2021-9-22_10-44-0.png upload_2021-9-22_10-45-1.png
     
  21. mick129

    mick129

    Joined:
    Jun 19, 2013
    Posts:
    142
    I also get this error as soon as I add the script on an empty object. upload_2021-9-22_10-48-13.png


    Edit: I have the same problem on the demo scene.
     
    Last edited: Sep 22, 2021
  22. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    I can't tell what would cause these errors I'm afraid. The first one is a null-ref on something that's created the moment the inspector is opened, before any GUI is drawn, so that's particularly puzzling.
     
    mick129 likes this.
  23. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    274
    Hello @StaggartCreations , I really like this asset, that I've discovered a little late. :oops:
    Anyway I have some problem with the noise, indeed my idea would be to create bit "patch" with grass to spawn forest over it, but modifying the Noise size wouldn't change too much, indeed that the maximum size that I've been able to achive.

    The red circle is my player. any advice to have a noise about the double of that size? :D
    Indeed if you try a noise scale of 5 and a scale of 250 will looks about the same.

    The only alternative that I can think about is to create some masks like for biomes.

    upload_2021-10-11_14-14-22.png
     
    Last edited: Oct 11, 2021
  24. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    586
    This looks really nice! This is apparently the first layer-based tool for terrain texturing in Unity, right?
     
  25. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    Ah yes, that's a little quirk, if the size value is over 100 it will actually appear to mirror and the noise gets smaller. So a value of 10 would actually result in the noise spanning over a larger area than with 5.
     
    MaximilianPs likes this.
  26. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    274
    I have another doubt, about the Slope, is Min and Max Falloff in meters or is just a procedural value?
    I would like to achive sharp blend between rock cliff and the grass on the ground, but if I lower the Falloff (1 and 1.1), MinMax angle value for the cliff need to have very low decimal, like from 3 to 90. o_O
     
  27. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,630
    The slope modifier works with angles in degrees. You can see the falloff parameters as a way smooth out harsh borders. With a minimum slope of 45º and a falloff of 15º, a smooth gradient is created between 45º-60º. So for a sharp transition, the falloff should ideally just be 0º.

    How aggressive the modifier responds to parameters is largely dependent on how much elevation changes the terrain has. For a relatively flat terrain, a few degrees will appear to make drastic changes.
     
unityunity