Low FPS on small FoV

I have a 100x100 grid. When I set camera FoV 60f (and all grid fits in viewport) it shows good fps (60+), but when FoV is 1-2 (from big distance) viewport displays only a part of all grid, but: fps is very low, 3-8. Why? jME must hide all spartials that does not render in viewport.

A test case would help… that could be anything.
JME performs frustum culling if that’s what you ask…

Interesting thing: fps starts to grow up when I move camera location closer to grid. The most low fps is directly on the center of grid. And it isn’t just low/good fps switch, it works smooth. Something like jME renders all this triangles out of viewport, but… with wide field of view more mesh details are rendering. Examples with FPS:

The mesh will either be rendered or it wont. It wont be partially rendered. Splitting the mesh solves this. Is this your issue?

1 Like

How is this grid done? Again it could help that you post your code. Else we can talk for hours not getting anywhere.

2 ways:
Geometry g = new Geometry(“wireframe grid”, new Grid(100, 100, 0.5f) );
and a lot of geometries with 1x1 quads.
Result is unchanged. Small FoV - small fps.

But on Windows I have 1800 fps on parallel projection mode and 800 on perspective.

As @nehon said write a single class test which reproduces your issue, imho the most efficient way, every thing else is just guessing around.

public class Main extends SimpleApplication {

public void simpleInitApp() {
    // TODO: uncomment case methods

    case1(); //most part of grid, 60+ fps
    //case2(); //small part of grid, parallel projection, 11 fps
    //case3(); //part, 22 fps
    attachGrid(Vector3f.ZERO, 100, ColorRGBA.Orange);
}

private void case1(){
    cam.setLocation(new Vector3f(20,20,0));
    cam.setFrustumPerspective(90f, (float)settings.getWidth()/settings.getHeight(), 1f, 1000f);
    cam.lookAt(new Vector3f(-0.54604214f, -0.8377432f, 0.0049444437f), cam.getUp());
}
private void case3(){
    cam.setFrustumPerspective(5f, (float)settings.getWidth()/settings.getHeight(), 1f, 1000f);
    cam.lookAt(new Vector3f(0,0,0), cam.getUp());
    cam.setLocation(new Vector3f(20f,10f,0));
    cam.lookAt(new Vector3f(19.703892f, 9.083364f, -0.2685094f), Vector3f.UNIT_Y);
}

private void case2() {
    cam.setParallelProjection(true);
    float aspect = (float) settings.getWidth() / settings.getHeight();
    float size = 1f;
    cam.setFrustum(1f, 1000, -aspect * size, aspect * size, size, -size);
    cam.setLocation(new Vector3f(0, 100, 0));
    cam.lookAt(new Vector3f(0.01506114f, -0.9997905f, 0.0138604045f), cam.getUp());
}

private Geometry attachGrid(Vector3f pos, int size, ColorRGBA color){
    Geometry g = new Geometry("wireframe grid", new Grid(size, size, 0.5f) );
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.getAdditionalRenderState().setWireframe(true);
    mat.setColor("Color", color);
    g.setMaterial(mat);
    g.center().move(pos);
    rootNode.attachChild(g);
    return g;
}

}

So, from my tests: jME has lowest fps when draws lines closer to 45 degrees. Sounds stupid, but it’s true. When I use whatever camera FoV and I look on big grid from the side (90 deg) I have 3-5 times more fps, than I look on it from the corner (45 deg). And after that, reading jME wiki “Generally jME3 is well optimized” sounds strange. Or it is just android opengl problem.

In the end… JME is not drawing those lines. It’s just sending the mesh to the GPU.

Btw. I think I had also some iuess with big grides with in the sim-eth-es example (I did also one big flat grid by my self) and if it is big (I don’t remember correctly maybe it was 100x100) it did a performance drop, but not that drasticall like the OP states.

But my MacBook Pro has anyway a lame grafic card :wink:

I’ve tested one grid and a lot of small quads. Android OpenGL performance sucks. And this is not a slow device. Samsung S7 edge.

Note that consumer GPUs are designed to display triangles, not lines. Expect to see performance loss when rendering lines. Nothing jME can do about it. Sad but true: the best way to draw lines is not with lines, but with triangles

Ok, I did same with a lot of textured cubes, but only few was on screen. And… openGL sucks, again :slight_smile:

Well not really. There are tricks and rules like @Momoko_Fan said. Another is that GPUs prefer floats over ints. The same can be said for mobile development. Its not the same as desktop - there are a lot of quite strict rules you should be abiding by and learning along the way. I have no doubt it is a frustrating and slow process.