Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (489)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (555)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Libgdx - What Graphic Settings can i expose?  (Read 1123 times)
0 Members and 1 Guest are viewing this topic.
Offline Andre Lopes
« Posted 2014-01-19 17:25:45 »

Hello guys!
I have a question that i've been researching in google and in the openGl superbible.

I want to know, what kind of Filters and options i can make in code, to make it faster/bad graphic quality and slower?/Better Graphic Quality

1  
2  
3  
4  
5  
6  
 
TmxMapLoader.Parameters params = new TmxMapLoader.Parameters();
        params.textureMagFilter = Texture.TextureFilter.Nearest;
        params.textureMinFilter = Texture.TextureFilter.Nearest;

        map = new TmxMapLoader().load("levels/One/LevelOne.tmx", params);


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
  public ArcherMovement() {

        TextureAtlas atlas = AssetAccessor.getInstance().manager.get("packed/archerresources.atlas", TextureAtlas.class);

        //Walk Left
       walkingLeft = new Sprite[4];
        walkingLeft[0] = atlas.createSprite("archer/archer_walking_left", 1);
        walkingLeft[1] = atlas.createSprite("archer/archer_walking_left", 2);
        walkingLeft[2] = atlas.createSprite("archer/archer_walking_left", 3);
        walkingLeft[3] = atlas.createSprite("archer/archer_walking_left", 4);

        walkLeft = new Animation(0.20f, walkingLeft);

        //Walk Right
       walkingRight = new Sprite[4];

        walkingRight[0] = atlas.createSprite("archer/archer_walking_right", 1);
        walkingRight[1] = atlas.createSprite("archer/archer_walking_right", 2);
        walkingRight[2] = atlas.createSprite("archer/archer_walking_right", 3);
        walkingRight[3] = atlas.createSprite("archer/archer_walking_right", 4);

        walkRight = new Animation(0.20f, walkingRight);

        //Standing
       standing = new Sprite[3];
        standing[0] = atlas.createSprite("archer/archer_standing", 1);
        standing[1] = atlas.createSprite("archer/archer_standing", 2);
        standing[2] = atlas.createSprite("archer/archer_standing", 3);

        stand = new Animation(0.28f, standing);

        //Dead
       dying = new Sprite[2];
        dying[0] = atlas.createSprite("archer/archer_dying", 1);
        dying[1] = atlas.createSprite("archer/archer_dying", 2);

        dead = new Animation(0.28f, dying);

        winning = new Sprite[1];
        winning[0] = atlas.createSprite("archer_hooray");

        win = new Animation(0.30f, winning);



I know that,
"GL_LINEAR smooths those out, GL_NEAREST presents them in their full glory. "

I know also about mipMapping but i dont know how to generate them or if they must be pre-gen.

This is a new Area for me , so any tip is totally appreciated. Smiley
Offline Andre Lopes
« Reply #1 - Posted 2014-01-20 18:54:38 »

Quote
Filter Combination (MAG_FILTER/MIN_FILTER)   Bilinear Filtering (Near)   Bilinear Filtering (Far)   Mipmapping

GL_NEAREST / GL_NEAREST_MIPMAP_NEAREST   Off   Off   Standard
GL_NEAREST / GL_LINEAR_MIPMAP_NEAREST   Off   On   Standard
GL_NEAREST / GL_NEAREST_MIPMAP_LINEAR   Off   Off   Use trilinear filtering
GL_NEAREST / GL_LINEAR_MIPMAP_LINEAR   Off   On   Use trilinear filtering
GL_NEAREST / GL_NEAREST                           Off   Off   None
GL_NEAREST / GL_LINEAR                           Off   On   None
GL_LINEAR / GL_NEAREST_MIPMAP_NEAREST   On   Off   Standard
GL_LINEAR / GL_LINEAR_MIPMAP_NEAREST   On   On   Standard
GL_LINEAR / GL_NEAREST_MIPMAP_LINEAR   On   Off   Use trilinear filtering
GL_LINEAR / GL_LINEAR_MIPMAP_LINEAR           On   On   Use trilinear filtering
GL_LINEAR / GL_NEAREST                           On   Off   None
GL_LINEAR / GL_LINEAR                                   On    On   None


Also this: Wrapping?


Quote
GL_CLAMP_TO_EDGE: The coordinate will simply be clamped between 0 and 1.
GL_CLAMP_TO_BORDER: The coordinates that fall outside the range will be given a specified border color.
GL_REPEAT: The integer part of the coordinate will be ignored and a repeating pattern is formed.
GL_MIRRORED_REPEAT: The texture will also be repeated, but it will be mirrored when the integer part of the coordinate is odd.



And This :

Quote
Filtering
Since texture coordinates are resolution independent, they won't always match a pixel exactly. This happens when a texture image is stretched beyond its original size or when it's sized down. OpenGL offers various methods to decide on the sampled color when this happens. This process is called filtering and the following methods are available:

GL_NEAREST: Returns the pixel that is closest to the coordinates.
GL_LINEAR: Returns the weighted average of the 4 pixels surrounding the given coordinates.
GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR: Sample from mipmaps instead.



So, theres two things,

Filter Combinations / Filtering
Wrapping


In Filters, i can do like this :
Best : Linear/Linear
Worst :Nearest/Nearest


For Wrapping....
I have no idea.

.

So i guess i will work with filters now,
1  
walkingRight[i].getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);


