Jump to content
  • Advertisement
Sign in to follow this  
CodeBoyCjy

Forest rendering problem( how to set the Z buffer ? )

This topic is 3614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey: I'm using XNA to render a forest . And each tree in the forest is a billboard , actually it's not a billboard , it's more like a crossed billboard. To render One tree , I have to turn off the ZBufferWriteEnable functionality.But when rendering a lot of tree , it seems that I have to sort the trees according to the distance between it and the Eye position. But when there are some buildings , things goes wrong , do I need to sort the buildings with the tree??If I don't sort them with the tree , some buildings behand the trees would be in the front because the trees doesn't rewrite the Z buffer. And that'll mean all of the object in the View has to be sorted ( before I render the scene , I have to make a list of the model which contains the current model to be rendered , and sort them ). Or is there any way to do the job?? I'll be really appreciate.

Share this post


Link to post
Share on other sites
Advertisement
Assuming the buildings are completely solid (opaque) and the trees are semi-transparent (translucent, not alpha-tested, see here-after) you first draw the buildings in any order (however, front-to-back would minimize overdraw when depth-test) and next, draw the trees back-to-front (depth-test, but no depth-write).

In the case of alpha-tested imposters you don't even need to sort them, as you can simply draw them together with any solid geometry (i.e. in the same order and pass).

Also, there are other, more modern techniques for efficient rendering of vegetation. I suggest looking up some (free online) chapters of the excellent GPU Gems series of books for example.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!