Determining outdoor areas

Discussions about Coding and Scripting
Post Reply
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Determining outdoor areas

Post 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?
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
User avatar
papercoffee
Godlike
Posts: 10443
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.
Contact:

Re: Determining outdoor areas

Post by papercoffee »

You best bet would be just to create a zone-actor for this.
User avatar
Feralidragon
Godlike
Posts: 5489
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: Determining outdoor areas

Post 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.
User avatar
XaNKoNII
Skilled
Posts: 216
Joined: Wed Jun 09, 2010 12:29 pm
Personal rank: Phenix
Location: Portugal

Re: Determining outdoor areas

Post by XaNKoNII »

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?
User avatar
Gustavo6046
Godlike
Posts: 1462
Joined: Mon Jun 01, 2015 7:08 pm
Personal rank: Resident Wallaby
Location: Porto Alegre, Brazil
Contact:

Re: Determining outdoor areas

Post 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.
"Everyone is an idea man. Everybody thinks they have a revolutionary new game concept that no one else has ever thought of. Having cool ideas will rarely get you anywhere in the games industry. You have to be able to implement your ideas or provide some useful skill. Never join a project whose idea man or leader has no obvious development skills. Never join a project that only has a web designer. You have your own ideas. Focus on them carefully and in small chunks and you will be able to develop cool projects."

Weapon of Destruction
Post Reply