Hide landscape foliage/grass where an actor is placed?

For example, when this campfire actor is placed, I want to hide the grass under it.

Hi! I personally do this on my project using a runtime virtual texture as a mask for hiding the foliage.

Are you familiar with RVT’s at all?

Either way I will post the setup process next time I am at my workstation. In the meantime I have linked the documentation.

1 Like

That would be very helpful :slight_smile: I keep coming back to RVT’s, but wasn’t sure if I was on the right track. I’ve seen examples use it for grass deformation.

1 Like

Hey! Took me a bit to get back to this. I’m assuming you have the basics of RVT setup with this. If not let me know and I’ll add that setup as well.

Plug this series of nodes up on your grass material. The scalar parameter will determine how much to apply the occlusion.

Set your default mask to zero by putting this in your landscape. I’m using the roughness channel but any black and white masking channel will do.

Screenshot 2022-04-11 161429

Then you want to run that mask into your landscape grass output.

Screenshot 2022-04-11 163911

For any meshes you want to apply the effect to, run a constant of 1 into the RVT output to ensure the RVT takes them into account.

Screenshot 2022-04-11 164137

So far my object looks like this.

Screenshot 2022-04-11 163100

Not doing anything. The last step is to tell the object to render to the Virtual Texture. In the object properties Find this area.

Screenshot 2022-04-11 164745

Click the plus to add an element. Select your RVT.

image_2022-04-11_165026753

Now it should look like this.

image_2022-04-11_165144690

If it doesn’t work right away you may need to tweak the grass parameter.

Hope this helps!

5 Likes

Thanks! I got it going. :smiley: The main thing that threw me off, being new to RVTs, was not having an RVT Volume.

And this part (Landscape material grass output), resulted in this

Rather than this

2 Likes

Looks like the mask got inverted at some point. I’m glad you figured it out though. It looks good!

1 Like

Hi, I was trying this technique out in UE5 and the offset was moving all the grass down instead of what should’ve been masked, anyone run into this issue or know how to fix it?

ALL as in the whole landscape? Did you see my last post? There’s an example of that and the fix. The original has Runtime Virtual Texture Sample going in the Grass node, but it should be 'Sample' Grass.

2 Likes

@Astaraa
Any idea what the performance differential is today on whatever engine build you are on between using RTV and not using it specifically on landscape?

My latest test was a couple of months after initial release. Each world partition tile required its own setup. With its own material because (I believe thats still the case) the volume could not change at runtime.
The performance gain was next to nothing. The quality loss rather significant.

I ended up scrapping the idea and going back to static meshes in the end (they just perform a whole lot better than landscape).

My point (aside from wanting to know if the system was at all improved, betting on not): you can achieve the same thing with a render target and custom painting and it will work on anything you put grass on, instead of requiring a landscape and a rtv volume…

You can output opacity in the grass mesh to make it disappear.
Or you can move the verts down. Or both (which may be overkill)

1 Like

Thanks, I got it sorted! Turned out, it was User error, my Runtime Virtual Texture sample was referencing the wrong RVT ;p Thanks for the writeup, this was a very clear and helpful tutorial.

I think Render Target may be the way to go.

And ultimately Static Mesh in place of landscape. But to be tested and seen how it will work with everything else. When you’re still forming things landscape can be useful.

I haven’t used RVT since around or before 5.0 release. I didn’t notice a change in performance. I keep it off because it had issues making it very tedious to edit with. My view of it is I’d rather not use it, and always figured there will be a better way, but in the end it can work.

I think the idea behind it was multiple paint layers from one virtual texture.
With the bonus addition of removing meshes by painting them to the landscape.

However, from what I remeber this wasn’t working with either foliage or the grass output.
Probably the grass output.

It would have been really useful if it did… making it so that you can double down on the way things look and possibly have them paint at any distance (with a rather low resolution ofc).
The VT part was supposed to allow for really good resolution. In my testings it doesnt really…

Is this still working also is there a better way to have meshes/actors that stamp out landscape grass?

I tried all day to make this work but I could not altho it might be because I’m trying to mash it into an advanced landscape material that I didn’t make

I was only able to offset ALL the grass and I could never get it to respond to the static mesh actor that I was placing in my level

Like I wrote:
One of either foliage or Grass fails to write and was never fixed.

Yup, pretty much. I was never able to affect the grass (or, the RVT at all really, it turns out) with the static meshes I was using because I was working with Nanite meshes

Turns out Nanite meshes can’t write to RVTs

Wish the engine would have suggested that somewhere. Like, maybe it shouldn’t allow you to set a mesh to write to the RVT if the mesh has Nanite enabled.

Could it be used to remove grass during runtime? For example, using a line trace to get the impact point from the ground with grass then use sphere trace with radius to remove the grass within that radius.

No, but to do that you run the same texture in world space into the foliage as the value for Opacity.

If you put time into the shader you can make it so that it only samples the exact point at the object’s pivot, so that the whole plant goes away when appropriate instead of partially disappearing.

Samething thing for grass - mostly because its painted in as foliage in like 99% of projects anyway, but even those using grass nodes are better off handing it that way instead of messing with extra landscape paint layers.

Partially because before you hide it you probably want to do other things to it, like move it around or make it bend…

Spent over an hour of my life and @XenoHiraeth solution had me up and running in under 5 minutes