Manipulate dynamic landscape material with foliage at runtime

Like the title states. I am trying to manipulate the landscape material with foliage actors added to the material. At the moment I have the material set up with the wanted foliage actors to be distributed based on the material and I’ve been able to control the landscape material parameters at run time by using a Material Parameters Collection. While the parameters do change during run time i’m running into an issue where my grass map isn’t being updated so the foliage stays in the same place no matter if i change my parameters and texture placement of the landscape material. It only recalculates the grass map when the original material or material instance is saved or “updated”… (in the editor) this successfully leads to the outcome i’m looking for…all foliage disappearing and reappearing in it’s new location.

I’m currently still looking into this and will be backtracking to see if i made an error…any help figuring out whether this is possible is appreciated.

There seems to be C++ code for the landscape to update/flush/etc the grass. I’d suggest popping the landscape into blueprints and see if there’s anything you can use to reset the grass there, then sync it with when you change the material instance.

@Juice-Tin Would you know the C++ code you’re refering to?
I tried entering grass.flushcachePIE in the command prompt…it seems to refresh the grass map but fails to give me a new version with the updated material instance…Not sure if this is what you’re talking about.

https://api.unrealengine.com/INT/API/Runtime/Landscape/ULandscapeComponent/index.html

I mean on the actual component. I haven’t tried it myself, but it seems like there may be some useful functions in there. Potentially RenderGrassMap().

Might be worth getting a reference to your landscape in C++ or Blueprints and giving some of those functions a shot.

@Juice-Tin Based on other forums I started to look into the LandscapeGrass.cpp file as a way of regenerating the grassmap (thank you for pointing out the RenderGrassMap() component ) but have yet to personally implement C++ into any my of my unreal projects files, so now it’ll partially be me figuring out how to reference my landscape in C++ and hopefully then making it work with blueprints…

I finally got to try some stuff out in Unreal. You can easily get the LandscapeComponent from the landscape by using the ‘GetComponentbyClass’ node. However looking at the c++ behind it, it seems like none of those handy grass functions are available to blueprints.

Referencing it through C++ is very easy, just use an actor iterator to find it in the scene. However I’ve heard it’s very difficult to add C++ into a non C++ project (if even possible).

Have you tried something simpler like just swapping to a different material to see if unreal updates the grass maps then? Maybe even swap to a version with no grass enabled and then back to your proper grass one.

@Juice-Tin hello!
Thank you for replying. I had to put that portion of my project on pause and move on because it was taking a bit to long and I didn’t know too much C++. I ended up simplifying it a bit by streaming levels instead of having the grass maps regenerate, but hopefully i’ll revisit it again in the next month or so.

I’ll let you know how it goes if I do get the time.