tree[d] trees render with low FPS, probably because of code.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Moo
Posts: 30
Joined: Fri Jan 09, 2009 10:07 pm

tree[d] trees render with low FPS, probably because of code.

Post by Moo »

Hello :)
I have recently started to use tree[d], a frecle product for tree generation. (Link). The generator is awesome, gives nice trees and sweet results, with amazing textures. I've seen some irrlicht users recommend it too.

In the generator, the tree is rendered real-time with a high FPS, butin my program, I get a low FPS. This is strange, since the generator uses dynamic lighting and a wind animation on the tree, all rendered real time. Which makes me wonder: what am I doing wrong?

I used the most simple technique provided in the tutorials to load a mesh:

Code: Select all

				ISceneNode* Tree = Device->getSceneManager()->addMeshSceneNode(Device->getSceneManager()->getMesh("Data/Meshes/Tree.b3d"));
				Tree->setMaterialFlag(EMF_LIGHTING, false);
				Tree->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
(Doh, after thinking about it a little, I figured that the generator didn't use a loaded exported mesh, but real-time calculations. In any case, I still need to higher the FPS of the given tree). Does anyone have a suggestion on FPS efficiency? The tree is the default tree[d] one, if you want to try loading it.

Thanks :roll:
rogerborg wrote:Answering a noob question is like having sex with a midget: there's a wonderfully satisfying sensation of being a giant.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

What version of Irrlicht, how many trees did you load, how many polygons does it use and how low is your FPS? You might want to try TRANSPARENT_ALPHA_CHANNEL_REF, which actually doesn't do any blending and should improve frame rate if it's a problem with doing too much filling.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Moo
Posts: 30
Joined: Fri Jan 09, 2009 10:07 pm

Post by Moo »

Irrlicht v1.5
1, but the more I load, the lower it gets.
12835 triangles
~90 FPS for 1 tree
~25 FPS for 5 trees
rogerborg wrote:Answering a noob question is like having sex with a midget: there's a wonderfully satisfying sensation of being a giant.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Set the _ref renderer and also call ->setHardwareMappingHint(EHMH_STATIC) on each buffer in the meshes. This should improve performance a lot.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Moo
Posts: 30
Joined: Fri Jan 09, 2009 10:07 pm

Post by Moo »

The _REF highers the FPS of 5 trees to about 32 FPS, but removes the whole leaf effect I needed. The other advices didn't change the FPS significantly. But it seems the performance is affected with the mix of terrains and trees. Let me explain:
Trees alone: good FPS.
Trees + 1 terrain: good FPS.
Trees + 9 terrains: ugly FPS (only if trees are in sight).
9 terrains: awesome FPS.
rogerborg wrote:Answering a noob question is like having sex with a midget: there's a wonderfully satisfying sensation of being a giant.
Moo
Posts: 30
Joined: Fri Jan 09, 2009 10:07 pm

Post by Moo »

Here's an attachment with the difference between EMT_TRANSPARENT_ALPHA_CHANNEL_REF and just EMT_TRANSPARENT_ALPHA_CHANNEL.

Image[/img]
rogerborg wrote:Answering a noob question is like having sex with a midget: there's a wonderfully satisfying sensation of being a giant.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Try setting Material.MaterialTypeParam = 0.5 to fix the transparency problem.

Another thing, the meshes may contain lots of mesh buffers, it depends on the layout of the B3D file. If so then a simple mesh format will give you better results, try converting it to OBJ, 3DS or another static mesh format.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Moo
Posts: 30
Joined: Fri Jan 09, 2009 10:07 pm

Post by Moo »

bitplane wrote:Try setting Material.MaterialTypeParam = 0.5 to fix the transparency problem.

Another thing, the meshes may contain lots of mesh buffers, it depends on the layout of the B3D file. If so then a simple mesh format will give you better results, try converting it to OBJ, 3DS or another static mesh format.
Doing the Material.MaterialTypeParam would be painful: I just noticed, when loading the tree in irrEdit, that
1-Even if the tree generator only offered animated formats (b3d and x), it wasn't animated
2-It had about 381 materials, for each leaf and each face of the tree.

This is seriously sad, because this tree generator was incredibly promising (give it a try if you want, it's light). Do you still have suggestions? Thanks a lot for helping me so much so far :)

P.S. I'll try to find a way to convert my .b3d to .obj/.3ds, I'm Googling at the moment, though my internet is incredibly slow today.
rogerborg wrote:Answering a noob question is like having sex with a midget: there's a wonderfully satisfying sensation of being a giant.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Moo wrote:2-It had about 381 materials, for each leaf and each face of the tree.
Yeah there's the problem. I guess the B3D file uses joints for each bunch of leaves, meaning Irrlicht loads it in separate groups so you can move the joints around without deforming them (for things like moving platforms in a world). This is a known bug, you'll have to use another mesh format until it's solved.

Try exporting to X, open in Wings 3D and save as OBJ or 3DS
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Moo
Posts: 30
Joined: Fri Jan 09, 2009 10:07 pm

Post by Moo »

bitplane wrote:
Moo wrote:2-It had about 381 materials, for each leaf and each face of the tree.
Yeah there's the problem. I guess the B3D file uses joints for each bunch of leaves, meaning Irrlicht loads it in separate groups so you can move the joints around without deforming them (for things like moving platforms in a world). This is a known bug, you'll have to use another mesh format until it's solved.

Try exporting to X, open in Wings 3D and save as OBJ or 3DS
I wish I had more 3D technical knowledge to understand or to provide more information, however I'm still a beginner in this domain. Thanks for the suggestion, I'll look through it more when I get home (in about 3 hours). Thanks!
rogerborg wrote:Answering a noob question is like having sex with a midget: there's a wonderfully satisfying sensation of being a giant.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, just tested it my own. The b3d export also does write animations into the file. The bones are moving (check with the meshviewer), but seems to be unconnected with the vertices. Don't know if the file is broken or the Irrlicht loader does not import the animations properly.
The .x file doesn't load, but as it seems the meshviewer from DX SDK does. Going to fix the .x loader then (simply ignoring a missing second ';' in most cases).
Moo
Posts: 30
Joined: Fri Jan 09, 2009 10:07 pm

Post by Moo »

hybrid wrote:Ok, just tested it my own. The b3d export also does write animations into the file. The bones are moving (check with the meshviewer), but seems to be unconnected with the vertices. Don't know if the file is broken or the Irrlicht loader does not import the animations properly.
The .x file doesn't load, but as it seems the meshviewer from DX SDK does. Going to fix the .x loader then (simply ignoring a missing second ';' in most cases).
Thanks for pointing out that the animation worked: I didn't take the time to look through the .obj for frames. However, my DirectX viewer crashes when trying to load the tree in it.

When you say "Going to fix the .x loader then", what do you mean?

Also, is it possible for the default tree - which has more than 10k triangles - to be loaded in Irrlicht as a game element without major performance drops? Or is it simply the .b3d issue mentioned before with joints that causes the drop?
rogerborg wrote:Answering a noob question is like having sex with a midget: there's a wonderfully satisfying sensation of being a giant.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

10k polys won't be very good for in-game usage. But together with VBOs and less meshbuffers it should be possible to add a few instances of those trees to sparsely populated scenery (i.e. don't do too much other stuff). But maybe Klasker's trees will fit better here.
Post Reply