Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (563)
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  
  [SOLVED] General OpenGL question - Mipmap level decided on only one axis  (Read 4198 times)
0 Members and 1 Guest are viewing this topic.
Offline Mike

JGO Wizard


Medals: 82
Projects: 1
Exp: 6 years


Java guru wanabee


« Posted 2009-05-28 18:50:57 »

All,

I have an annoying problem. I am mipmapping my road texture and it works fine when you look straight at it. However, when you make either the X or the Y axis really small compared to the other axis by looking at it in a slope (see attached picture) it takes the mip map of the lower quality and applies it instead of using the higher quality one.

Any good way to solve it? What I'd expect is that seeing as, for example, the X axis needs the higher quality texture it'd use the higher quality one instead of using the Y axis lower quality one (seeing as the Y axis is squeezed together).

Any solution to this? It doesn't matter if I generate my own mip maps or use the opengl generatemipmap function, both give the same problem.

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline lhkbob

JGO Knight


Medals: 32



« Reply #1 - Posted 2009-05-28 22:28:14 »

If I'm not mistaken, the solution to your problem would be to use anisotropic filtering.  OpenGL supports this through an extension but it's pretty easy to use.  I'd post an example, but I'm at work  persecutioncomplex

Offline DzzD
« Reply #2 - Posted 2009-05-28 22:43:42 »

All,

I have an annoying problem. I am mipmapping my road texture and it works fine when you look straight at it. However, when you make either the X or the Y axis really small compared to the other axis by looking at it in a slope (see attached picture) it takes the mip map of the lower quality and applies it instead of using the higher quality one.

Any good way to solve it? What I'd expect is that seeing as, for example, the X axis needs the higher quality texture it'd use the higher quality one instead of using the Y axis lower quality one (seeing as the Y axis is squeezed together).

Any solution to this? It doesn't matter if I generate my own mip maps or use the opengl generatemipmap function, both give the same problem.

this is one thing I dislike on hardwae as you are dependant on : GPU / GC drivers / OpenGL and user setting .... and then finally you never know how it will really look like on end users computers...

enabling anisotropic filtering may help if user GC & its custom setting support it, but I guess that trying your demo on another computers or with differents GC and/or drivers (wich may use different mipmap algos) may be another solution too  Undecided

EDIT : you should be able to force anysitropic in your GC panel setting to test


can you put it online ?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2009-05-28 23:41:06 »

Another option, if you're only concerned with the blurryness is to mess with <a href="http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_lod_bias.txt">texture lod bias</a>, which you can set to bias against choosing the lowest mip levels except under extreme angles (at the tradeoff of a certain amount of temporal aliasing).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Mike

JGO Wizard


Medals: 82
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #4 - Posted 2009-05-29 06:23:58 »

Thanks for all the tips. It's online at dreamlandz.com (just fill in something random as username and password). It isn't the newest version but it has this issue present.

I'll look into the different advices when I'm at work Smiley

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #5 - Posted 2009-05-29 07:08:23 »

as the road looks sort of pixelly, i was curious as to what minFilter, and magFilter you are actually using?

I use:
1  
2  
3  
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);


and iv never had results that ugly.

Also the road pixel size looks different to the grass pixel size, are they handled differently, as its only the road that is returning the bad results.


My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline Mike

JGO Wizard


Medals: 82
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #6 - Posted 2009-05-29 09:43:12 »

as the road looks sort of pixelly, i was curious as to what minFilter, and magFilter you are actually using?

I use:
1  
2  
3  
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);


and iv never had results that ugly.

Also the road pixel size looks different to the grass pixel size, are they handled differently, as its only the road that is returning the bad results.



I use the same min/mag filter as you. I don't use the texture_env though but I don't see any difference when I do and when I don't.

The reason why they are pixly is because I use Alpha_test and they are as big as the grass tiles but part is transparent.

The reason why the grass looks better is because it doesn't use Alpha_test and covers the whole tile.

I could use blending instead which would look nicer but then I'd have to sort everything when I draw it which isn't something I'd like seeing as the camera can rotate and the landscape isn't static.

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline ryanm

Senior Member


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #7 - Posted 2009-05-29 10:26:56 »

Or you could use polygon offset to ensure that the roads are in front of the grass.
Offline Mike

JGO Wizard


Medals: 82
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #8 - Posted 2009-05-29 11:10:50 »

Or you could use polygon offset to ensure that the roads are in front of the grass.

I already do, it is always in front, it doesn't have to do with them sharing the same Z value.

Another option, if you're only concerned with the blurryness is to mess with <a href="http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_lod_bias.txt">texture lod bias</a>, which you can set to bias against choosing the lowest mip levels except under extreme angles (at the tradeoff of a certain amount of temporal aliasing).

That didn't work, it still takes the wrong mipmap. I could make everything really blurry though, was a fun setting Smiley

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline Mike

JGO Wizard


Medals: 82
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #9 - Posted 2009-05-29 11:29:48 »

It didn't take any FPS and it looks great with:


1  
2  
3  
4  
5  
6  
          if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic){
             final FloatBuffer MaxA=FloatBuffer.allocate(16);
             MaxA.rewind();
             GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, MaxA);
             GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, MaxA.get(0));
          }


It is missing a vertical line of pixels here and there but it looks 100 times better than before without me having to use blending or making any big change Smiley

Thanks guys!

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mike

JGO Wizard


Medals: 82
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #10 - Posted 2009-05-31 14:25:28 »

And as a final post I've attached a picture of how it looks now instead (I also fixed the pixly roads making it look alot better imo).

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
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.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (30 views)
2014-09-21 02:42:18

BurntPizza (20 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (28 views)
2014-09-20 20:14:06

BurntPizza (32 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
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!