Sign in to follow this  
TGA

Filtering on FBOs

Recommended Posts

TGA    134
Hi, I've been having trouble getting filtering working correctly when rendering to FBOs. When rendering to the texture the filtering seems to switch to GL_NEAREST mode, whereas I would prefer to have a GL_LINEAR filter. Also, I would quite like my FBO texture to be an alpha mask (GL_ALPHA) rather than an RGBA texture as I only need the alpha, and have issues with card memory, but again, it doesn't seem to like that. Has anybody got any thoughts/solutions to these problems? Could it just be that I'm doing it wrong? I've a feeling these might be unavoidable limitations of FBOs - though I can't find them documented anywhere. Are there any others that I should know about?

Share this post


Link to post
Share on other sites
stramit    122
I'm not sure about the second issue, but for the first. When you create the texture specify the type of sampling you wish to use, for example:


GL11.glTexParameteri( textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR );
GL11.glTexParameteri( textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR );
GL11.glTexParameteri( textureType, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP );
GL11.glTexParameteri( textureType, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP );

Share this post


Link to post
Share on other sites
TimothyFarrar    210
Have you tried rendering to a red only channel FBO?

Also when rendering (meaning writing to) your polygon (or primitive) is always going to be pixel aligned. However if you have alpha blending on, and blending say a transparent texture, the texture coordinates will have correct sub-pixel positioning and thus look anti-aliased (or linear filtered?) if they happen to be on a sub-pixel boundary.

Share this post


Link to post
Share on other sites
Yann L    1802
Quote:
Original post by TimothyFarrar
Also when rendering (meaning writing to) your polygon (or primitive) is always going to be pixel aligned. However if you have alpha blending on, and blending say a transparent texture, the texture coordinates will have correct sub-pixel positioning and thus look anti-aliased (or linear filtered?) if they happen to be on a sub-pixel boundary.

Alpha blending is completely unrelated to polygon rasterization. It doesn't even know about polygons, nor about texture coordinates or subpixel positions. It just blends single fragments (ie. pixels), nothing more.

An FBO used as a render target isn't a texture, as far as the OpenGL API is concerned. No texture states applied onto it while bound as a target are going to have any effect. If you need smooth polygon edges while rendering to an FBO, then you need to enable antialiasing, just as with the regular framebuffer. Note that you need support for EXT_framebuffer_multisample for this to work.

Quote:

Also, I would quite like my FBO texture to be an alpha mask (GL_ALPHA) rather than an RGBA texture as I only need the alpha, and have issues with card memory, but again, it doesn't seem to like that.

The standard doesn't allow this. It only allows full RGB or RGBA colour attachements:
Quote:

* An internal format is "color-renderable" if it is RGB, RGBA,
or one of the formats from table 3.16 whose base internal
format is RGB or RGBA. No other formats, including compressed
internal formats, are color-renderable.


Which is completely idiotic, so certain manufacturers ignored it. However this is not standard. If you attach an RGB/RGBA texture, it is guaranteed to work on a standards compliant driver. If you attach anything else as a colour attachement, it might work, or it might not.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this