SpeedTree in Blitz3d

Blitz3D Forums/Blitz3D Programming/SpeedTree in Blitz3d

SabataRH(Posted 2004) [#1]
I've been spending sometime lately working on a tree engine that is very much similar to SpeedTreeRT ($400) http://www.idvinc.com

I'm curious as to how many people would be interested in a BlitzTree engine that would function exactly like SpeedTree?

I've recently started some code and have been able to produce some amazing results. The engine would be a simple include into your programs and called like this:

To reference a tree:
Amodel=LoadBlitzTree("<name>",parm2 ... . ..)

Inside the main loop you would call an update such as:
UpdateTrees()

To add global wind animtion:
TreeAnim(vel%,str%,dir%,global%,area%)

The engine would include:
Occulision
Distance checking
LOD
Portaling
Distance degrade (mesh and texture res)
AutoMipMapping (detail texture res upclose and smudged in the distance)
PreBuilt trees (60)
Proper alpha sorting
Animation controls
just to name a few..

My idea here is to produce an engine that will allow maps to contain litterally hundreds of thousands of trees without a hurt to the overall game speed.. This would be possible by a series of chks and portal of the tree meshes themselves.. Of course theres more to it then that but i won't endulge at this point.

Anyways, early results I've been able to make some nice trees at SUPER-LOW poly counts... check these out -

ss1
ss2

This tree is 312 polys.
No flat planes are visible as the engine uses a unique rotation calcuation to keep the planes lined up to the camera at all times (more powerful upclose and less process-demanding further away). The result is a tree that appears to be very lush and full but contains only a fraction of the poly count one might think.


Before I continue to build this system I wanted to see how the community would respond to such a tool... Im going to produce this code for my next game no matter the response but if enough people show interest I would make it more 'universal' then what I have planned.



BlitzTree3D Features:

** Tested engine code for 3d-tree operations.
** You get all the source code for the tree engine, easily add it to your projects.
** Fast calculations to control 1000's of trees per render.
** Included is 60 pre-made engine trees.
** Included is a convertor utility that allows you to make trees in any modeler and import them in.
** Simple demo code to show you the required steps for putting trees in your game/application.
** Support via Aliencodec's forums.
** Use in any commerical / private project (full version, non-open source)

Engine Specific Features:

** Single-surface operations, all the chunks (leaf) are sorted and take advatnage of quad-mesh design..
** High detail trees using photorealistic skins and design.
** Tree shading controls.
** Tree tinting controls.
** Tree ambience controls.
** Tree animation controls.
** Tree seasonal controls.
** 9 season presets included, change seasons with a simple command - Season=winter, or define your own!
** 3 levels of LOD
** Gridding / portaling engine code.
** The developer has full control over LOD, degradtion, animation and updating functions ..
** Over 6 years of 3d-tree mesh experience! we got it looking like you want it!
** Many many more features not mentioned, download the demo to see all the features!

CDheck out thje website for more info, pics and a demo download. Aliencodec






Kissme(Posted 2004) [#2]
Nice Idea Gardener :)

After Tree Magik, Tree Magik Pro, LEAFmagik ! now Engine ? :) Doh i forget Forest Magik too :-D

Great work Sabata !


"Run Forest Run !"
KissKool


SabataRH(Posted 2004) [#3]
Haha, yah I suppose one might think i have a fixation(sp?) with trees! well not true. Improvements and new advancements I have a fix on. :)