Something like that.

And for the wrapping, idk.


Offline Andre Lopes
« Reply #2 - Posted 2014-01-20 19:53:56 »

I think this website have the correct order :
From worst to better.


For Mag_Filter :

GL_TEXTURE_MAG_FILTER:
GL_NEAREST
GL_LINEAR

///////////////////////////////////
///////////////////////////////////

For Min_Filter :

GL_TEXTURE_MIN_FILTER

GL_NEAREST
GL_LINEAR
GL_NEAREST_MIPMAP_NEAREST
GL_NEAREST_MIPMAP_LINEAR
GL_LINEAR_MIPMAP_NEAREST
GL_LINEAR_MIPMAP_LINEAR

Nearest (worst) -> GL_LINEAR_MIPMAP_LINEAR (Better)
?



Can Anyone confirm this for me?

http://www.felixgers.de/teaching/jogl/textureFiltering.html
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #3 - Posted 2014-01-20 20:02:21 »

Why don't you just research it. There are so many resources out there that will tell you exactly what you want to know.

Offline Andre Lopes
« Reply #4 - Posted 2014-01-20 20:21:58 »

Why don't you just research it. There are so many resources out there that will tell you exactly what you want to know.

WTF
What you think that im doing ? Im researching all over but my knowledge of openGl is new, so im trying to find out.

Why do you think im posting all this? To help others newbies in openGl.

Instead,once again, you come here comment that.

If you want to help, either post a link or say something constructive you freaking troll.

"Age:   16"

There you go.


Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #5 - Posted 2014-01-20 20:29:35 »

So how about you test it out in one of your programs and see for yourself instead of creating yet another topic about something that is easily found on the internet? You have all the different types of texture filtering right there, why not be proactive and test them out?

Offline Andre Lopes
« Reply #6 - Posted 2014-01-20 20:33:58 »

So how about you test it out in one of your programs and see for yourself instead of creating yet another topic about something that is easily found on the internet? You have all the different types of texture filtering right there, why not be proactive and test them out?

Firstly, I have sought a solution already and was hoping to find somebody with experience that might be able to put me on the right track.  Secondly, my question and its hopeful solution on this board may help others in the future.  Thirdly, your responses are still of little value to me.  If you can help, I will be appreciative.  If you cannot, then my appreciation will be there if you stop replying please

"...another topic about something that is easily found on the internet..."

If its so easily, then why dont you post the link?
Since you didnt, its clearly that you are here only to troll.
Grow up.


Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #7 - Posted 2014-01-20 20:36:33 »

I don't post anything about it because you need to learn to be a problem solver. Maybe its not my place to teach you, but if you ever want to make it as a programmer then you need to be able to solve issues like this by yourself.

Calling me a troll is immature when I am only trying to help you.

Offline Andre Lopes
« Reply #8 - Posted 2014-01-20 21:35:17 »

