I have background, his size 20000x20000 pxl’s, consisting from 33 random repeat images 1000x1000 pxl’s.
At the beginning I try load images as Texture from files, but my pc freezes. I create json with params, and texture atlas, load as Image and build… it take 3 fps. I change filter from texture pack from Linear to Nearest, but it not take effect. How I can up perfomance? Correctly load background images via scenes.scene2d.ui.Image?
do you render the complete background?
Do you need to draw them all at the same time? If not, loading each of them as seperate texture should solve your problem.
Yes I load background complete, I need to draw them only in my viewport, how I can separate?
Show your code.
Have a look at culling, google it.
You are probably experiencing low FPS because you are rendering a ton of stuff not even visible to the camera. Culling allows you to render things only visible in the viewport.
This is my actor (part/component background), I try optimize with frustum, and take 10fps. I correctly use frustum? In camera i see 4 sprite, where I mistake?
private TextureRegion sprite;
private Stage stage;
public Space(Stage s, MapJsonReader m, Skin skin) {
stage = s;
sprite = skin.getRegion(m.name);
setBounds(
m.x, m.y,
sprite.getRegionWidth(),
sprite.getRegionHeight()
);
setName("space");
stage.addActor(this);
}
@Override
public void draw(SpriteBatch batch, float parentAlpha){
if(stage.getCamera().frustum.boundsInFrustum(new BoundingBox(
new Vector3(getX(), getY(), 0),
new Vector3(getY()+sprite.getRegionWidth(), getY()+sprite.getRegionHeight(), 0)
))){
batch.draw(
sprite,
getX(),
getY()
);
}
}
Resize texture from 1000x1000 to 500x500, I take 60fps, problem solved. See mip mapping http://www.badlogicgames.com/wordpress/?p=1403