In a 3D game i have large no. of trees with alpha value. What is the efficient way to draw all? What i tried is Taking every tree as a object and draw according to its z value and using billboarding. But large draw calls, hiting performance.
|
|
You can use geometry instancing to draw a large number of trees in one draw call. (That article is written about Direct3D 9, but the same feature should be available in any 3D graphics API.) That should improve CPU performance, if that's indeed the bottleneck. If the trees are alpha-blended you still have to sort them back-to-front yourself, though, which can itself be a significant performance cost. There's no good way around the necessity of sorting to get correct rendering with alpha blending (although see this answer for some alternative approaches). |
|||
|
|
|
You can set a maximum draw distance and use it as a limit instead drawing every tree. With Z buffer you can start by drawing the trees closer to your point of view and then move to the farthest trees. Also be sure of not drawing trees or objects if they are outside of your current view. (Culling) Finally another way to deal with this is not drawing trees that are already hidden by other trees. For that you need to make a vector from the point of view to the target tree and see if there is a tree intersection in the middle. If its true then you don't draw the tree. I hope I helped. |
|||||||
|
