texture filtering

I have a single (1024*1024) texture (fbo) I want to display in a orthogonal setup after rotating it a bit in the z and x direction. After which it looks ugly :smiley:

I tried AF, but I didn’t see any difference.
glBindTexture(GL_TEXTURE_2D, fboTex);
glRotatef( 45f,1f,0f,0f);
glRotatef( 20f,0f,0f,1f);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 2.0f);

How do I make the texture look better?

Try trilinear filtering (GL_LINEAR_MIPMAP_LINEAR), don’t forget to build mipmaps first. Also, 2.0 is the minimal value you can specify according to the extension spec, try a higher value.

Will building mipmaps help? It is only one texture rendered on a single quad.
16.0f still looks exactly the same. How do I test if everything is going as expected?

Is it this problem? http://www.r3.nu/~cass/qcoord/

Not as far as I understand it :slight_smile:

Its just that the font(thin lines) rendered on the fbo look really bad AAed after the rotations. It looks nice if it isn’t rotated.

Ok, then anotehr question: what is the size of the rasterized quad? I mean, if you map the texture to a image with a smaller size, say, 500x500 pixels, you can’t expect good filtering quality (this is where the mipmaps kick in – or use a smaller FBO). There is nothign else that comes to my mind right now :slight_smile:

Maybe a screenshot will help?

I map it to a quad of the same size. but the rotations make it a bit smaller in the framebuffer.

glRotatef( 45f,1f,0f,0f);
glRotatef( 20f,0f,0f,1f);
glClearColor(0.33f,0.13f,0.12f,0.0f);
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8.0f);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2d(1f,1f); glVertex3f(1024f ,1024f ,0f);
glTexCoord2d(0f,1f); glVertex3f(0f ,1024f ,0f);
glTexCoord2d(1f,0f); glVertex3f(1024f ,0f ,0f);
glTexCoord2d(0f,0f); glVertex3f(0f ,0f ,0f);
glEnd();

should I use a mipmap for this? (any mipmap setting suggestions)

as others have sad try mipmapping

glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

  • if that doesnt help
    post a screenshot

I’m looking into mipmapping now and here a screenshot :wink:

http://img112.imageshack.us/img112/6488/fontgv1.png
(before and after rotation)

Mipmapping didn’t change anything.
Maybe I got it wrong but if the size of the texture is about the size of the object (in pixels) mipmapping will not be used, or am I wrong here?

Looks like nearest filtering to me?

Did I do anything wrong here?

glGenFramebuffersEXT(1, &fbo);
glGenTextures (1, &tex);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8.0f);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0);
checkFboStatus();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

Or do you maybe know a good test program?

Yes, might be nearest as doing the same rotations on a normal texture to the framebuffer looks way better.

Should I attach anything else than the color to the fbo to make linear filtering work or something?

I don’t think there’s much you can do for such fine line textures.

e.g. suppose you have a black texture with a one pixel vertical white line. If you draw that texture to a viewport of the same size, half a pixel offset in the horizontal direction, you get a 2 pixel-wide gray line. 8 pixel height is also rather low for text don’t you agree?

N.

Except for what I said: Using a normal texture iso the fbo makes the font look a lot better.
So I’m looking into the difference or maybe GL_LINEAR is not supported on fbo’s :stuck_out_tongue:

The texture you created is a normal texture. The fact that you bind it to an FBO doesn’t make it less of a texture. It should behave in the same way as any normal texture as long as you don’t read from and write to it in one pass.

Did you try repeating the

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

calls right before you draw the fbotex to your screen?

N.

I found the problem ! :smiley:

using:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1024, 1024, 0,GL_RGB, GL_INT, NULL);
iso:
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

This makes it look like it should (or how I expected it :)).
But also makes the fbo one big black quad as expected.
thus, the problem lies in displaying/filtering of the rgba fbo texture.

anybody know how to fix it ? :o

I expect it to have something to do with my blending or color management.

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(0.0f);
glColor4f(1.0f,1.0f,1.0f,1.0f);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER,0.1);
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);

I think you would want to enable blending when drawing your text to the fbo and then disable blending when drawing the fbo to the framebuffer, no?

N.

No, if I do that then the fbo will look like one big black quad (with text on it). The background (already on the framebuffer) should be seen through.