Maybe its not my place to teach you, but if you ever want to make it as a programmer then you need to be able to solve issues like this by yourself.

Its not an issue, its a problem to search a certain topic in a certain book , in a big library called internet, and you cant find it
Offline mrboj

Innocent Bystander





« Reply #9 - Posted 2014-01-20 22:24:12 »

I would also like to know the answer to this question.

Opiop, I thought you were supposed to be over 13 to use this forum?

Give this guy a break, isn't this forum wonderful for asking for help?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #10 - Posted 2014-01-20 22:27:50 »

I would also like to know the answer to this question.

Opiop, I thought you were supposed to be over 13 to use this forum?

Give this guy a break, isn't this forum wonderful for asking for help?
I respect skill, not age Tongue (I was 12 when I joined)

And yes.
Offline StumpyStrust
« Reply #11 - Posted 2014-01-21 01:23:35 »

nearest then linear. With min/mag options that is what type of filtering to use when reducing a texture are stretching a texture.

Mag is magnification filtering and min is the opposite. For some games you will not see textures up close so you can use a faster min filter.

Usually though, all graphics cards can do trilinear with ease.

The main options that speed things up or slow things down are polygon count, texture size, and shaders. Really shaders are the biggest thing as you completely control them. Of course there are logically things like physics and AI but they are not something that can be changed without effecting the game.

EDIT: Oh yeah resolution can greatly effect speed due to fill rate limits.

Offline Andre Lopes
« Reply #12 - Posted 2014-01-21 01:59:37 »

nearest then linear. With min/mag options that is what type of filtering to use when reducing a texture are stretching a texture.

Mag is magnification filtering and min is the opposite. For some games you will not see textures up close so you can use a faster min filter.

Usually though, all graphics cards can do trilinear with ease.

The main options that speed things up or slow things down are polygon count, texture size, and shaders. Really shaders are the biggest thing as you completely control them. Of course there are logically things like physics and AI but they are not something that can be changed without effecting the game.

EDIT: Oh yeah resolution can greatly effect speed due to fill rate limits.


I see, its because im making a graphic quality settings so the user can select.
Offline davedes
« Reply #13 - Posted 2014-01-21 04:01:16 »

You can read about filtering and wrapping here:
https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Textures

Mipmapping is a little different. It basically exists to make textures look smoother when they are rendered really small. Here's some brief info:

  • It's only used on minification (making something smaller). And it's only really useful if you plan to significantly scale down your textures -- e.g. for distant objects in 3D games, or in a 2D game with, say, a very high zoom level.
  • When mipmaps are generated (LibGDX has a boolean in Texture constructor for this), the GL Texture will be associated with a "mipmap chain." This is just a series of images, each one halved from the last -- e.g. 128x128, then 64x64, then 32x32, etc. Example here.
  • This increases texture memory by 33%, which isn't too much. But no point in using mipmaps if you don't need to down-scale your image.
  • Often the driver uses a higher-quality filtering than bilinear, e.g. like bicubic instead. This is more expensive, but since you generally only do it once (when you create the texture), it's no big deal.
  • In the vast majority of applications, the choice of filtering or wrap modes will have zero impact on performance, so it should be a non-issue. There are some rare exceptions -- like on Android with large images -- that you might want to be weary of.
To describe the basic difference between the different mipmap parameters, first you need to know "nearest" vs. "linear." NEAREST picks the single closest sample -- so if you were to plot somewhere "in between" pixel A and B, it would choose whichever is closest to your given value. Whereas LINEAR will blend the two pixels using a weighted average, aka linear interpolation. It's technically "bilinear interpolation" since we are interpolating in both directions (X and Y, or more specifically, the S and T tangents), leading to a weighted average of the four nearest colors.

The GL_*_MIPMAP_* parameters first describes the filtering between mipmap levels, and then the filtering on that particular mipmap texture.

GL_NEAREST_MIPMAP_LINEAR will use nearest-neighbour filtering to sample one mipmap, determined by the size at which you're drawing your texture. Then it will use linear filtering between the samples from that mipmap texture. Whereas GL_NEAREST_MIPMAP_NEAREST will sample from a single mipmap level, and then sample a single pixel.

