PDA

View Full Version : why texture linear filtering doesnt work in 3.1?



crankygoo
01-11-2010, 05:44 AM
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

i have these lines just before glTexImage2D
and textures are filtered the same ugly way like GL_NEAREST do
both under win xp and 7

btw i program an image browser so textures are in fact images, that can be big
like 1920x1200

and performance also sucks.
i tried dx10 it handles hundred thumbnails with ease.
but with opengl i cant scroll the window with thumbs without stuttering.

can anybody help?

ZbuffeR
01-11-2010, 06:03 AM
Typo ? second line should read _MAX_FILTER, right ?

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

LINEAR MIN filter means no mipmaps used, so it will be both slow and ugly when big images will be shown as a small thumbnail.
Try
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); for best quality (trilinear filtering), or GL_LINEAR_MIPMAP_NEAREST if your card is slow.

In either case, do not forget to either provide mipmap levels by hand to GL, or generate them with glGenerateMipmap();

Xmas
01-11-2010, 07:11 AM
It's GL_TEXTURE_MAG_FILTER and glGenerateMipmap, no s.

crankygoo
01-11-2010, 07:40 AM
yes, it was typo.
i think i dont need mipmaps since i need only fixed size thumbnails.

i can render to FBO's texture i guess to make small thumbnail textures.

but again i dont understand:
1. why GL_LINEAR doesnt work. (it's ovbious, GL_NEAREST is applied).
2. why even this errorneous GL_NEAREST appliance is so slow.
(since directx10 with linear filtering works fine even with big images).

and this happens both under win xp & 7.
maybe opengl has some restriction on appying trilinear filtering?

mark ds
01-11-2010, 08:00 AM
Are you using texture rectangles by any chance?

ZbuffeR
01-11-2010, 08:26 AM
i think i dont need mipmaps since i need only fixed size thumbnails.
1920x1200 is quite a thumbnail :) ...

1) Can you post a screenshot ?
You can't see a difference between nearest and linear filtering on a very reduced texture.
2) Both linear and nearest are also very slow in the MIN case, because texture access becomes very hard to cache (the whole 1920x1200 texture is sampled almost randomly). Nearest only have a performance advantage when used on MAG filtering.


maybe opengl has some restriction on appying trilinear filtering?
Say again ? By using MIN: LINEAR, you explicitely disabled trilinear filtering !
To get trilinear, use MIN: LINEAR MIPMAP LINEAR, and glGenerateMipmap(), it will be much better and faster.

crankygoo
01-11-2010, 02:06 PM
ok, you say i'm disabling triliner filtering with glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );?

it's wrong algo for minification?
so why dx10 gives smooth thumbnails with
SamplerState mySampler{
Filter = MIN_MAG_MIP_LINEAR;
};

about screenshots - no sense to upload.

MIN_MAG_MIP_LINEAR in dx10 gives smooth thumbnails
while GL_LINEAR doesnt work.

Alfonse Reinheart
01-11-2010, 02:15 PM
MIN_MAG_MIP_LINEAR in dx10 gives smooth thumbnails
while GL_LINEAR doesnt work.

Did you even read what ZbuffeR said? Setting the min filter to GL_LINEAR is not the same thing as setting MIN_MAG_MIP_LINEAR in D3D. You have to set the min filter to GL_LINEAR_MIPMAP_LINEAR like he said.

ZbuffeR
01-11-2010, 02:44 PM
Yeah thank you Alfonse, I started to feel alone talking to a wall...

For the last time, D3D10_FILTER_MIN_MAG_MIP_LINEAR is equivalent to MIN:GL_LINEAR_MIPMAP_LINEAR+MAG:GL_LINEAR.

crankygoo
01-11-2010, 04:34 PM
ok, understood )
thanx, guys