Quality issues

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.
dban
Posts: 11
Joined: Tue Dec 18, 2012 12:47 pm

Quality issues

Post by dban »

Hi,

I'm trying to choose a 3D engine for a project and Irrlicht ( version 1.8 ) is one of my options. But I have some problems...

First problem is with the quality of the rendering. I have a simple scene with floor, ceiling and walls and a number of cubes at intersections of lines with x and z multiple of 10 (361 cubes). I'm using Wavefront .obj for the objects. The floor looks fine in blender or if I export it to Collada (.dae) and look at it in Xcode:
Image
But in the application it looks bad. Same with the walls and ceiling. It looks ok near the camera but worse and worse as the distance to camera increases:
Image
I've tried with different lights, without lights, antialiasing, different formats etc., but no improvement. Any idea?

The second one is not necessarily a problem, but a question. With 361 cubes I get 60 frames (vsync). When I increase the number of cubes I get lower frame rates - 40fps for ~700 cubes, 25-30fps for ~1500. I use static mesh for the cube, even though I'm not sure this has any effect for these simple cubes.

Code: Select all

    IMesh *mesh = smgr->getMesh("../../examples/res/cube.obj");
    for (unsigned int i=0; i<mesh->getMeshBufferCount(); i++) {
        mesh->getMeshBuffer(i)->setHardwareMappingHint(EHM_STATIC);
    }
 
For the real project I will have objects with a lot more vertices and the frame rate will be lower...

What can I do? LOD? Occlusion culling? What else?

Another problem is with the FPS camera. If I'm rotating and strafing in the same time, the movement is not so smooth, it's kind of jerky. This can be seen in the Quake3Map sample also.

Thanks & best regards,
Dumi.

P.S. The source code and everything needed is here - http://dako.ro/irrlicht/app.zip.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Quality issues

Post by hendu »

That's called by the technical term "blurred textures at an angle", and you fix it by turning the anisotropic filtering up.

Your fps issue on the other hand is a common beginner thing - you're telling the computer to draw each cube individually. So it's going to be slow.
The keyword to solving that is batching, where you have bigger blocks of cubes instead of single ones.
dban
Posts: 11
Joined: Tue Dec 18, 2012 12:47 pm

Re: Quality issues

Post by dban »

Thanks for pointing me in the right direction.

The first problem was an easy one, just a line of code:

Code: Select all

node->setMaterialFlag(EMF_ANISOTROPIC_FILTER, true);
The second one is not that easy. I tried 2 things for batching, the ones from IrrExt project:
1. CMeshCombiner
  • 60fps for 1500 cubes
  • 15fps for 150 objects with 3000 vertices
  • lost collision based on triangle selectors
2. CBatchingMesh
  • 60fps for 1500 cubes
  • 7fps for 150 objects with 3000 vertices
  • collision is done with the whole mesh, but there is some distance between the objects and I should be able to go between them
Without batching, the results are:
  • 25-30fps for 1500 cubes
  • 20-25fps for 150 objects with 3000 vertices
  • collision works fine
The conclusion is that for my final application I get better results without batching, at least with CMeshCombiner or CBatchingMesh batching. Is there another way of batching? And with collision support?

What I actually want to do is to create a library application (with books). This is made of a big room with floor, ceiling and walls and with ~150 shelves (a shelf has ~3000 vertices). On each shelf there can be 100 books (different objects with low number of vertices). How can this be done in such a way to have acceptable fps and collision support? If batching is not working what else will? Occlusion culling + LOD? Any ideas?

Any help would be appreciated.

Thanks & best regards,
Dumi.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Quality issues

Post by CuteAlien »

Slower speed with batched models is confusing. Maybe not all are visible in that case and so some nodes are not rendered? You can try adding the resulting mesh to an octree-scenenode (ISceneManager::addOctreeSceneNode). Then clipping is happening per polygon which can improve speed for static meshes when they are not always completely inside the visible area.

You probably shouldn't use such hi-polygon models for collision anyway. Rather put an invisible box around them and collide against that.

Also 3000 vertices for a shelf doesn't really sound much like a realtime model, but rather like you use some hi-poly models there. Or maybe it's really huge shelves?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Quality issues

Post by hendu »

3k verts for a bare shelf, not including books? That must be one ornate, well decorated shelf ;)
dban
Posts: 11
Joined: Tue Dec 18, 2012 12:47 pm

Re: Quality issues

Post by dban »

