[LibGDX] Textures and Zoom Out

Hi, guys!

I’m using LibGDX to render my game and at some point I call the following code to render:


render(){

        Gdx.gl.glClearColor(0, 0.1f, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
         
        camera.update();
        mapRenderer.setView(camera);
        mapRenderer.render();
        
        batch.setProjectionMatrix(camera.combined);
        
        batch.begin();

            for(GameObject o : tiledWorld.objects){                
                o.getGraphics().render(o, batch);
            }    
        
        batch.end();
        
        stageGame.act();
        stageGame.draw();
}

The render(o, batch) just renders TextureRegions from the GraphicComponent. I’m getting my textures from there.

When the camera zoom out, it seems very pixelated. I tried different setFilter() options (TextureFilter.Linear/TextureFilter.Nearest), as you can see in that follow image:

I would like that textures look like when I have the 12.5% zoom out in the Paint (as in the example, it’s much better).
If you zoom in, it’s possible to see that there are differences between the different combinations at setFilter(). It seems to me that Linear/Nearest is the best, but it is far from the best result like in Paint.

Someone could help or have any ideas?

Have you tried enabling mipmap generation upon texture load and then using one of the the mipmap filter options?

It could also be possible that paint does the filtering in software, so you can’t just use one of the default filters (nearest/linear/mipmap) to get the same effect.

A last ditch effort would be to generate scaled down versions offline and load them as mipmaps or just load them as normal textures and do the swapping yourself depending on the zoom level.

I was thinking that mipmap only works when you already have the images scaled (I’m new at openGL, sorry). I will try that later.

Thanks!

Hi VaTTeRGeR,

I enabled mipmap generation and now it works perfect! Actually, is better than Paint using MipMap/MipMapLinearNearest.

Thank you very much!