GL_LINEAR_MIPMAP_LINEAR on the other hand, will blend with a weighted average between the two closest mipmap levels, and then blend again the nearest sampled pixels from the resulting image. This is also known as trilinear filtering, and it leads to the smoothest result. (At the expense of performance, on low-end devices.)

Likewise, GL_LINEAR_MIPMAP_NEAREST first blends between two mipmap levels -- but then samples from the result using nearest-neighbour sampling.

Offline Andre Lopes
« Reply #14 - Posted 2014-01-22 12:20:32 »

I came up with this :

            Mag ||  Min

Low      Nearest,Nearest
Medium Nearest,Linear
High     Linear,Linear
Highest Linear,GL_Linear_MIPMAP_LINEAR


What you guys think?

Im also reading about AA in libgdx so yeah Smiley
Offline theagentd
« Reply #15 - Posted 2014-01-22 13:32:29 »

I can't speak for mobile, but on PC the filtering cost of all those is almost exactly the same thanks to dedicated hardware. Trilinear filtering (4 taps each from 2 layers = 8 taps) is used for every single texture in 3D game, so it's obviously been a priority to optimize this. If you look at older specifications for ATI cards they brag about doing 128 tap filtering, which would be 16x anisotropic filtering samples, where each (trilinear) sample requires 8 reads. You'll have to search hard for a game that doesn't default to GL_LINEAR_MIPMAP_LINEAR today.

Mipmaps can actually improve performance as well. A smaller texture fits better in the texture cache, so if you render a huge 1024x1024 texture to a 16x16 pixel quad, you're sampling very sparse points in the texture so they'll all be cache misses, while with mipmaps the texture units would just cache the whole 16x16 mipmap level on the first read and the rest would be covered by the cache. There's really no point in disabling mipmaps at all.

If you really want to, you could add an option for switching between GL_LINEAR_MIPMAP_NEAREST and GL_LINEAR_MIPMAP_LINEAR, AKA bilinear filtering (4 taps) and trilinear filtering (8 taps). The last time I saw such a setting was in Half Life 2, 9 years ago...

Myomyomyo.
Offline Andre Lopes
« Reply #16 - Posted 2014-01-22 14:57:16 »

Its because its also going to run in Android.
So im just being cautious.

But ok!

Offline theagentd
« Reply #17 - Posted 2014-01-22 21:21:36 »

Okay, in that case having a setting for switching between bilinear and trilinear filtering might be useful. Since mipmaps actually improve performance, using GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR since they both do the same thing except using mipmaps is more cache efficient. GL_LINEAR_MIPMAP_LINEAR may have a noticeable performance cost though.

Myomyomyo.
Offline Andre Lopes
« Reply #18 - Posted 2014-01-22 22:34:31 »

Okay, in that case having a setting for switching between bilinear and trilinear filtering might be useful. Since mipmaps actually improve performance, using GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR since they both do the same thing except using mipmaps is more cache efficient. GL_LINEAR_MIPMAP_LINEAR may have a noticeable performance cost though.

GL_LINEAR_MIPMAP_LINEAR is better than GL_LINEAR_MIPMAP_NEAREST which is better and Faster than  GL_LINEAR

Right?


I think i will just put android as :

Linear - GL_LINEAR_MIPMAP_NEAREST

And pc as

Linear - GL_LINEAR_MIPMAP_Linear

What you think?


//Thanks for the replies by the way!!!
I wont forget it Smiley
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (9 views)
2014-08-31 22:59:12

TehJavaDev (22 views)
2014-08-28 18:26:30

CopyableCougar4 (27 views)
2014-08-22 19:31:30

atombrot (40 views)
2014-08-19 09:29:53

Tekkerue (38 views)
2014-08-16 06:45:27

Tekkerue (34 views)
2014-08-16 06:22:17

Tekkerue (24 views)
2014-08-16 06:20:21

Tekkerue (34 views)
2014-08-16 06:12:11

Rayexar (71 views)
2014-08-11 02:49:23

BurntPizza (47 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!