Hey there, recently I’ve gotten down to creating some forests with some prefabs that I’ve created in blender. Every tree is very much low poly, but since the forests take up so much space (semi-open worldish…) there are way too many vertices/tris to draw out:
(5.5 million vertices)
The problem being that . For some reason, Occlusion Culling really isn’t doing much at all, so this is what’s being drawn in reality:
Here are the types of trees I’m working with. They are all low poly:
So the obvious solution is to draw what’s closer. There are a couple problems that crop up with just setting my camera’s far clipping plane down, even though the fps raises due to so many less vertices drawn:
Now, there’s a sea of blue, and I have two ways in which I can solve it. I can paint right onto the skybox, which I’m going to do anyway…
…but I thought a better solution would be to do one or more of the following:
Write a sight distance script, instead of having the camera’s far clipping plane. Have the objects when they first appear fade in like in GTA. Then, I can have terrain and water planes be completely ignored by this or drawn much farther than the trees.
Perhaps then I could kind of just stimulate the eyes by writing code somehow in where the terrain grass texture fades slightly to more bluish (a cooler color) the farther away it is from the camera.
Have half the trees or so be tagged as “unimportant” objects, so that on lesser quality settings they are simply inactive altogether, not being drawn at all.
Have the game simply not be as open-world, more linear, which is fine as it’s a story rpg game with side-quests here and there. I could just block out paths with the wintergreen pine trees.
Since the trees use flat planes, have all of the planes but one that faces the camera disappear from far away, a means of using a kind of custom LOD script.
Use a faster shadow engine, which is obvious. I’m not looking for realism, but the current Unity shadow engine is very slow.
So I’m wondering what experienced Unity user’s thoughts are on all of this, if anyone here has tried this, and what they would suggest, what kind of issues I might run into, or better and faster ways possibly of going about solving these perfomance issues?
The typical technique is to store foliage as abstract data rather than placing prefabs, like the Unity terrain system does. Then the foliage system creates meshes on the fly, handles LOD, and so on. This also makes editing much simpler. In fact it would probably be a good idea just to use the Unity terrain; it’s rather outdated but should work well enough for this. Your main problem is not the number of verts (which is not too much for any half-decent GPU to handle well), but rather the massive number of draw calls. Occlusion culling won’t really work for this sort of thing since it depends on geometry being like solid walls that totally block everything behind them.
Oh, I see, that explains quite a lot. So it’s just that I have to get it to draw quite a lot less, and occlusion culling simply isn’t detecting the thin planes as walls then. Hmmm…The problem with the Unity terrain engine as far as trees go is that it wouldn’t take in and place the prefabs that I had created, and I simply don’t know how to easily and quickly export the tree models from blender as a single geometry in a format. Now that they’re done as prefabs, I’m thinking of sticking with that way of doing it if at all possible…
So since it’s all of the drawing that has to be limited, I think I’m going to try to write custom code to handle LOD by cutting back on the number of planes the farther away the trees are, and having unimportant foliage just not display at all.
It’s not really the typical Unity way of doing things, but it should at least cut back on what’s being displayed…The top plane parts of the trees, again, are like solid walls (it’s an insanely thin cube), it just must be so thin that the occlusion culling isn’t picking up on it.
The CPU I’m using isn’t that great by these days standards anyway, it’s an HP laptop with shared Radeon R5 graphics, although I think I can use that to my benefit because I want this game to be low poly and work on most computers. It looks like I’ve got a little bit of work to do though to get there…I’m gonna have to work with creating a custom LOD script for this then is what I’m understanding where things are either changed or don’t display at all when farther away.
Okay, I’m editing this with an update…
I suspect that it could be vertice related again, because of this:
The second those vertices go up, the framerate drops immediately. I’m going to do terrain in Blender either tomorrow or the day after to run some tests on it. I don’t really see a reason to have such high res terrain in the first place with it being a low poly game, those planes are pretty high res.
The main problem is not so much the vertices that are going up, but the draw calls. I’d recommend spending some time learning the proper technique for getting trees to work with the terrain system, since there’s no feasible way to make it work with a zillion prefabs.
Yeah, I just tested a bunch of the pine trees that don’t have the stumps and it seems to be just that…
I’m gonna look into it, then, but another problem I have then is just drawing terrain. Maybe then it’s better to do the terrain in blender or something if you can’t view it from large distances on a low to mid end comp?