Jump to content
  • Advertisement
Sign in to follow this  
Hiyar

Sorting alpha blended grass

This topic is 2485 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

Hi,
I am not satisfied with alpha tested grass, harsh edges are the main problem.
Also dissolving at distance is a problem too, I tried to use noise texture to simulate "fade out effect" but it still looks like garbage.
I also used a 2 pass approach alpha blending and alpha testing, but in the end I decided to use alpha blending only with semi transparent grass billboards. This is expensive but looks very natural, this gave me the best results, but I dont know how to sort the billboards properly.
I read somewhere that one can first sort the grass batches(grid cells) and then use pre calculated view positions, if I understand correctly, but this would eat alot memory.
So how do you sort grass billboards in an efficient way.

Thanks

Share this post


Link to post
Share on other sites
Advertisement
I mean grass rendering as described here
Anyone tried to sort like this?
Or another approach?
Any suggestions?

Share this post


Link to post
Share on other sites
To sort the billboards, just sort from distance to the camera. Qsort is a good place to start for the first frame, but after that, since the camera moves slowly frame-to-frame, and the desired render order for the billboards will change a little at a time, bubble sort is a usable choice. Bubble sort is the 'worst' sort because its O(n^2), but for incremental updates, its close to O(n). If you're worried about the worst-case scenario where a bunch of things suddenly reverse sort order, you can limit the number of iterations of the bubble sort per frame. What this will do, is it will keep up with the 'small' changes, but if there's a LOT of things changing order at once, the job will be broken into multiple frames. The user will see the incorrect order for a few frame, and then it will 'pop' to the correct order. But this is probably better than just stalling..

If your terrain is broken into difference sections (like a grid or whatever), then you can do the sort in two levels: Sort the sections based on distance, and then the contents of each section by distance. This breaks the sort down to where its easier to manage. In fact, distance sections don't have to be sorted every frame, since at a distance, the view angle changes very slowly. Basically you would re-sort the section the camera is in, then then re-sort the other sections only if their view angle has changed more than some threshold angle. This should work as long as each grass part is restricted to a particular section; if a piece of grass spans two sections, there will be problems.

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!