I spawn actors during runtime to be placed on landscape. I want to hide grass underneath the placed actors without RVT. I found this reddit achieved post. I’m trying to replicate this. https://www.reddit.com/r/unrealengine/comments/nyeu6t/fun_with_grass_hiding/
So here what I have do far.
Material Param Collection:
Grass Material:
This is the instructions:
"I have a box collision for my player character that gets its location offset and scaled dependent on vector3’s CursorHitStart(initial click) and CursorHitEnd(updated per tick until mouse is released). A plane with a world space aligned texture is parented to the box collision strictly for visuals. The box collision is for getting overlapping actors like trees/rocks/NPC colonists/etc. when released, what it does depends on what tool enum it is currently set to. (select, chop, place, mine, etc)
I then pipe the location and size from my box collision into a material collection parameter. The grass material uses the material collection parameter’s vector3 size and location and plugs it into a box mask, that is inverted and multiplied against the mask texture.
End result is my selection tool’s visuals are no longer obscured by tall grass instances, because they are being masked out dynamically in the material.
So it’s a bit of a mix between the player box tool, sharing information with the material. The nice part is I don’t have to constantly remove/add grass instances for this per tick since it’s powered via material, and is a softer transition.
I am tempted to look into runtime textures at some point, but mostly for other effects.
Oh and here’s the section of blueprint if anyone’s curious, for having the box collision from the player update (adds mousestart and mouse end locations, divides by 2 to find the center which we place our box, then scales the box (box has extent set to 1, 1, 100 or whatever for how high you want it)
The subtracting, squaring, then square rooting is so the box scales correctly in the X and Y direction. Works in both positive and negative directions.
https://i.imgur.com/yTwdhNC.pngThe final part is just plugging the relevant information into the material collection parameter. (I had to multiply by 2 again before plugging it in for the box mask to match the box collision)
The grass grid stuff and dictionary is in C++, but isn’t used or needed for this specific function.
And here’s the actual part in the grass material.https://i.imgur.com/FGoMVv0.pngSuper simple, just grabbing the material collection parameters inputs that we set before and plugging them into a box mask, then inverting. It’s then multiplied by the regular opacity mask used for the grass blades. The lerp is just another parameter I threw in to disable/enable the grass hiding effect when the player presses/releases the marquee selection tool.
"
These are his screenshots: