Thursday, July 21, 2011

Trees man, how do they work?

Working in the source engine makes making trees an expensive and painful task.

The material system in the source engine seems to rely on dirtymods and workarounds. Traditionally trees consist of a mesh based trunk with static particle leaves, a quick look at any speedtree based game will show this. Stock valve trees don't have this, which makes me question the applicability of the "sprite" shader that comes with the engine. If valve saw fit to not use this shader to make their trees, why would I want to?

I guess I'll have to have a look into the use of that shader. Using a sprite system would change the way I make trees anyway. Using static polygons means you can use simple quads to define whole branches, but with a player-view particle you would have to only render leaves and leaf bunches, not the whole branch. Otherwise you'd have rotting branches and it would be quite a fiasco.

Trees are an already resource intensive application

And I don't think it is in my capacity to change this. Particle leaves would be cheaper to render since they would have only one side but then more polygons would be used to define each leaf cluster, and more branches. Static mesh leaves can define larger branches and such, but they have to be rendered twice, with $nocull.

LOD models are definitely a must for trees, the trunks can be dropped from an 8 vertice circle to 6 and then 4, leaves can be removed and edgeloops in curved faces deleted, the final LOD can be a billboard (which also eludes me in source, so I have to make my final LOD models crossing quads) which renders very cheaply at all distances. But I think that system can be further optimised.

I plan on making not only tree models, but tree clumps, or stands. Up close these would be just a bunch of trees and simple undergrowth or whatnot, and then as you move through the LODs I can change not only the individual trees to billboards and such, but multiple trees. In a wide stand of trees I could leave the outer trees at LOD1 and have the center trees go to LOD4, drastically dropping the polycount without the difference being too noticable. I could even have all the center trees drop to one or two billboards depicting a render of the whole stand of trees, giving the illusion of bushiness and depth.

At a very far distance trees tend to bush out enough that they look like little broccoli heads, and this could be the final LOD, a very simple dome or arrangement of billboards that would look like the original clump from a distance and could be used to render on distant terrain. I think it would be a better system than most these days, especially on hills. Tree billboard LODs on hills look terribad, a few clump dome LODs would look far better, and if you take into account the amount of billboard LODs a simple forest would have at that distance, I think the clumps would be cheaper to render.

Actually, you know what? Computers are far better than I give them credit for. Current LOD systems are probably optimised plenny. No LODs, voxels everywhere.

No comments:

Post a Comment