Facing serious Performance Problems

Hello everyone,



I’m currently trying to develop something like Minecraft and Mythruna, just to get into the engine and to test a bit. I thought it may be a good point to start, as it doesn’t need a good physic and only simple Models(Cubes ^^).

So i created a Cube Model with Blender and textured it. I exported it with Ogre and converted it to .j3o. As i tried to add some shadow to my scene i ran into some Problems but with some help of the community(thanks :slight_smile: ) i could solve them.

But now, as I’m adding more cubes to the scene, I’m facing performance problems:



The image, shows a Plane with 50x50 Cubes.



As there exists Mythruna (which works on my pc) i’m sure it should easily be possible to render 2500 Cubes or am I wrong?

I searched in the wiki and the forum for “Performance” and “Optimization”, and tried a lot, like GeometryBatchFactory.optimize() and MipMaps.

But it didn’t really have any effect.

Multithreading I sorted out, cause, as it is described in the Wiki, it seems only to be tought for the simpleUpdate cycle, and as I’am not really doing anything in that it wouldn’t help.

The only thing i do is to attach the cubes to my worldNode and the worldNode to the rootNode.

When i run it with 30x30 cubes it runs smoother but with still less then 30 fps, with 10x10 cubes it runs over 60 fps.

I really tried a while now and i wouldn’t ask you for help if i would know another way out…

So does anyone has some ideas what could cause this, or some solution or improvements, i would be grateful…



If someone needs it, here is some source code too:

[java]

private static GameMap map;

private PssmShadowRenderer pssmRenderer;

private List<MapArea> visibleMapAreas;

private static final int VISUAL_RANGE = 2;

private Node worldNode;



@Override

public void simpleInitApp() {



viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f));

map = new GameMap();

worldNode = new Node(“world”);

visibleMapAreas = map.getVisibleAreas(Vector3f.ZERO, VISUAL_RANGE);

drawWorld();



cam.setLocation(new Vector3f(10, 10, 10));

flyCam.setMoveSpeed(25);

rootNode.attachChild(worldNode);



addLight();

addShadow();

}



private void drawWorld() {

int i = 0;

for (MapArea mapArea : visibleMapAreas) {

worldNode.attachChild(mapArea.getMapAreaNode());

}

}



private void addLight() {

AmbientLight al = new AmbientLight();

al.setColor(ColorRGBA.White.mult(2f));

rootNode.addLight(al);

}



private void addShadow() {

pssmRenderer = new PssmShadowRenderer(assetManager, 256, 4);

pssmRenderer.setDirection(sun.getDirection());

pssmRenderer.setLambda(0.55f);

pssmRenderer.setShadowIntensity(0.6f);

pssmRenderer.setCompareMode(CompareMode.Hardware);

pssmRenderer.setFilterMode(FilterMode.Bilinear);

//pssmRenderer.displayDebug();

viewPort.addProcessor(pssmRenderer);

}



@Override

public void simpleUpdate(float tpf) {

}

[/java]

Explanation:

The Class Map, contains MapAreas and each MapArea has a node with 10x10 Boxes, the VISUAL_RANGE indicates how many MapAreas the Player can see.



When i deactivate the shadow, the frames go up for about 20fps, but a shadow would really be nice. And 22-27fps are still low, or?



With kind regards

Dragonblade05

A box world does not consist of box meshes. Also make sure you read the wiki on how to optimize your scene.

thank you for the quick answer.



Maybe i’m just too stupid, but i don’t really unterstand what you mean with

@normen said:
A box world does not consist of box meshes.


As i searched for "optimize scene" i came across the faq. Where i found this.
As i described above i already tried the GeometryBatchFactory.optimize(), but maybe i made something wrong, so i tried it again and indeed it really gives me a speedup.
The only problem is that it now slows down the start, but thats not really i problem, i may use some loading screen or something.
But the speedup is not really enough, i have now 30fps and when i add some physics its back to 10 fps or so. The werid thing is that when i jump i get a speedup from 20-100 fps, depending on how many blocks are visible.

Theres not a single box mesh in minecraft. Except when you remove all boxes around one single box, then you get a box mesh. Look for “voxel” in the forum to see a rundown on how its done. Basically is a mesh that looks like a surface made out of boxes. Many people successfully implemented this, so its definitely not about the “performance of the engine” here.

2 Likes

And to add a further hint. a) don’t use a box model at all or even jme’s Box mesh. b) you aren’t rendering boxes but the quads between empty and filled cells.

1 Like

Actually you can get quite some good performance when just using the jme box where visible faces are, and batch those. The extra polygons usually only hurt on really old graficcards or if there are several millions. At least it is possible to have a decend visiblerange without any performance issues at all.

1 Like

Yeah, Mythruna tends to have over a million triangles visible and not culling out the invisible faces roughly doubles that on average.



At any rate, creating the quads manually is not that hard… or at least a decent learning experience that will serve well later. Or just use one of the open source JME voxel engines someone else has already put together, I guess.

1 Like

Wow, thanks for the answer, i will start trying immediately. Really, many thanks. :slight_smile: