The new grass system of 4.8 is nice, but there is one problem: I spawn grass everywhere where the grass material is, but what if I place a house there? Then the grass is visible inside of the house, going through the floor.
So we need something to disable grass from being rendered in a certain area, so if I spawn a house in this house I would have a grass blocking volume in the size of its bounds and the problem would be solved.
Or is there anything what I could use to workaround this?
How can I paint a different material below the house when spawning the house? Everything in my game get’s spawned and destroyed while the game is running.
No comment? Another place where I need this is for creating “footpaths” the player can build during the game where AI can walk on, and of course there the grass has to disappear.
I have a building system and removing the grass under the floor could be quite good.
Are you sure that his is not possible somehow? I know that Ark also has grass inside of the house
which looks pretty ugly :X
I’ve been thinking about this problem since the UDK time with its foliage system. It also are spawned even in difficult places to be manually deleted one-by-one…
Couldn’t we use the distance to nearest surface and use that as a mask for the grass output node? Would need a remap node in the editor though (making a mat function is next on my list). So distance < 0 = no grass and gradually getting to full density as it gets to a distance of 1m.
I’ve done this with a mask. Just use the grass node and put a filter on it. Sorry, I’m not at home now to look at the material to tell how to do this, but its quite easy with UE 4.8
its easy in the material with a mask, i just wish you could have more than 1 grass node. for example so you can do woodland area grass then do wetland area grass.
And how do you modify this mask? So lets say I place a building somewhere and the grass needs to disappear there. How do you modify the mask to make the grass disappear on the world location where the building is placed?
I don’t think it is possible with the current version of the engine. As far as I understand it, UE creates a “grass mask” by rendering material nodes that are connected to the “Landscape grass output” into a 2d texture. This texture is then used to spawn the instances of foliage. The thing is that the grassmap can be rendered only in the editor and not during runtime (the code is commented out in the “game” mode so there is no way around it).
I actually modified our local version of the engine to allow recreating the grassmap in runtime but it is still very crafty with lot’s of visual artifacts (e.g. once a grassmap is recreated all existing instances on a given landscape component disappear and you need to wait some time until new ones are generated. I was planning to work in this in future but having an official solution from Epic would be definitely a big time saver.
Are the grass instances just instances in a Hierarchical Instanced Static Mesh Component or are they stored in another special way? If they are just instances, it would be enough to set the instances which should disappear to a scale of 0, then the grass would not have to get “regenerated” since all instances stay where they are. I don’t think there is a way to get the grass hit by a trace to get the instance index in a specific area, but if we could access the Component the grass is stored in then we could just loop through all instances and compare the instance location with the location where we want to remove the grass. A waste of performance, but it would be a nice workaround until Epic introduces an official solution.
Yes the instances are in a HISMC. It may be possible to do the scaling trick if all you want to do is to remove existing instances but I have never looked into this myself (in my project I need to both remove and add the instances so this wouldn’t work for me).
If you want to add instances you could also do it in the HISMC instead of modifying the mask, adding instances does not modify or regenerate the existing ones. I don’t use c++, is there any way how I could access this HISMC from blueprint? Which class is the Actor of where the HISMC is inside? If I know the class I could just do a GetAllActorsOfClass and then get the HISMC and modify it.
I’m not really sure. I do most of the work on the project directly in C++ and I don’t use blueprints too much. I was planning to directly modify the existing HISMC directly using C++ but haven’t had time to work on it yet.
Yeah if I would know the name of the Class (Actor) which owns the HISMC I probably could access it from blueprint, so if you know the name please tell me
All I can tell is that the components are stored inside landscape proxy actor (ALandscapeProxy) which is the parent of the main ALandscape class. There can be multiple HISMC components inside of the landscape but I don’t believe they are exposed to Blueprints… if you have access to UE source on git you can check the declaration in https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/Landscape/Classes/LandscapeProxy.h