Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Disabling Texture filtering completely in Modern Opengl

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2017
    Location
    holographica
    Posts
    10

    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

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,169
    Quote Originally Posted by PixelClear View Post
    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.
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2017
    Location
    holographica
    Posts
    10
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •