Page 1 of 1

Determining outdoor areas

Posted: Fri Feb 23, 2018 10:28 pm
by Gustavo6046
Hello. I'm doing a mutator that adds grass and other environmental effects (with graphics, sound and basic interaction, the latter which is mostly aesthetic) to the level, but it's more logical that grass is added in the right spots.

Right now, my idea for the grass part is:
  1. Pick every NavigationPoint.
  2. For each NavigationPoint, test whether it is located in an outdoor area.
  3. In case it is located in an outdoor area, add grass patches.
However, I'm stuck with a problem, and it's in the 2nd "step": how would a Mutator find out whether a NavigationPoint is in an outdoor area? Which areas would be more appropriate to add grass, after all?

To solve this problem, I began with defining "grassy outdoor":
  • It must be a wide open area. (Finding and averaging the distance of eight diagonally upward Traces should give some sense of spatial volume)
  • It must be well lit. (Summing the quotients of all visible Lights' brightnesses * radii by their square root distance will be a rather inaccurate, but quick fix)
  • It should be in a vegetable area, preferably with soil (although we all know grass can grow anywhere, even in your keyboard!)
But it's a rather messy definition that is only necessary due to the limits of the engine's flexibility, so do you have any better ideas?

Re: Determining outdoor areas

Posted: Sat Feb 24, 2018 1:17 am
by papercoffee
You best bet would be just to create a zone-actor for this.

Re: Determining outdoor areas

Posted: Sat Feb 24, 2018 1:49 am
by Feralidragon
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.

Re: Determining outdoor areas

Posted: Sat Feb 24, 2018 2:11 am
If I had to make ways for it to be automated I would try
*list of specified textures to generate
*is it directly under a texture with skybox btrue?

But I have to ask, like all iventions what is the intended use? A tool for map making to save time? A add on for someone to play the game "more beaurifull" from just a users perspective?

Re: Determining outdoor areas

Posted: Sun May 27, 2018 5:49 pm
by Gustavo6046
Well, it is to add outdoor decoration, and automatically fill in blanks with eyecandy. To be used with poorly detailed maps, or even the stock ones if desired.