Yeah, this is what I got from the designer :( I've changed it to a 300 verts shelf and I got the following results:

1. CMeshCombiner
  • 60fps for 150 objects with 300 vertices
2. CBatchingMesh
  • 60fps for 150 objects with 300 vertices
3. No batching:
  • 30fps for 150 objects with 300 vertices
So yes, batching did some good in this case. But what will happen when I'll add 100 different objects on each shelf? Initially I was thinking of occlusion culling for the shelves and have the books as children of the shelves. Then, when a shelf would be hidden, all its children would be the same. But is occlusion culling a viable solution in my case?

Also, what about collision? Can I still use triangle selectors with the bounding boxes of the shelves, but without the shelf nodes? Or do I need some invisible nodes?

I know there aren't any off-the-shelf solutions for my application, but there has to be something to start with. At this point I'm trying different things, but they are punctual and I'm not sure in the end I will obtain what I want. It would be nice to have something like - "use batching for the shelves, LOD for books etc."...

Thanks & best regards,
Dumi.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Quality issues

Post by hendu »

Yes, using occlusion culling like that, with books as children, makes perfect sense for your case. But note that batching would prevent you from having per-shelf children - the books would then be children of the batch.

Do tell your designer to trim the polys. Maybe post a pic so we can see how decorated it is?
It would be nice to have something like - "use batching for the shelves, LOD for books etc."...
No such general advice exists. It's always "it depends" here in software world :)

So just do your app without any tricks, and profile where its worst spots are. But start with a better shelf.
dban
Posts: 11
Joined: Tue Dec 18, 2012 12:47 pm

Re: Quality issues

Post by dban »

Do tell your designer to trim the polys. Maybe post a pic so we can see how decorated it is?
Initially the shelf had ~4500 vertices. There were 8 feet each having 174 vertices; so a total of 1392. After removing them I got a little over 3000. The frame of the shelf has 2 poles, each having 1416 vertices (a lot of holes). I replaced them with rectangular cuboids of 8 vertices and this is how I have now ~300 vertices. Still, I think I can lose some more...
dban
Posts: 11
Joined: Tue Dec 18, 2012 12:47 pm

Re: Quality issues

Post by dban »

Strange thing... From what I understood, frustum culling is done automatically with Irrlicht. This was something good, something I needed. But then I started studying how things are actually happening (CSceneManagers' isCulled method) and I realized that culling is done not with the frustum, but with its bounding box. When I added the line below to my cubes/shelves the results improved without batching:

Code: Select all

node->setAutomaticCulling(EAC_FRUSTUM_BOX);
Now I get between 30 and 60 fps with 150 objects (300 vertices), but almost entire time is 60 fps. I get 30 fps only when I'm in the corners of the room and almost all objects are in the frustum.

Dumi.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Quality issues

Post by hendu »

Your measurements aren't useful if you have vsync on (only 30/60fps results). Usually you turn it off for development and benchmarking.
dban
Posts: 11
Joined: Tue Dec 18, 2012 12:47 pm

Re: Quality issues

Post by dban »

I turned on vsync in order to see the average values and I am looking for my application not to go under 60fps.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Quality issues

Post by hendu »

Sure, but being able to differentiate 31fps from 59fps is useful. With vsync on both go to 30.
dban
Posts: 11
Joined: Tue Dec 18, 2012 12:47 pm

Re: Quality issues

Post by dban »

I am not trying to start a debate or to upset anybody. Initially I have chosen Panda 3D for the application and I created the same room with the same shelves. The results were really good; even with the 3000 verts shelves it never got under 30fps and most of the time was at 60fps. Then I added LOD and used the shelves with 300 vertices for far and the ones with 3000 vertices for near. The results were even better. Then I got into a problem (http://www.panda3d.org/forums/viewtopic.php?t=15235) and while looking into how to fix it, it was decided that we need support for mobile.

The natural choice was Irrlicht, since Panda doesn't have official support. And I ported the code to Irrlicht. But the results are not quite good. I'm thinking that both Panda and Irrlicht try to do a lot of optimizations in the "default" mode. Also, what I'm doing seems to translate into the same thing in the end. So why these big differences? Is the format of the objects important (egg vs obj in my case)? What else could it be?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Quality issues

Post by CuteAlien »

Did you try creating it as octreescenenode? It sounds like it might improve a lot in your case.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
dban
Posts: 11
Joined: Tue Dec 18, 2012 12:47 pm

Re: Quality issues

Post by dban »

Actually it's worse. With no batching and octree is worse than just without batching. There must be something I'm doing wrong...
Post Reply