Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / Foliage library

Author
Message
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Feb 2009 18:54 Edited at: 21st Feb 2009 07:34
As a small side project I've been working on this foliage library for GDK, I haven't named it yet so ideas on that would be great. Basically this is a flexible and fast library that handles many useful aspects of foliage in games. The library is easy to add into any project and it's contained in its own classes making good use of OOP so you can easily expand any portion of it to your liking.

Public releases:

Version 1.0:
DOWNLOAD
LICENCE

Demos:

Basic foliage sandbox!:
DEMO DOWNLOAD
README

Features:

Trees with unlimited LOD levels
Create scenes with tens of thousands of trees
Billboards for efficient rendering of trees at a distance
Real-time shadows via shaders
Add trees and other foliage seamlessly in real-time
Static objects are grouped into a single object, requiring only one draw-call to render
Efficient handling(multiple solver types) of large amounts of foliage objects
Comes with free very high-detail models & textures(photo based)
Trees and grass sway in the wind
Create grass that follows the camera around, giving you an unlimited sized grassland
Have your endless grass always stick to your terrain's surface and even avoid certain areas(like the rocks below)
Create trees that drop/spawn leaves that glide off in the wind
Efficient 3d object garbage collection system allowing you to fly through a forest with little to no performance impact
No DLLs to hassle with!

Possible future features:
A more complex tree simulation, so a tree would look like it was in a gale force wind if it was
Elegant fading in/out of LOD levels and ground foliage
An editor to create billboard textures and other things
More media!
An automatic tree generator
Allow trees to have varying textures(i.e. if it started to snow, put snow on the leaves)

Pictures:





If the thumbnails don't load:
[1]
[2]
[3]
[4]

NOTE: Those trees aren't very good and I'll redo them or improve them eventually, they don't even fit in with this scene but oh well.

Other stuff you probably won't read:

Currently this foliage library was built for another project I'm working on which may or may not be showcased here soon, and as such it wasn't originally intended for the community, this means that it's going to be 100% free(unless people request really advanced features that takes up a lot of my time).

When released I'll include all media for free(edited by myself from royalty free sources) as well as the source code so you can port it to DBPro or something. I don't have time right now to prepare a video but the screenshots should suffice. I'll eventually release a demo when there's more media as currently you can't do much, other than spawn random stuff and look around.

Lastly, C&C are very welcome. I'd like to hear ideas for features you'd like to see in this kind of library as my list is running a bit low.

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 7th Feb 2009 20:00
looks very good, and hearing that you'll release the source for possible port to dbpro will make a lot (more) of us happy.

one feature i don't see often enough in a foliage system is something i'll call 'trail blazing' where, when a character, creature, vehicle, etc, passes through tall(ish) grasses, reeds, etc, the foliage leans, bends, and breaks in natural, appropriate direction(s), leaving a "trail" behind.

the addition of such a function could enhance any genre of game that utilizes foliage by allowing players to track and identify enemies based on the trail(s) they discover, or consider the ramifications of the trails the player leaves, for example(s). it would also help with any type of terrain alteration/destruction system people might be using in their games. all of this with the idea of terrain/foliage being more than "eye candy" or simple obstacle that both player and programmer might tend to take (somewhat) for granted in a number of ways.

looking forward to this, dc. coming from you gives this plenty of potential!

Virtual Nomad @ California, USA
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Airslide
19
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 7th Feb 2009 20:44
Looks really cool!

I've found it is really difficult to get lush looking foliage and still maintain a decent speed, and I'm sure others have the same problem. This will be a very useful addition to the community

Monk
15
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 7th Feb 2009 23:20
This sounds and looks great!! Hope there is a version available for DBPro =)
An idea that I think would be good would be to have grass of vareying lengths, as well as trees and mid level shrubbery. Its not often that you see games with grass instead of lookalike textures, and i think thatd be cool...
Good work though

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Feb 2009 23:58
@Virtual Nomad