Kissme(Posted 2004) [#4]
Hi Sabata,

I think your idea for the BlitzTree Engine it's not bad. I using your great Tree Tools only :) am not an expert like you for TREES :-D because you are an Little Green Alien !

Kiss ya
Stephanie


*(Posted 2004) [#5]
Looks like Delta Force 1's forests ;)


Sweenie(Posted 2004) [#6]
I have been drooling for SpeedTree a long time now but the price has kept me from bying it.
If you could come up with a similar system for a hopefully lower price then I'm definitely interested.


RetroBooster(Posted 2004) [#7]
Interested.


napole0n(Posted 2004) [#8]
Looks nice. Would it be possible to export trees so you can incorporate them into a lightmap renderer?


Koriolis(Posted 2004) [#9]
Looks very good.
I'm intrigated about the way you rotate the leaves quads.
As a still image it sure looks very good, what would be interesting is to see it moving as the camera goes closer to the tree, and rotates around.
Isn't seing the leaves rotate too weird? Or did you manage to make it unnoticeable?


maximo(Posted 2004) [#10]
You are a hero! Keep this up, it will benifit everyone here if you! I'd be ready to pay for this ;)


maximo(Posted 2004) [#11]
You are a hero! Keep this up, it will benifit everyone here if you finish it I'd be ready to pay for this ;)


Danny(Posted 2004) [#12]
good point gema, if he doesn't finish it, I refuse to pay him a cent!

;-) LOL!

sorry..
(lack of caffein)


SabataRH(Posted 2004) [#13]
Quad rotation is virtually unoticable, if you are directly underneath the tree its more noticable (which is to be expected).. But to be honest, so far it behaves 100% like speedtree's rotation.. If you downloaded any of the speed tree demos or played DAOC then you'll know what to expect..

I'll try and get a small demo up within the next few days..

Sweenie: fraction of the cost of SpeedTree

NapoleOn: Not sure yet... i may include a lightmapping function that would tint terrains beaneth the trees... Or something simular.


Tangent(Posted 2004) [#14]
Daaaamn. I could have used this at work a few months ago when we were making jungles.


maximo(Posted 2004) [#15]
How do you get quads to be dark in some regions and bright in some? Is this automatic ligthing or do you do something to produce this effect? It's a good effect just like in the real tree.


SabataRH(Posted 2004) [#16]
Yah, the shading is randomly generated to help break up the continious patterns.. I'm working on additional means to help remove the tiling effect.


maximo(Posted 2004) [#17]
Keep it up, it's very good work :) I've tested SpeedTree and if you can reproduce this in Blitz, this will elevate Blitz above any other product out there. Great thing you are working on! This will benifit all of us here :) I am ready to pay if it's fast ;)


sec05(Posted 2004) [#18]
nice tree


AbbaRue(Posted 2004) [#19]
I'm still working on my outdoor world and I do need a good tree rendering engine.
My question to you is. Are you writing this tree engine in Blitz3D or in another language?


sswift(Posted 2004) [#20]
"After Tree Magik, Tree Magik Pro, LEAFmagik ! now Engine ? :) Doh i forget Forest Magik too :-D "


Wood you leaf Sabata alone? Stop birching. If he wants to stick to making foliage simulators, I say we should root for him, not peck away at his ego. I know you may pine for him to branch into other areas, but you're barking up the wrong tree.


RetroBooster(Posted 2004) [#21]
1 thing tho sabata, if I where you I'd realy get some better trunk textures... I'd hate if if the 60 provided trees had trunks like this.


maximo(Posted 2004) [#22]
Swift how come you never made any TreeSystemOptimal or something like that ;) You could have made lots of money in this area ;)


sswift(Posted 2004) [#23]
Actually Gema, when I saw that tree engine demo that this is based on, I too considered making such a system. I decided not to though for various reasons. I may reconsider that decision, but probably not in the near future.


maximo(Posted 2004) [#24]
WEll if Sabatas system is good enough and I belive it will be then maybe is no good reason for you to make your own one. But if you see that you could make someting faster and better then there could be. Have you tried SpeedTree demo? It's awsome! There were like tousends of good looking trees everywhere you looked. You could fly up and see the big forest. If you haven't you should check it.

I'm really glad that Sabata is working on this! This will really help people :)


SabataRH(Posted 2004) [#25]
Competition is good!, actually competition is welcomed - it helps each project reach better results.

Those tree-trunk textures are temp. I needed something very low res for testing. The final trees will have detailed trunks.

I know several of you have pointed towards speed of the system, speed is the entire purpose behind this project. I've done some early tests and recived some great responses.. 500 trees in a very small area and my systems never lost a fps.. More remarkably so, one of my test systems is a celron 500mhz with 32/mb v-card.

Worry not with speed! BlitzTree is being based off speed.

But at current I'm having a few probelms but I hope nothing that can't be sorted out today.. Quad rotations can be some tricky stuff..


Panno(Posted 2004) [#26]
interested !!


Koriolis(Posted 2004) [#27]
I didn't say it in my previous post: I might be interested too.


maximo(Posted 2004) [#28]
Sabata will you provide editor to create new trees like in the speed tree? They can create lots of new trees and lots of varitions of the same type of tree. Will you have this in the system as well? I hope so :)


John Blackledge(Posted 2004) [#29]
Definitely interested. It took me ages to model my trees (with a heavy frame loss); yours look better and if they're not too intensive... basically I want forests; I don't think my six trees quite give the same impression :)
Please keep working on this, and keep us informed.


SabataRH(Posted 2004) [#30]
gema, thats a nice idea... I think a simple cad-like tree generator is possible.. Something you can randomly (or not so randomly) put limbs onto a tree and contort the trunks geo. Also a way to place the quad chunks around the tree would be nice.

I think for now I will concentrate on the engine itself and a handful of trees to get started. But I will for sure make some form of tree maker/ediotr to go with the engine.

Btw, Sswift is a genious, quad rotation problems are sorted.. :)


Ross C(Posted 2004) [#31]
Oh well, check your mail anyways. I doubt it will be better than sswifts solution :D


sswift(Posted 2004) [#32]
"Btw, Sswift is a genious"

Genius. :-)


Gabriel(Posted 2004) [#33]
I never make outdoor games, but, daaaamn, those are lovely screenshots. So yeah, even though I don't generally make outdoor games, I'd definitely be interested in a product like this.


maximo(Posted 2004) [#34]
Man you will make so much money from this you could get rich ;) This if anything will work towards expanding the Blitz users base :) If Swift is genius, Sabata is legendary ;)


SabataRH(Posted 2004) [#35]
Doh ... typo's :) GENIUS!

Rich? hmm never thought about that. This app won't cost much though so I doubt 'rich' is in reach. I think SpeedTree at $400 is a bit much.. but hey whatever floats their boat.


maximo(Posted 2004) [#36]
Swift maybe genius but I bet he is thinking now: "damn I could have made that engine in 2 weeks, why didn't I think of this before, it would be nice addition to my systems" ;)


sswift(Posted 2004) [#37]
Sabata:
Speedtree can get away with charging that much because $400 is penauts to a game company!


SabataRH(Posted 2004) [#38]
True true sswift..

Hey guys, sswift's been hard at work optimizing the quad rotation funcs. The results are amazing, heres a test with 10k quads loaded into the scene. Using hi-res 512x512 texture skins... No lod,no trunks, no degration, no clipping added yet and still it cranked out 30fps. A normal forest would be less then 1/4 this amount.. Great things in store!

pic


sswift(Posted 2004) [#39]
If you edit that bmp so that it's a rounded shape instead of the unrealistic square you have now, it'll go even faster. Less overdraw. :-)


SabataRH(Posted 2004) [#40]
Oh yah, all this media was just to get started.. nothing perm. here... The real fun begins now.. Opt'ing the media and the logic routines...


maximo(Posted 2004) [#41]
More screenies thank you :)


SabataRH(Posted 2004) [#42]
Ahhh improvements by the hour.. this system is really starting to shape up.. much to do yet but it's getting there.. heres the latest:

Adaptive-degrading of tree resources.. This shot shows how the trees downgrade in strength based of distance. Mipmapping, texture resoultion, texture bitmode, trunk poly count and rotation factors are things the engine currently downgrades based on distance.
shot 1

This next shot shows un-uniformed generation of the tree reference all done in real time... No 2 trees ever look the same! [well.... in theory :)]
shot 2

This shot shows the trunk detail, geo and skin is altered heavily based, once again, on distance.. Extra detail up close while only a smudge in the distance.
shot 3

More later!


maximo(Posted 2004) [#43]
Exelent! Btw you are not using any shading on the trees now? The leaves are very bright now? Did you turn it off on purpose? I think what adds to realism is the shading you had in the first screenshots ;)


SabataRH(Posted 2004) [#44]
You are correct, theres no vertex tinting in those shots.... I'll put the polish in later.


sswift(Posted 2004) [#45]
I really don't think that accordion music and leiderhosen are really neccessary.


SabataRH(Posted 2004) [#46]
Haha cute sswift..

gema is correct, the vert tinting really gives some depth to the tree, thanks to tranz for pointing out a bug in the vert coloring code.. its now working!

shot1
shot2

It may be a bit aggersive atm, but im adding const's to give the developer complete control over tint strength.


AbbaRue(Posted 2004) [#47]
I am still curious, Sabata.
Did you write this in Blitz3D or another language?
Also, are you going to give us a little demo of a scene with those trees on it so we can see what frame rate we get?


SabataRH(Posted 2004) [#48]
Yes the code is all done in blitz, a simple include file will be distributed with the package..

Demo! of course... as soon as im feeling really good about it i'll toss together a demo.

I've finished animation controls yesterday, they are cool:

;_____________________________________________________________________________________________________________
;--- Animation controls
;------------------------------------
;--- Def: these values control diffrent apsects of animating trees. These values may be changed at anytime to give 
;--- diffrent looks to the animation system.. IE you may want no animation, you may want strong gusty winds.. slight
;--- breeze from the west ... etc..etc...

;---- X-rotation anim (front/back)
CONST TREEAMIN_STR_X#=.05   ;float value / the strength of the animations (0 turns this rotation off)
CONST TREEANIM_MAX_X#=14     ;max distance the anim can reach before retracting

;---- Y-rotation anim (left/front)
CONST TREEAMIN_STR_Y#=.09   ;float value / the strength of the animations (0 turns this rotation off)
CONST TREEANIM_MAX_Y#=2     ;max distance the anim can reach before retracting

;---- Z-rotation anim (left/right)
CONST TREEAMIN_STR_Z#=.03   ;float value / the strength of the animations (0 turns this rotation off)
CONST TREEANIM_MAX_Z#=1     ;max distance the anim can reach before retracting

;---- Animation Randomizer
CONST TREEANIM_RAND=100     ;determines how often the animtion patterns are shifted (lower = often, higher = occasionaly)



These controls have recently been changed to Globals so changing these values in real time is now possible. These controls really give some wonderful sway effects to the trees and make it much more dynamic than static trees.

I'm also looking for new fresh ideas.. anything you guys like to see specific in a tree system? Nows the time to mention it! :)

Things i'm working on or will add before release:

Season tinting: Ability to define Summer, Winter, Autumn, Spring color tinting to the trees.

Weather Look: Summer, Winter, Fall looks. (oh god, i sound like a foley's commerical)

Shadowing: Experimental atm, but loose towel shadows underneath close up trees.. Will work on terrains or mesh.

Preset animtion controls for: Hurricane, storm, light breeze, shifting effects.

24Hour Light Format: A global variabel to control all vertex lighting on the trees. So trees will react to the time of day, 12noon light would be ontop of the trees shinning down etc..


maximo(Posted 2004) [#49]
It looks and it sounds amasing, very good progress so far :) Keep it up Sabata! :)


John Blackledge(Posted 2004) [#50]
Stunning work. Can we make this one of those 'anchored threads' like Tokomak? This work is actually far more important to me than Tokomak! All my stuff is exterior!


SabataRH(Posted 2004) [#51]
Well having a few problems with the lighting .. It's working but not as I want it to. I want to be able to use Dx lighting on the quads but updating the light angles has proven to be quite a challenge.

Anyways, heres a few screens of two trees thats 'almost' lighting correctly.

shot1
shot2


maximo(Posted 2004) [#52]
The second shot is beautiful. Good work Sabata :)


SabataRH(Posted 2004) [#53]
Well it's took awhile and many brains put together... but I think im finally happy with the way the trees are interacting with DX lighting now...
The light dosent flat shade the mesh as dx normally does ... instead it sorta frosts the edges of the mesh (in this case the leaf chunks)..
Need to spend some more time on it and smooth out a few rough edges..

This screenshot is a combo of dx-lighting and vertex tinting, although i think the effect will become more of a 'highlighting' feature and less dx-light based in the near future... Working with single surface trees (or any ss-mesh for that matter) closes the door to effects that are normally 'easy to acheive'..

dxlight_shot


napole0n(Posted 2004) [#54]
Wow, it's really shaping up nicely! Finally the trees are getting a very organic look and feel to them, I found your first shots a bit flat and cold, but these last ones look pretty damn amazing!


maximo(Posted 2004) [#55]
This is looking damn good Sabata!


SabataRH(Posted 2004) [#56]
Hey thanks for the comments, I'm really getting excited about this entire project.. I feel these trees are some of the best I've done in Blitz yet.. if not amongest some of the nicer ones found in most of todays games...

So far i've completed the init's for Summer settings.. I'm going to have 3 settings for fall 1) Early Fall, 2) Fall, 3) Late Fall .. Imagin games that have seasonal changes or diffrent types of regions on diffrent maps.. No need to change out the models, just assign a new seasonal pattern to the engine.


Today I've finished late fall and wanted to show the tree.. Nevermind the unfinished mapping on the trunk. Granted the colors will need some tweaking.. but it'll be just right by the time this project is released.

Late Fall

More later!


maximo(Posted 2004) [#57]
This is getting better and better. One question though, can you produce great looking palms with lots of leafs with the same method? If yes, could you demonstrate plz ;)

Can you produce any kind of tree, or are you limited to some trees?


SabataRH(Posted 2004) [#58]
Haven't done much to the structure tree yet but, I will soon.

There should not be anything to stop palm trees from being created as you can flag which rotations you desire. So palms, with naturally drooping leaves, would be possible.. maybe.

Like I say i've not explored the structure to its fullest yet.. still working on the code sections but it shall not be long.


SabataRH(Posted 2004) [#59]
This will more then likely be the last post i make to this thread - as the coding is near complete. I've still got some effects to add and other minor things but for the most part it is complete. Now time to make trees... lots of trees... :) I'll post later about a release date.

Here's a few screenshots from the last of the season settings I finsihed. Thanks for the support of many!

mid fall
winter 1
winter 2
winALT
spring


koekjesbaby(Posted 2004) [#60]
i really don't want to be picky or anything, but didn't trees lose their leafs in the winter? :)


sswift(Posted 2004) [#61]
Methinks someone lives in a tropical area with trees that never lose their leaves even when snow does fall. :-)


xmlspy(Posted 2004) [#62]
.