Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Released] Corgi Foliage Painter - Built-In + URP + HDRP Instanced Rendering Tooling

Discussion in 'Assets and Asset Store' started by funkyCoty, May 12, 2022.

  1. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Quickly and easily paint any foliage on any terrain or arbitrary meshes.

    logo.png

    Asset Store URL: https://assetstore.unity.com/packages/slug/221883

    Documentation Here

    Features
    • Simple and easy to use. Follow the documentation to drop in a few scripts and start painting your dream foliage right away.
    • Highly optimized rendering system, with tooling available to make it EVEN FASTER for those hardcore shader wizards out there.
    • Has several paint modes available so that you can paint on anything! Includes arbitrary plane painting, painting on raw meshes in the scene, and painting on colliders with layer masks.
    • Supports both local and world space foliage groups. Want a mossy car? Prefabs are fully supported!
    • Multiple brush modes available. You can create high precision designs, or randomly scatter your rocks or grass anywhere and everywhere with just a few clicks.
    • Painting over existing data is fully supported, including opacity and feathering options for those micro tweaking fantasies.
    • Includes a data browser in each foliage group so you can control every tiny detail of every blade of grass, if your heart desires.
    • Comes with a ShaderGraph example of simple but beautiful grass, so you can start painting immediately. Please note: this plugin is intended to be a tool for placing foliage you have either made or gotten from outside sources, it's not intended to be a model pack or anything like that. You'll need to get some high quality rocks to drop in!
    • Simple scripting API for programmers.
    • Includes FULL SOURCE CODE
    • Juicy support. Hit me up any time if you run into any issues! Contact info in the documentation linked above.

    Unity_gfrQ8zDLyR.png
     
    Foreman_Dev likes this.
  2. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    It's finally live!
     
  3. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    First update since release!
    (updates that happened while I was waiting on the initial package to be approved)
     
    Foreman_Dev likes this.
  4. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Next update!

    1.1.0:
    Here is what the new icons can look like:

     
    Foreman_Dev likes this.
  5. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,225
    Ya'll landscape junkies, get over here!

    Alright let's talk performance here, is this thing made for vast terrain? Do you have a sample code to add1000 patches of grass in various rotation with SetAllFoliageData? Does it do frustrum, orientation (grass pointing away from camera) or distance culling? How about fade in and out at a distance?
     
  6. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    No, not out of the box, at least. It's more geared towards typical unity-sized levels. If you wanted it to work for vast terrain, you definitely could, but the functionality is not there by default. You would want to turn off groups by distance at the very least. There is some of this in the plugin already, but I would by lying if I said it could scale to a true open world game. It's possible, but not all the pieces are there for it yet.

    If you look at the Editor classes, they use the same API, pretty much, as what any user of the plugin could use. Check out how the brush is adding a bunch of foliage with random rotations, it's pretty easy to do.

    Implicitly it has culling just because of the unity API it uses for rendering. If the bounding box is huge, all grass will be requested to render but not all grass will actually render. There is no fancy per instance culling, but if you request this I can see about working on something like that. There's not yet a fade in and out at distance, but there is a jobified LOD system in place, per group. You can set distances for LODs and it's automatically handled for popping between the LODs and a cull range. If you request some sort of LOD transition such as fade or dither, I can look into getting it in.
     
    laurentlavigne likes this.
  7. Foreman_Dev

    Foreman_Dev

    Joined:
    Feb 4, 2018
    Posts:
    79
    Heyo! First of all, thanks for making this plugin. :) Hard to find something that can paint onto arbitrary meshes/colliders, and I appreciate you putting in the effort to make that happen.

    My team has a need for painting foliage (trees, grass, flowers, grass) onto custom, non-square terrain meshes that were created in an external 3D program. Seems like this should, in theory, fit our needs. Just bought the plugin and I'm excited to give it a whirl.

    A couple of questions:
    1. Does this play nicely with WebGL build platform? (URP and Unity v2020.3, if that info matters)
    2. Assuming I have a powerful PC, how usable is this plugin without the burst compiler dependency? Burst isn't supported for WebGL, so I don't want to bring that package into the project.
    3. Is Burst only used for in-editor functions, and not used at runtime? (I assume so but just want to be sure)

    Thanks!
     
  8. Foreman_Dev

    Foreman_Dev

    Joined:
    Feb 4, 2018
    Posts:
    79
    Oh! One other thing. I'm using baked lighting via Bakery GPU Lightmapper (a better alternative to Unity's built-in lightmapper). I have some placeholder trees/foliage in my scene right now, and currently they cast shadows during the lightmap bake (but use light probes to light themselves so that they don't consume lightmap texture space). Using your plugin, is it possible for foliage to cast shadows during a lightmap bake with Bakery?

    Note: If you need any detail about the inner workings of Bakery, the documentation goes into some detail about shaders and material compatibility: https://geom.io/bakery/wiki/index.php?title=Manual#Material_compatibility
     
  9. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    I haven't tried it with WebGL yet, but if you run into any issues let me know and I'll try to fix them.

    I believe that when it's running on a platform that does not support burst, it will fall back to a non-burst version of the code (just mono, il2pp, or whatever the platform uses). However, you'll still need the burst package in your project for the editor.

    No, burst is also used for speeding up rendering at runtime (LODs and stuff). It's not super critical though, should be fast enough even without burst. Burst is also used for speeding up editing at runtime though, yeah, and you really want it for that.

    For normal unity lightmapping, it's not possible, no. For bakery, I'm assuming it's also not possible but couldn't say for sure. I will say its extremely uncommon to bake foliage (grass, small rocks) shadows into lightmap data anyways, though.
     
    Foreman_Dev likes this.
  10. Foreman_Dev

    Foreman_Dev

    Joined:
    Feb 4, 2018
    Posts:
    79
    Thanks for the fast response!

    Appreciate the explanation about what Burst is used for. So then, there shouldn't be any issue importing the Burst package even though my platform doesn't support it? Is it likely to run fairly well on mobile devices even without Burst?

    As for the shadows, is there any way we could get that working? I plan to use your plugin to place trees, and in our case the shadows are important since the trees provide nice shaded areas like in this image:

    upload_2022-11-3_17-20-38.png

    I realize that instanced rendering doesn't necessarily lend itself to static lightmap baking, but is there any way you can think of (even unconventional) to get shadow casting to work with your plugin during a lightmap bake?
     
  11. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    I really wouldn't recommend using a foliage instancing plugin like this for trees, I think it's a lot better suited for meshes you want to draw thousands of times per frame, such as grass or stone or other, well, foliage. Trees are a lot less frequent thru a scene, and in my opinion are better suited as just normal prefabs which can be statically batched and also statically baked. You could try with it, and I can work to improve things for your workflow, but really I do think trees specifically aren't worth instancing like this.

    For your questions on Burst, I think you should also use Burst on mobile and really anywhere you're able to. The speedup is huge.
     
  12. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Pushed a small update just now to add some limited support to Unity 2020.3. Fixed some script errors from using a newer API that didn't exist in 2020.3, but unfortunately shadergraph doesn't fully support 2020.3 either so some manual work is required by the user (explained in the documentation).

     
  13. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Working on some improvements to the editor in order to make user errors less likely.

    Example video of what's coming soon:

     
    Foreman_Dev likes this.
  14. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Preview of another feature coming to the next update:
    The plugin will allow 'baking' foliage groups into a single static mesh (or multiple, if over the 65k vert limit - its handled automatically).
     
    Foreman_Dev likes this.
  15. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Update has been pushed to the store!
     
    Foreman_Dev likes this.
  16. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    MAJOR UPDATE incoming.

    The included ShaderGraph shaders now support indirect rendering mode, which can have a massive impact on improving performance on large foliage groups:
    Unity_nehjXXHCIX.png

    FoliageMeshData assets now support multiple meshes/materials per LOD level, allowing for more complex foliage (such as trees). Image below has meshes provided by a user to use as an example, not included in the plugin.

    Unity_qRwQ9lopAk.png

    Because the FoliageMeshData is now somewhat complex to setup, creating them has been made easier view a simple right click menu on any existing prefab.

    Unity_mc4D1fcUQp.png

    The stats menu has been greatly improved, too:

    Unity_wNpYbsPLHA.png
     
    Foreman_Dev likes this.
  17. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Small update incoming right after.
     
    Foreman_Dev likes this.
  18. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    bugfix update coming through
     
    Foreman_Dev likes this.
  19. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    more bug fixes / improvements

     
    Foreman_Dev likes this.
  20. evergreen420

    evergreen420

    Joined:
    May 1, 2017
    Posts:
    4
    hey! super promising system, this really fills a hole in the pipeline I'm building.

    Questions:
    1. I've made an exporter for houdini point clouds to send data directly to a Foliage Group from a HDA - this works great but I'm having trouble getting accurate rotations - are there any gotchas or anything when filling in the trs matrix ? More likely something wrong with my data transformations but would be good to know nvm fixed this :)
    2. Any tips on setting up indirect instancing with Amplify shader editor? Specifically I want to integrate with The Vegetation Engine
    3. Do you have a roadmap for the tool?

    Suggestions:
    1. Stroke caching - I'd like to be able to re-apply manual edits to support a non-destructive workflow when re-baking procedural assets
    2. Automatically setting up foliage groups based on JSON data

    Bugs:
    1. transforms going wild when using the select tool
    2. paint tool not working at all, draw only
    3. Randomly not rendering ,seems to be fixed by calling SetDirty() or going into Play mode
     
    Last edited: Feb 20, 2023
  21. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Hey there, glad you're enjoying the plugin. Thats a lot of stuff, let me try to answer everything..

    For 2, check out the included #include files, if you can do custom nodes in amplify you can probably just include those and work from there. For 3, I don't exactly have a roadmap, no. If people buy it and request features I'll try to add in whatever is reasonable.

    Can you explain 1 a bit more? I'm not really following. For 2, there's a save/load API already - you can just use JsonUtility to convert it directly from the serializable format.

    Can you provide some examples or potentially logs of any errors? If I can replicate these I can fix them much faster.
     
  22. evergreen420

    evergreen420

    Joined:
    May 1, 2017
    Posts:
    4
    Thanks for the help Coty!
    2 - Cool, I'll attempt to get that working

    1 - So what I mean by caching is storing each manual edit in a list which can be played back. For example, storing the position, direction, radius, depth & subgroup indexes of a stroke. With this a rough re-application of manual edits could be achieved if the underlying point cloud data need to be changed (e.g. I update a landscape)
    2 - I was referring to the FoliageMeshData subgroups, turns out setting foliageGroup.Subgroups works. Needed to avoid the differently sized subgroup problem, so I'm manually clearing it and adding the subgroups directly from my biome data so I can generate and push data into Corgi Foliage with one click

    I'll record the behaviour when I get a chance

    Cheers!
     
  23. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    For 1, oh I think I see what you mean. Basically for an undo/redo system at runtime? At the moment I have stuff setup to be friendly with Unity's undo/redo system in the editor, but I can see if I can implement something more useful for runtime too.
    For 2, I'm glad you got it working! If you have any more requests in this area that might make your workflow better, please let me know.
     
  24. evergreen420

    evergreen420

    Joined:
    May 1, 2017
    Posts:
    4
    upload_2023-2-24_13-44-12.png
    ok, managed to get a Vegetation Engine shader setup for indirect instancing ! nice to see 66 thousand objects in 92 draw calls (shadows included). quite a crude scattering for now while I'm still constructing the pipeline but i'm getting closer to visual goals!

    some stuff I haven't figured out:
    1. the normals were flipped, just added an invert node but could it be something in the way I setup my foliage data? i'll test the sample meshes you included
    2. features like SSS are broken (i wonder if the Veggie Engine dev could implement an integration for your asset, they have it for other GPU renderers)
     
  25. evergreen420

    evergreen420

    Joined:
    May 1, 2017
    Posts:
    4
    I meant an editor cache so I can re-apply entire sessions of manual edits, if possible. This makes things way faster when iterating. For example, in Houdini
     
  26. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Small bug fixes coming in hot.
     
  27. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Another small hotfix coming in:

     
  28. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Small fix just pushed.

     
  29. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    719
    Small workaround fix pushed.