*Massive* amounts of foliage ...
by Melv May · in Torque Game Engine · 08/21/2002 (3:02 am) · 50 replies
I haven't uploaded this yet as I'm doing some testing before I do so but I couldn't resist posting this little image which shows a very efficient algorithm handling *massive* amounts of foliage.
The previous version had a problem in that if you created large quanities of foliage the system would parse each one at render time to see if it was within the visible distance and this potentially added a huge chunk to the frame-time.
Now, new and improved and after many hours of hard-work, I've included a pretty sophisticated quad-tree algorithm to reduce the foliage down to a minimum. I've also orchestrated it such, that you only have a *single* new field to control the culling resolution which makes it easier for non-programmers to use. ;)
Ultimately, the number of billboards you can render comes down to your card so what I'm showing here is not massive quantities of billboards being *rendered* but the *handling* of that huge dataset efficiently.
In the screenshot I setup *one million* foliage items which brought the previous code to it's knees, even on a top-o-the-line computer. Even with this ridiculous number of objects the system performs at over 100 fps.
I've highlighted the FPS, Foliage Items count and the new field which controls the culling resolution. This figure is in world-units and controls the *worst* resolution at which culling takes places. The algorithm will attempt to cull at lower resolutions starting at the whole foliage area and working down to your specified resolution. The higher the culling resolution, the more memory is taken for the quad-tree as it directly controls the recursive pyramid-depth of the tree itself.
The advantage of this algorithm is that it takes into account many factors including a pseudo-volume that I give to the billboards including the sway factors and standard dimensions. It uses this to cull whole areas of billboards that don't fit within the viewing frustum.
It's pretty neat and I will upload it just after I have sent it for testing to a Linux/Mac friend so I am sure it works on all platforms.
Massive Foliage Handling
- Melv.
The previous version had a problem in that if you created large quanities of foliage the system would parse each one at render time to see if it was within the visible distance and this potentially added a huge chunk to the frame-time.
Now, new and improved and after many hours of hard-work, I've included a pretty sophisticated quad-tree algorithm to reduce the foliage down to a minimum. I've also orchestrated it such, that you only have a *single* new field to control the culling resolution which makes it easier for non-programmers to use. ;)
Ultimately, the number of billboards you can render comes down to your card so what I'm showing here is not massive quantities of billboards being *rendered* but the *handling* of that huge dataset efficiently.
In the screenshot I setup *one million* foliage items which brought the previous code to it's knees, even on a top-o-the-line computer. Even with this ridiculous number of objects the system performs at over 100 fps.
I've highlighted the FPS, Foliage Items count and the new field which controls the culling resolution. This figure is in world-units and controls the *worst* resolution at which culling takes places. The algorithm will attempt to cull at lower resolutions starting at the whole foliage area and working down to your specified resolution. The higher the culling resolution, the more memory is taken for the quad-tree as it directly controls the recursive pyramid-depth of the tree itself.
The advantage of this algorithm is that it takes into account many factors including a pseudo-volume that I give to the billboards including the sway factors and standard dimensions. It uses this to cull whole areas of billboards that don't fit within the viewing frustum.
It's pretty neat and I will upload it just after I have sent it for testing to a Linux/Mac friend so I am sure it works on all platforms.
Massive Foliage Handling
- Melv.
About the author
#3
08/21/2002 (4:41 am)
million!? excellent...
#4
Your just plain sick ;) wish I had the knowledge of opengl/math/c++ to kick something this usful out the door *sigh*
Great job mate!!!
-Ron
08/21/2002 (5:34 am)
Melv,Your just plain sick ;) wish I had the knowledge of opengl/math/c++ to kick something this usful out the door *sigh*
Great job mate!!!
-Ron
#5
Just making some minor amendments to the quad-tree analysis to reduce the memory overhead to a minimum and then I'll post it up asap.
- Melv.
08/21/2002 (10:20 am)
Cheers Guys.Just making some minor amendments to the quad-tree analysis to reduce the memory overhead to a minimum and then I'll post it up asap.
- Melv.
#7
Firstly: THANK YOU! Nice work... I have been playing with the replicator this morning...
My initial attempt reminded me of Stephen King's bit in the original Creepshow movie where everything turns green... including himself :)
Some thoughts on lighting: it doesn't seem to take into account the ambient light of the scene? If you adjust lighting to a nighttime look the grass is quite bright...
Is it practical to use the lighting (shadow) from the scene to affect the billboards?
I bet this could be modified to place .dts files... I see huge use in rock/tree/etc placement... awesome!
EDIT: LOVE IT LOVE IT LOVE IT LOVE IT! The amount of thought put into the controls is tremendous... your code is clean, well commented (not in bulk but concise), and even well formatted...
-J
08/22/2002 (8:13 am)
Melv,Firstly: THANK YOU! Nice work... I have been playing with the replicator this morning...
My initial attempt reminded me of Stephen King's bit in the original Creepshow movie where everything turns green... including himself :)
Some thoughts on lighting: it doesn't seem to take into account the ambient light of the scene? If you adjust lighting to a nighttime look the grass is quite bright...
Is it practical to use the lighting (shadow) from the scene to affect the billboards?
I bet this could be modified to place .dts files... I see huge use in rock/tree/etc placement... awesome!
EDIT: LOVE IT LOVE IT LOVE IT LOVE IT! The amount of thought put into the controls is tremendous... your code is clean, well commented (not in bulk but concise), and even well formatted...
-J
#8
Glad you like it!
You are quite correct, the lighting could do with improvement but it was just a hack that changes the luminosity of each billboard to give the effect of depth.
It would be possible to change this to an ambient colour or do many other things. Certainly, next up, is to integrate meshes so that meshes show close-up and reduce to billboards further out.
The only thing to be careful with is the CullingResolution. If you set it too low on a large area you will eat up huge quantities of memory so you have to be careful.
I am quite pleased with it but there are a few areas of improvement that can be made, I guess I'm never satisfied. ;)
I'll have a look at the lighting case a little more for you though.
- Melv.
08/22/2002 (9:04 am)
Joshua,Glad you like it!
You are quite correct, the lighting could do with improvement but it was just a hack that changes the luminosity of each billboard to give the effect of depth.
It would be possible to change this to an ambient colour or do many other things. Certainly, next up, is to integrate meshes so that meshes show close-up and reduce to billboards further out.
The only thing to be careful with is the CullingResolution. If you set it too low on a large area you will eat up huge quantities of memory so you have to be careful.
I am quite pleased with it but there are a few areas of improvement that can be made, I guess I'm never satisfied. ;)
I'll have a look at the lighting case a little more for you though.
- Melv.
#9
Meshes with the option of billboarding at a distance is better yet...
Is collision a problem in this case?
The lighting option that is in there for modulation is quite good... simulates sunlight rippling thru a field...
Now just need some dandelions floating thru the air... and some way of presenting smells...
Sweetcorn!
-J
08/22/2002 (9:07 am)
Ah you are a step ahead of me... :)Meshes with the option of billboarding at a distance is better yet...
Is collision a problem in this case?
The lighting option that is in there for modulation is quite good... simulates sunlight rippling thru a field...
Now just need some dandelions floating thru the air... and some way of presenting smells...
Sweetcorn!
-J
#10
Collisions are a big issue that I'm currently chewing on.
I've certainly got some thinking to do. ;)
- Melv.
08/22/2002 (9:12 am)
J,Collisions are a big issue that I'm currently chewing on.
I've certainly got some thinking to do. ;)
- Melv.
#11
I am very glad you have taken this on... your work on the water and this replicator improves the potential look of Torque games considerably...
I am also thankful because I need to focus on gameplay and design... I am making a conscious effort to stay away from rendering code... well, as much as possible...
It's ignorant bliss to run thru the weeds... and dip my feet in all the pretty water :)
-J
08/22/2002 (9:29 am)
Melv,I am very glad you have taken this on... your work on the water and this replicator improves the potential look of Torque games considerably...
I am also thankful because I need to focus on gameplay and design... I am making a conscious effort to stay away from rendering code... well, as much as possible...
It's ignorant bliss to run thru the weeds... and dip my feet in all the pretty water :)
-J
#13
Any news on the water update?
-David
Samu Games
08/22/2002 (10:36 am)
Looks great, Melv. Allows for much better coverage, even on my pitiful old Pentium II-400 with a GeForce2. =)Any news on the water update?
-David
Samu Games
#14
I know I shouldn't of but I got a little distracted by the foliage stuff (because it was much more interesting) but I've got no distractions now (not many anyway) so I can get cracking on it.
I'm just not happy at the method used to determine the transition between deep & shore water. Other than that it's essentially ready. Perhaps I should stop being so picky and release it.
I'll sort it soon. ;)
- Melv.
08/22/2002 (10:44 am)
David,I know I shouldn't of but I got a little distracted by the foliage stuff (because it was much more interesting) but I've got no distractions now (not many anyway) so I can get cracking on it.
I'm just not happy at the method used to determine the transition between deep & shore water. Other than that it's essentially ready. Perhaps I should stop being so picky and release it.
I'll sort it soon. ;)
- Melv.
#15
I just want to look at the ability to select go/no-go areas of the terrain for finer control of the foliage placement. ;)
- Melv.
08/22/2002 (10:51 am)
Alright, I admit it, just one more thing and then I'm done ...I just want to look at the ability to select go/no-go areas of the terrain for finer control of the foliage placement. ;)
- Melv.
#17
The reason I'm asking is because a flat object for a tree isn't very realistic, to me, especially when a game would want someone to be able to 'land' or sit in the tree itself to hide.
Another question I have is, are some of these techniques your using applicable to speeding up the particle engine in Torque? I think another area that Torque could improve in is the particle effects engine, its slow and out-dated and I think torque could benefit greatly from overhauling it. One specific idea I think might be applicable is not pushing the particles through the scene manager, much like what your doing with the foliage. But again, I havn't really looked at the particles, so maybe this doesn't apply anyway.
08/22/2002 (12:40 pm)
Melv, have we moved on to mesh rendering of these foliage objects now or is that just not possible?The reason I'm asking is because a flat object for a tree isn't very realistic, to me, especially when a game would want someone to be able to 'land' or sit in the tree itself to hide.
Another question I have is, are some of these techniques your using applicable to speeding up the particle engine in Torque? I think another area that Torque could improve in is the particle effects engine, its slow and out-dated and I think torque could benefit greatly from overhauling it. One specific idea I think might be applicable is not pushing the particles through the scene manager, much like what your doing with the foliage. But again, I havn't really looked at the particles, so maybe this doesn't apply anyway.
#18
You are quite correct, this would be a much more intuitive method for foliage placement but I still think that the ability to quickly insert/remove billboards in areas has it's place. ;)
@Robert: The particle engine was one of the first things I wanted to redo completely as I created a really cool one for Wildtangent last year. It's just that I haven't seen many people complaining about the existing one so I didn't want to reinvent the wheel.
I'm also not quite up on all of the existing particle engines' features. Can particles spawn new particles so that you get cascading effects? Can it create shaped explosions or is that done via other code using it? Can particles collide with scene objects?
The engine I did previous could do all this and more including motion blur etc. You can see it here, select "ScreenShots" / "fxExplosion".
Perhaps we could start a thread with the requirements of a new/enhanced particle engine. If enough people wanted it then I would be glad to give it a go as particle engines are fun to write and even better to look at. ;)
- Melv.
08/23/2002 (1:53 am)
@Harold: @Robert: The particle engine was one of the first things I wanted to redo completely as I created a really cool one for Wildtangent last year. It's just that I haven't seen many people complaining about the existing one so I didn't want to reinvent the wheel.
I'm also not quite up on all of the existing particle engines' features. Can particles spawn new particles so that you get cascading effects? Can it create shaped explosions or is that done via other code using it? Can particles collide with scene objects?
The engine I did previous could do all this and more including motion blur etc. You can see it here, select "ScreenShots" / "fxExplosion".
Perhaps we could start a thread with the requirements of a new/enhanced particle engine. If enough people wanted it then I would be glad to give it a go as particle engines are fun to write and even better to look at. ;)
- Melv.
#19
If you are interested in tweaking your culling resolution then this amendment is for you!
- Melv.
08/23/2002 (3:38 am)
EDIT: 23/08/2002 - Fixed minor problem with visualisation of DebugInfo quad-tree boxes. The Z bounds are now clipped to the lowest/highest placed foliage item.If you are interested in tweaking your culling resolution then this amendment is for you!
- Melv.
#20
Keep up the great work!
Particle engine enhancements next? You're certainly covering a lot of areas. If you need a tester let me know :)
08/23/2002 (5:55 am)
Melv I finally dropped this code in last night...so very cool. I like it even more after using it then I thought I would. Lot's of very useful options and settings. The only bad thing is now it's hard to look at a normal mission without at least some foliage use ;)Keep up the great work!
Particle engine enhancements next? You're certainly covering a lot of areas. If you need a tester let me know :)
Associate Stefan Beffy Moises
*one million* foliage items ...
that's amazing, Melv!!! :))
Can't wait to get it and then flood all my levels with foliage stuff...! ;)