Forums

Full Version: foliage help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Messing around with the new scenery support, I've successfully added around 250 trees, but it's a pretty big pain to map out the objects in a text file. i have to make a row of them, and then copy it, then change the values and it takes quite a while. i was thinking, what if there was another way to map some of the objects - for instance, if we added a png to the objects directory for each track, maybe objects.png, which could be the same size as the terrain graphic.The png would work like this. Each dot on the map tells what kind of foliage is there and how dense it is. This data is represented by the color value on the map. Each color channel is broken up into 3 or 4 ranges of values, sorta like this:0-33% red: foliage a34-66% red: foliage b67-99% red: foliage c0-33% blue: foliage d34-66% blue: foliage e67-99% blue: foliage f0-33% green: foliage g34-66% green: foliage h67-99% green: foliage iInstead of breaking it up into thirds it could also be fourths, that would give 16 different types of foliage instead of nine. Anyway with the above values, a dot of value 33% green and 100% red and blue would be a lot of foliage g, but nothing else in the the area represented by that dot on the map. The positions of the foliage inside that area would be random, as well as the rotation of the objects. The quantity of foliage g in that area would be the maximum for that type of foliage's range (which would be set along with the model filename in the settings text file).Using this scheme many different combinations can be made, for instance a dot with a lot of foliage a (red 33%), a few of foliage e (40% blue) and a medium amount of foliage i (80% green) could be placed next to a dot with two or three very different types or amounts of foliage, etc. etc. Along with the randomization I think this would make foliage a lot easier to place.Other objects could still be directly mapped to positions as they are now.
This method sounds fine. I'll modify the tree class to do this.
thelusiv Wrote:Each color channel is broken up into 3 or 4 ranges of values ... it could also be fourths, that would give 16 different types of foliage instead of nine.
Actually, if you think about it, you're already (potentially) representing more than 9 types with 3 classifications in each as doing it by RGB individually makes it a 3d matrix.You're thinking of it like this:<pre> R G B1 a b c2 d e f3 g h i</pre>But really you get 27 combinations:<pre> R1 R2 R3 R1 R2 R3 B1 B2 B3B1 a b c G1 j k l G1 s t u B2 d e f G2 m n o G2 v w x B3 g h i G3 p q r G3 y z @</pre>EDIT - actually it's probably more than that... R1G1 has 3 combos with B etcUnless you want colour to affect foilage type (e.g. so more green means conniferus or blue means more bushy) then it could be a lot simpler just breaking down 1 number than it will be combining 3, so you may want to stick with greyscale unless features require otherwise.I do, however, think the 'treemap' image is an excellent idea.
charlieg: I see what you mean and I think you're talking about the same thing I am.<pre> R G B1 a d h2 b e i3 c f j</pre>So, let's say on a given pixel represents a square 5 m x 5 m in the actual game (it may be different, idunno). Let's also say that for each lowercase letter in my matrix above there is a range equivalent to 0-100% that corresponds to the color values 0-33% for a, 34-66% for b, etc. Let's say "a" represents grass, "c" represents bushes, and "h" is an oak tree. Let's also say grass has a 10-unit per-square max density, bushes have a 6-unit max density, and oak trees have a 2-unit max density.So, if there was a dot on the map that had the value a(50%) c(20%) h(10%) then in that 5x5 meter square there would be 4-6 grass tufts, 1-3 bushes, and 0-1 oak tree. The actual numbers of them should have some random coefficients because that's how plants grow, kinda randomly.If there is a dot which has any channel as 0xFF (255) then all the foliage types that channel maps to are forced to 0% for that 5x5 meter square.The extended matrices you made are basically permutations of the system I describe here. As you say, we could have each of these permutations map to another type of foliage, but realistically 9 types of foliage will be plenty for one track. Thus it'd be more useful to be able to combine different types of foliage in a given area than have yet more types of foliage.
charlieg Wrote:I do, however, think the 'treemap' image is an excellent idea.
I must admit the idea is not mine, a grayscale foliage map was used in their FAQ page as well as the rest of how to make Trigger tracks.
Yeah, it's a sweet idea. You could even use the alpha channel, if you needed more for some reason (but I don't think you would).Also, let's stick to trees and bushes -- you won't even be able to see grass tufts.
joevenzon Wrote:Yeah, it's a sweet idea. You could even use the alpha channel, if you needed more for some reason (but I don't think you would).Also, let's stick to trees and bushes -- you won't even be able to see grass tufts.
Yeah, grass would be pretty useless, it would all end up behind the wall. I was just using it as an example. The alpha channel would be useful if we needed to have a square that contained more than 3 different kinds of foliage.How big are those squares anyway?
if you look at the nurburgring's parameters.txt file, the size of the terrain grid is 5 km by 3 km. so, if we use a 512x512 texture, you end up with each square being ~ 10 meters by 6 meters (or 20 by 12 at 256x256).
[quote="thelusiv"]I must admit the idea is not mine, a grayscale foliage map was used in ppracerI don't know if it is exactly the same, but it looks the same
Well the foliage system is really coming along nicely I think. Now there are three detail levels of tree models and textures and a static foliage system that makes good backdrops. We now have 4 kinds of trees and I will be adding 3 or 4 more in the next few days. Trees are now randomly scaled up or down a little bit to give them more variety, as well as turned different ways and their types are still chosen at random. Instead of using an RBG color map that can specify different types of foliage, we just have a grayscale treemap that decides how thick the trees are, and the type is random.Something that would add a lot more realism to the trees would be if they threw a shadow on the ground. Since the trees are placed semi-randomly I think the shadows would have to be calculated when the track loads. I could provide a shadow graphic for each tree much like the one for the cars. It would be nice if the shadow could be laid over the terrain as well as the road.
I agree, a shadow is very necessary....
You want to be careful with shadows because if you don't shade the tree as well as the ground, it can look quite wrong.
charlieg Wrote:You want to be careful with shadows because if you don't shade the tree as well as the ground, it can look quite wrong.
Good point. Joe, what shading is being applied to the trees right now?The shadows in the latest SVN aren't bad. I am about to check in some new shadow tex that are a little less dark, they look a little bit better. Still could use some improvement though.Is the shadow scaled with the size of the tree? How does the game decide where to place the shadow?
OK, I just made a run around the track and noticed that the shadows disappear when you drive over them, they seem to be 'floating' on top of the track. They look good on the terrain. Is there a way that the shadows can be 'drawn' onto the track/terrain to eliminate this? It seems that we'll need some way to alter the texture on the track later if/when skid marks from tires are added.
Yeah, they're floating a bit above the track. I can make them closer to the track, but then there are parts where the track pokes up through the shadow, and that looks really weird.I'm not sure what the best way to draw exactly over a surface is (without redrawing the surface)... any advice?
Since Joe's last post he changed the way they're done and they look very good now. I need to update the shadow graphics themselves a bit more but after that I think the tree shadows are more or less done.The biggest remaining problem I see with the tree system is this:When trees are placed on the terrain, it isn't taken into account where other trees are around them. So, some trees can end up stuck under others. When they're really thick like this the framerate drops quickly. I think the best way to fix this would be to make the game aware of the trees' radii, maybe just have another text file in runtime/data/objects/ called trees.txt that has the width of each tree. This text file could be something like this:<pre># tree 0rad 2.0# tree 1rad 2.0# tree 2rad 4.0# tree 3rad 10.0# tree 4rad 3.0</pre>So each tree would have a radius, and that way the trees could be made to avoid each other and not be too clumpy, even if they are at the highest density.One more idea for the trees: they look a little funny sometimes when the trees are mixed together because usually, trees tend to group together somewhat. It would be nice to have some way to control which types of trees go where so that we could have a clump of pines, then some oaks, blah blah blah.Oh yeah one other thing: it would be nice if the shadows of the trees moved/grew a little along with the weather system, so that as the sun sets the shadows get longer or move.
Pages: 1 2