Low fps

The debug apk runs at 20 fps. What are the tricks to optimize performance for android?

  • GeometryBatchFactory.optimize(rootNode) --> this optimizes the whole scene away, only the sky and nifty gui is left :slight_smile:
  • disable logging output --> how to do this?

It may depend on what you do / what you need…

Logging uses the standard java logging, turn it off/down however you like, lots of options.

http://www.vogella.com/articles/Logging/article.html

also , if you use the lighting material a lot it might be useful to set it to vertex lighting. Also using baked lighting for static geometries can help a lot. (ofc if you don’t use dynamic lights)
A single light (except ambient which is almost free) ,few geometries (100 max), not too much animated characters (that generate a lot of garbage collection on android).

1 Like

The framerate stays 30 on a SGS2 and crashes after 1 minute due to GC_CONCURRENT, freezing app, freezing time out -> game over.

How does vertext ligthing work and which decision points should be put into balance?

Instead of calculating the lighting for each pixel in the fragment shader it calculates it for each vertex and then interpolates between it.

This gives you gains for objects with a lot of rendered space and few vertices - although it can also give inferior results.

However it can actually be a loss because there may actually be more vertices in the scene than visible pixels (for complex models etc) so you actually end up calculating lighting for a lot of points that never need it.

It’s one of those ones where you have to try it with your app and see if performance improves and if it looks ok.

1 Like

Can you give me a hint on how to set vertex lighting?

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:materials_overview

I am not sure if I the new values are being applied because the output of the parameter values say “null”:
[java]
for (Spatial subnode : level.getChildren()) {
Geometry geo = (Geometry) subnode;
Material material = geo.getMaterial();
material.setBoolean(“VertexLighting”, true);
material.setBoolean(“UseVertexColor”, true);
material.setBoolean(“LowQuality”, true);
MaterialDef materialDef = material.getMaterialDef();
if (materialDef != null) {
for(MatParam param: materialDef.getMaterialParams()){
System.out.println(param.getName()+": "+param.getValue());
}
}
}
[/java]

You’re looking at params from the material def. those are the params available for this material not the params that are actually set.
trust me material.setBoolean() works and the params are applied.

Ok. thanks.
The new parameters result in about 100 fps extra on my desktop pc which is a 20% gain.