Disabling Texture filtering completely in Modern Opengl

Hi ,

I am trying to render texture to FBO with larger than original size.
I dont want OpenGL to apply any type of filtering in order to fit my new FBO size.

I did following after I load my texture after I loaded my texture.

glTexParameterf(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

My understanding was this should disable texture filtering but I am confused because
difference between texelFetch() and texture2D() sampling functions I use in my shader.

As per my knowledge texture2D() internally applies some filtering while fetching texel.
So my question is as I have added GL_NEAREST will usage of texture2D() is safe? ( by safe I mean can I be sure texture2D() function will not do any filtering by itself?)

or

should I just use texelFetch() to sample my texture ?

Thanks
PixelClear

[QUOTE=PixelClear;1288822]My understanding was this should disable texture filtering but I am confused because
difference between texelFetch() and texture2D() sampling functions I use in my shader.[/quote]

texelFetch() bypasses any sampler state you’ve got set (including min/mag filters), whereas texture2D() honors that sampler state.

As per my knowledge texture2D() internally applies some filtering while fetching texel.

More specifically, it uses the texture filtering settings in the bound sampler object (or texture object, if there is no bound sampler object).

So my question is as I have added GL_NEAREST will usage of texture2D() is safe? ( by safe I mean can I be sure texture2D() function will not do any filtering by itself?)

If by safe you mean it’s not going to do any multi-texel blending, that is it’s just going to point-sample a single texel value in your texture, then yes.

should I just use texelFetch() to sample my texture ?

That works too. Either way.

Note that texture2D() also honors things like level-of-detail clamping, texture wrap mode application, and depth comparisons. But if you have none of those set, then there’s not much of a reason to prefer one texture sampling function over the other … except that one takes normalized texture coordinates and the other takes integer texel coordinates.

Thanks for reply .

I have put GL_NEAREST filtering mode and disabled texture wrapping along with mipmaping. I think now even after using texture2D() I dont see any filtering or blurring on my final image.