Post
by Feralidragon » Sat Feb 24, 2018 1:49 am
First, you could limit this to be nearly fully client-side.
If you do that, not only you spare the server from having to load these and replicate them to the clients, you become able to apply some neat tricks using decals for instance to retrieve texture information from BSP surfaces.
Having that said, the light actors won't really help you that much, as there are tons of maps which have very strong lighting and which are just big empty boxes, and which are as far from being outdoor as a closed room.
Instead, make a list of standard textures which are considered to be "soil" and "grassy" as you would put it, and then trace around near path nodes and other actors (light actors can serve as reference points for this so you can know where you can trace from to increase your coverage area), and use decals to retrieve each hit surface texture to check if it matches any of those, and check the hit normal vector so you don't spawn grass onto walls or ceilings (unless you have special vegetation for those).
Given that it would be mostly client-side, and given that decals can be disabled, you run the risk of the grass to be spawned in different locations for each player or to not be spawned at all.
As for the different locations, you can simply check one of the randomness algorithms in the web and implement it in UScript, so you can actually control the seed. This seed could be randomly generated in the server, and then replicated to all clients so they "randomly" spawn this stuff, but all in the same exactly locations by using the same seed between them.
As for the decals being disabled... I don't think you can really do much in that case.
As to know if it's outdoors or not, I would argue that these textures are used mostly outdoors already, and even when used indoors, seeing grass there may still be the expected behavior.
However, if even so you don't want to have it indoors at all, you can study the size of the area vertically, and check if there's such a thing as a skybox with sky-like textures applied, so you can at least know if it is supposed to exist any outdoors area to begin with.
From here, you can then use more sophisticated approaches, such as checking vegetation meshes around or even check if the name of the texture implies to be "grassy" even if it's not in your list, but I think this would be a good starting point.