Good idea, if you want these tracks to persist over a long time(i.e. you walk over some grass and come back to it after exploring for ages and it's still squashed) that's a little harder to do as I'd need to potentially store quite a lot of data especially if there are multiple sources for the flattening. However if it's only for local things and they get erased when you walk away then it's quite easy to add.

@Airslide, thanks

@Monk

If there is I won't be porting it as I don't use DBPro that much these days and because of the complexity of certain aspects it would probably be faster in a plug-in, but I've never written one for DBPro so I wouldn't know where to begin.

"An idea that I think would be good would be to have grass of vareying lengths"

You can already do this, however I only have 2 'grass' objects(well one's more or less weeds), maybe it's not very evident in my screenshots but all the objects have slightly different scales and rotations. I'll be making some more grass textures and stuff soon though.

"as well as trees and mid level shrubbery"

Indeed there's only one tree/shrub thing that's between grass and a proper tree so I'll need to make more variation there, I have loads of awesome reference pictures so I know what to aim for though.

Thanks for the comments, keep them coming!

Monk
15
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 8th Feb 2009 13:49
Looking at your screenshots, theres not much more to suggest, that you havent already nailed
I don't know if your trees are animated but if that doesnt take up a huge amount of time, then that would be a welcome addition.
Also, perhaps some interactivity between a player and the trees. This is probably complicated, but to be fair, you seem to have really got the trees looking nice so that theres not much else you can do to improve them...
The interactivity is only really so that if and hopefully when you release the library, people can start to use your foliage in games.

P.s if you manage to put snow on your trees, that'd be AWESOME!!
Cant wait for a demo...

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 9th Feb 2009 21:14 Edited at: 9th Feb 2009 21:16
OK I tidied up some of the media and added some new types(2 of them created from my own pics), fixed some small issues and made a demo!

Demo1 - Basic foliage sandbox!

README
DEMO DOWNLOAD
New pics: [5] [6]

Controls, notes and possible issues are in the readme. Also because you probably didn't read the readme, the demo uses a lot of high res textures so don't be surprised if you have a crap PC and get low FPS with nothing on the scene, try using a lower shadow map resolution or manually resizing the textures(fun).

prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 9th Feb 2009 21:25
It looks amazing! There always is a lack of foliage in dbpro/gdk games, and now if it is released, all of that will change!
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 9th Feb 2009 23:41 Edited at: 9th Feb 2009 23:42
all 'tests' with 1 of ea type (1-6), ~220 objects, 1 priority object, ~4500 instances, and cache flushed (JIC):

1680x1050 full, shadows @ 2048 w/ ~220k tris = ~22-24 fps
i dont think i noticed any shadows here

1680x1050 full, shadows @ 256 w/ ~189k tris = ~40-44 fps
shadow effects not bad, here.

1024x768 windowed, shadows @ 256 w/ ~215k tris = solid 60 fps
very nice, in maxed mode, too.

i didn't notice anything wrong with distant clusters on my ati card as mentioned in the readme but i'm not sure what to look for.

everything looked natural to me except when approaching distant trees; they appear to lean (exactly?) the opposite way compared to their distant versions.



specs in sig.

Virtual Nomad @ California, USA
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit

Attachments

Login to view attachments
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 10th Feb 2009 01:35
Great little program, I made a forest with lots a trees lol, I guess I pressed 2 like 10 or 15 times, and it ran great.. I just noticed it made a huge performance drop when adding the grass though, from 75fps to about 50fps

What kind of control will we have with using it in GDK? Because this would be a great addition for me if I can use it properly


Making dreams possible, one line at a time...
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 10th Feb 2009 05:57
Quote: "i didn't notice anything wrong with distant clusters on my ati card as mentioned in the readme but i'm not sure what to look for."


Maybe it only affects some ATI cards, one of my testers had some model of the 4850(I don't remember exactly) and he reported not noticing any size variation in the leaf clumps, so when you got closer you could see all the branches and the leaves were all tiny. Apparently this doesn't affect all ATI cards so no idea, I'll be implementing some proper billboard leaves eventually.

Quote: "everything looked natural to me except when approaching distant trees; they appear to lean (exactly?) the opposite way compared to their distant versions."


The distant LOD billboards only use a single texture for all trees of the same type(of which there are 3), I didn't take into account the rotation of the higher detail tree and rotate the billboard so I'll add this in. However they sway the exact same as the higher detail ones. Eventually I'll make it so that the distance LOD billboards use snapshots from multiple angles of the high detail tree so it looks as close to the highest detail one as possible at all times.

Quote: "I just noticed it made a huge performance drop when adding the grass though, from 75fps to about 50fps"


Yep, adding grass shouldn't be done more than once unless your PC can handle all the additional fillrate. Though if you get close to the ground you can see that there's quite a lot to draw.

Quote: "What kind of control will we have with using it in GDK? Because this would be a great addition for me if I can use it properly"


It depends for what, adding trees and static props(rocks, logs etc) gives you full control over the amount of instances of that type of thing, their rotation, scale and position. Things like trees can be repositioned and re-rotated at any time however instances of an object group can't but I can easily add that in.

The way objects that follow the camera are handled is slightly different, you select the size of each foliage cell and the amount of cells on the X/Z axis, the amount of instances in each cell and the source objects. These automatically follow the camera around and thus you don't have control over their placement(though you initially do) but their placement uses a function callback so you can tell the engine what the terrain height is at that location and you can return false if you don't want foliage spawning there and it is hidden for this cell.

Here's an excerpt from main.cpp of the demo that spawns the grass(it creates 3 instances of 2 types):



and the declaration for this CreateTileShiftArray method is:



where groupID is the foliage group you've loaded into the foliage pool, in this case I pass 'groupGrass' which contains about 10 types of items, 2 of which are used here(0 and 1). Also this above function is merely a helper function that automatically creates loads of instances of 'class FoliageTileShift' where each instance signifies a cell, if you need full control over how they are spawned and where then you can call its constructor manually and/or look at how this helper function does it. Foliage items are added to the foliage pool(think of it as a media library) like this:



I'll explain it in more detail when I come to release the code but I think it's fairly easy to use.

Monk
15
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 10th Feb 2009 17:51
Looking good!
Ill try the demo once ive reformatted my pc

Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 10th Feb 2009 20:32
Ok what I was mainly asking is if I can integrate this with my current engine, basically I dont have an LOD system and one that handles objects like that, So I was wondering if it is easy to implement static locations with it so when I go to make a map format it can handle that


Making dreams possible, one line at a time...
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 11th Feb 2009 02:47
Quote: "basically I dont have an LOD system and one that handles objects like that"


This library handles the LOD so you don't need to make any special code, you just need to add the LOD levels to the object pool(which is part of the lib).

Quote: "So I was wondering if it is easy to implement static locations with it so when I go to make a map format it can handle that"


When you press 1 in the demo, other than the loop and randomly picking one of three trees the only code that gets called is:



Where FindHeightAtXZ() is a function in your code(not the lib) that finds the terrain height at this X/Z position.

Monk
15
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 11th Feb 2009 17:51 Edited at: 11th Feb 2009 17:59
That is cool! The trees actually look like they are dancing sometimes with the swaying...
Now that youve released a demo, im gonna throw my ideas into the pot.
The trees could be made to sway at the same time, not into each other...
Possibly some collision between the camera and the trees,
Some slightly more realistic colours for the leaves,
and finally, when you add grass, it does look real, but possibly the terrain could be retextured so that it looks grassy from a distance, not just normal.

Sorry for being nitpicky...

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 16th Feb 2009 19:17
Public release 1

DOWNLOAD
LICENCE

The download contains the full source to the library, media, code to the demo above and 4 samples showing you how to implement basic stuff. The examples aren't exactly amazing but I didn't spend long on them so what can you expect. If you have any questions about stuff then feel free to post them here.

Lastly, I'm probably going to be busy on my other projects for a little bit so I dunno what else I can add to this for a while, so don't expect any major changes any time soon.

----------

Quote: "The trees could be made to sway at the same time, not into each other..."


They used to sway together but it looked rather bland so I made them sway based on their position, besides the whole swaying thing is part of my tree's vertex shaders so you can just modify those.

Quote: "Possibly some collision between the camera and the trees,"


No point in adding this to my library as it's meant to be quite modular(is that the right term?). When spawning trees you can easily enough place a collision object there or generate collision data at that position, otherwise my lib would require either code to handle collisions(no point with so many collision libs around, plus it'd likely be slower) or to implement something like sparky's lib into my lib, but this adds more bloat to my code and you may not want to use that collision lib, especially if you already use DarkPhysics or something.

Quote: "Some slightly more realistic colours for the leaves,"


It's not easy making those leaves you know! Plus taking pics of good bunches of leaves isn't all that easy either, the light green tree in the demo was made using several leaves on their own and I spent a while pasting them around and shifting their colours etc.

Quote: "and finally, when you add grass, it does look real, but possibly the terrain could be retextured so that it looks grassy from a distance, not just normal."


Perhaps, but it's only a demo and not a game, anyone using this can always add such a feature in by themselves.

Monk
15
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 16th Feb 2009 22:59 Edited at: 16th Feb 2009 23:15
Glad youve released it!! Am downloading now so cant wait to have another look and a play with it.
Not often you get to read a licence though.. =)
Is the code in DarkGDk or dbpro?
Sorry silly question cos ill find out in a min anyway but if its in darkgdk is there anyway of converting it to dbpro or should i just learn dark gdk...?
Happy to see you liked the suggestions
Good work!

ps, i just looked back at the pictures you posted with the demo, and i didnt notice the rocks etc as well as the trees, thats cool!
pss, i think i got carried away,see the pic attached...=)

