jPCT-AE - a 3d engine for Android > Support
How to improve the performance of SkyBox?
kiffa:
I made a skyBox, which cause a 6-9 fps dropping down。How to improve the performance? Could i use only one world and one-time rendering to make skyBox?
My codes:
--- Code: ---World skyWorld = new world();
/ /sky is an object3D which has a center of (0,0,0);
skyWorld.add(sky).
//set camera to the center of sky.
skyWorld.getCamera().setPosition(0,0,0);
// sceneWorld is the world of scene(the "real" world).
skyWorld.getCamera().setBack(sceneWorld.getCamera().getBack());
// don't write to zBuffer when rendering the sky, to avoid to adjust the size of sky.
sky.setRenderHook(new IRenderHook(){
public void beforeRendering(int paramInt) {
GLES20.glDepthMask(false);
}
public void afterRendering(int paramInt) {
GLES20.glDepthMask(true);
}
});
// onDrawFrame(), rendering sky per frame
framebuffer.clear();
skyWorld.renderScene(framebuffer);
skyWorld.draw(framebuffer);
sceneWorld.renderScene(framebuffer);
sceneWorld.draw(framebuffer);
framebuffer.display();
--- End code ---
kiffa:
I tried to add sky to sceneWorld, but the result seems incorrect:
--- Code: ---sceneWorld.addObject(sky);
sky.setRenderHook(new IRenderHook() {
@Override
public void beforeRendering(int paramInt) {
mBackPos = sceneWorld.getCamera().getPosition();
sceneWorld.getCamera().setPosition(0,0,0);
GLES20.glDepthMask(false);
}
@Override
public void afterRendering(int paramInt) {
GLES20.glDepthMask(true);
sceneWorld.getCamera().setPosition(mBackPos);
}
});
});
--- End code ---
When does jPCT-AE calculate and upload the MVP matrix?
EgonOlsen:
It makes on sense to add the skybox to the main scene/world. It will cause nothing but more complex code and won't improve performance one single bit. If the skybox slows down things, this is either because of the additional fillrate it requires or because of the texture fetches and cache misses in case that the skybox's textures are pretty large. Rendering itself is really cheap.
kiffa:
So, the following 2 codes have the very close performance, right?:
--- Code: ---//code 1
world1.add(obj1);
world2.add(obj2);
renderWorld1();
renderWorld2();
//code 2
world.add(obj1);
world.add(obj2);
renderWorld();
--- End code ---
EgonOlsen:
Yes.
Navigation
[0] Message Index
[#] Next page
Go to full version