Saturday, February 8, 2020

3d - How to draw efficiently large number of objects with alpha blending?


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.



Answer



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).


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...