Attachments

Login to view attachments
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 17th Feb 2009 06:14
Quote: "Is the code in DarkGDk or dbpro?"


All GDK.

Quote: "Sorry silly question cos ill find out in a min anyway but if its in darkgdk is there anyway of converting it to dbpro or should i just learn dark gdk...?"


No easy way because DBPro doesn't even support 90% of the coding techniques used so it may be easier to start using GDK unless you know C++ well enough to port it.

Quote: "Happy to see you liked the suggestions"


Every post counts :p.

Quote: "ps, i just looked back at the pictures you posted with the demo, and i didnt notice the rocks etc as well as the trees, thats cool!
pss, i think i got carried away,see the pic attached...=)"


Awesome .

Monk
15
Years of Service
User Offline
Joined: 25th Sep 2008
Location: Standing in the snow =D
Posted: 17th Feb 2009 11:48
I know no c++ so i think that when i get the chance, i might just start to learn gdk on the sidelines...

FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 28th Mar 2009 22:09
looks very good, just the grass looks creepy maybe it should be a little smaler a little darker color....

Game.Love
thm120
15
Years of Service
User Offline
Joined: 28th Dec 2008
Location:
Posted: 17th Jul 2009 06:41
how do u install this?
Brick Break
User Banned
Posted: 17th Jul 2009 07:04
Yay trees. Thanks

