Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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 3743 times)
0 Members and 1 Guest are viewing this topic.
Offline Mickelukas

JGO Ninja


Medals: 39
Projects: 2


Java guru wanabee


« Posted 2009-05-28 20: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.

Offline lhkbob

JGO Knight


Medals: 32



« Reply #1 - Posted 2009-05-29 00: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-29 00: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: 48
Projects: 11


Monkey for a head


« Reply #3 - Posted 2009-05-29 01: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 Mickelukas

JGO Ninja


Medals: 39
Projects: 2


Java guru wanabee


« Reply #4 - Posted 2009-05-29 08: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

Offline bobjob

JGO Knight


Medals: 10
Projects: 6


David Aaron Muhar


« Reply #5 - Posted 2009-05-29 09: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 Mickelukas

JGO Ninja


Medals: 39
Projects: 2


Java guru wanabee


« Reply #6 - Posted 2009-05-29 11: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.

Offline ryanm
« League of Dukes »

Senior Member


Projects: 1


Used to be bleb


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

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

JGO Ninja


Medals: 39
Projects: 2


Java guru wanabee


« Reply #8 - Posted 2009-05-29 13: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

Offline Mickelukas

JGO Ninja


Medals: 39
Projects: 2


Java guru wanabee


« Reply #9 - Posted 2009-05-29 13: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!

Games published by our own members! Check 'em out!
Try the Free Demo of Droid Assault
Offline Mickelukas

JGO Ninja


Medals: 39
Projects: 2


Java guru wanabee


« Reply #10 - Posted 2009-05-31 16: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).

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (76 views)
2013-05-17 21:29:12

alaslipknot (89 views)
2013-05-16 21:24:48

gouessej (119 views)
2013-05-16 00:53:38

gouessej (113 views)
2013-05-16 00:17:58

theagentd (125 views)
2013-05-15 15:01:13

theagentd (112 views)
2013-05-15 15:00:54

StreetDoggy (156 views)
2013-05-14 15:56:26

kutucuk (178 views)
2013-05-12 17:10:36

kutucuk (178 views)
2013-05-12 15:36:09

UnluckyDevil (186 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.132 seconds with 21 queries.