WINNER list:
Latch, Lee Bamber, TDK
Thanks for the help!
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 17th Jul 2009 08:53
Posts eh.

Quote: "looks very good, just the grass looks creepy maybe it should be a little smaler a little darker color...."


Change it then .

Quote: "how do u install this?"


Click DOWNLOAD under 'Version 1.0' and extract it. Assuming you've correctly installed GDK then it should work without any further changes and just include the foliage library project into your other project and setup the include path and it should work fine.

jasonhtml
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: OC, California, USA
Posted: 18th Jul 2009 08:02
forgot to post here. intended to once i got it working 100% correctly. thanks to dark coder's help, my game now looks quite beautiful.

thm120
15
Years of Service
User Offline
Joined: 28th Dec 2008
Location:
Posted: 27th Jul 2009 22:30
Dam y is everything awesome something u gotta pay for? cant wait till i get a job/old enough for a job
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 27th Jul 2009 22:45
@ Dark Coder (or someone assisting DC who is familiar with making DBPro dlls),

I beg thee - please release a DBPro plugin version....

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Mista Wilson
15
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 28th Jul 2009 05:39
@thm120 -

Quote: "Dam y is everything awesome something u gotta pay for? cant wait till i get a job/old enough for a job "


incase you have misunderstood, dark coder has made this foliage library available to us for free, it has a license agreement, but it is quite a lenient one imo - and trust me when I tell you that this lib is very nearly of saleable quality, plus it comes as source code, so if something doesnt look the way you want or act the way you want, you can simply change it

If it ain't broke.... DONT FIX IT !!!
thm120
15
Years of Service
User Offline
Joined: 28th Dec 2008
Location:
Posted: 29th Jul 2009 05:04
awesome.. when i see "demo" i immediately think PAY
thm120
15
Years of Service
User Offline
Joined: 28th Dec 2008
Location:
Posted: 31st Jul 2009 22:36 Edited at: 31st Jul 2009 22:44
this program is AWESOME!! i cant figure out how to set a default number of objects that are loaded on startup ( i dont want the user to have a choice)
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 1st Aug 2009 08:06
Quote: "i cant figure out how to set a default number of objects that are loaded on startup ( i dont want the user to have a choice) "


What do you mean? If you want your map to be populated with foliage to begin with then just copy the code that's run when you press any of the buttons to spawn things and place it before the main loop.

Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 2nd Aug 2009 12:17
@ dark coder - any chance of implimentation of this as a DBPro dll?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 2nd Aug 2009 12:44
Quote: "@ dark coder - any chance of implimentation of this as a DBPro dll?"


No. I have no experience with making DBPro DLLs anyway.

Login to post a reply

Server time is: 2024-04-25 13:24:19
Your offset time is: 2024-04-25 13:24:19