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 10 of 14

Thread: Edge texture filtering

Hybrid View

  1. #1
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,136

    Edge texture filtering

    Hi All,

    I've recently encountered a very peculiar problem. Edges of the triangles where texture changes (i.e. where level of texture array changes) expose noticeable artifacts. The artifacts are probably due to the texture filtering. I have to emphasize that texels on those edges are far from the border of the texture (level), and also I blend two adjacent levels. With or without blending, artifacts are the same. What could be the solution of the problem?

    Images on the following links illustrate the problem (the same (zoomed) scene filled and wireframed).
    Artifacts
    Wireframe

    Thank you in advance for any suggestion!

    Aleksandar

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,193
    Are you sending the exact same vertex coordinates down for that edge in both triangles? Are those stray pixels being filled? Would clear the screen to 100% blue beforehand and then render the scene. Do you see blue holes? Try another clear color -- same result?

    Also, are you rasterizing with MSAA?

    Are your texture coordinates for that edge in both triangles the same? Do your texture coordinate have continuous derivatives at the edges of triangles? Are you using MIPmap filtering and/or anisotropic texture filtering? What happens if you revert to non-MIPmap filtering (NEAREST or LINEAR)?

  3. #3
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,136
    Thank you, Dark! Your questions help me to locate the problem, but it cannot be eliminated easily.
    Well, let me first answer to all your questions. Maybe the answers could reveal deeper cause of the problem.


    • Edges in question are boundary edges of two adjacent triangles of the same triangle strip. So, coordinates should be the same. In fact, the problem repeats on the same triangle strip whenever texture level (of the same texture array) is changed.
    • Those pixels are filled (there is no holes, and the color is somehow related to used texture level)
    • Yes, I’m using multisampling.
    • The texture coordinates are not the same for both sides of the edge (different levels).
    • Mipmaping is not used (not applicable in this case). GL_LINEAR is used for the MIN/MAX filtering, and GL_REPEAT for wrap in both direction.
    • Anisotropic filtering IS used and THAT causing the problem!


    If anisotropic filtering is disabled, the problem disappears. Unfortunately, I cannot permanently disable it, since it is a terrain rendering application, and the impact will be unacceptable.

    Have you any suggestion how to solve it?

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,193
    I guess I'm not understanding something. You say MIPmapping is not used, but then you say that texture "level" varies across the edge. This doesn't make sense to me. Levels are MIPmap levels. If level varied, I could easily see how you might get filtering discontinuities.


    In any case, what about the X and Y texture derivatives on either side. First, are they always valid? And are they always the same? Is the content of the texture level(s) they're looking up into the same?

    Where you sometimes run into problems is if on the edges of your triangle the texture coordinates aren't defined outside of the triangle, so you end up with invalid (huge) texture derivatives for pixels (or samples) on the edge, which causes MIPmap filtering and/or anisotropic texture filtering to try and sample and filter over a large area of your texture. This can generate seam artifacts like this.

  5. #5
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,136
    OK, I'm sorry I was not clear. I'll try it better now.

    Quote Originally Posted by Dark Photon View Post
    I guess I'm not understanding something. You say MIPmapping is not used, but then you say that texture "level" varies across the edge. This doesn't make sense to me. Levels are MIPmap levels. If level varied, I could easily see how you might get filtering discontinuities.
    When I say "level" I mean "texture array layer". I'm sorry for misuse of the word level (in my context those are levels of detail, hence the term).

    Quote Originally Posted by Dark Photon View Post
    In any case, what about the X and Y texture derivatives on either side. First, are they always valid? And are they always the same? Is the content of the texture level(s) they're looking up into the same?
    I need a bit of coding to confirm values of the derivatives, but they are probably not the same since those are different textures (different layers of the same texture array).

    Quote Originally Posted by Dark Photon View Post
    Where you sometimes run into problems is if on the edges of your triangle the texture coordinates aren't defined outside of the triangle, so you end up with invalid (huge) texture derivatives for pixels (or samples) on the edge, which causes MIPmap filtering and/or anisotropic texture filtering to try and sample and filter over a large area of your texture. This can generate seam artifacts like this.
    Texture coordinates are defined outside of the triangle (GL_REPEAT is used and always have a "buffer" of at least 10% of the texture size that is not used in the drawing process). The artifacts stays even if less than a half of the layer is used for drawing.

    Here are some other examples of the artifacts:
    - With anisotropic filtering (img1)
    - With anisotropic filtering - artifacts marked (img1a)
    - Without anisotropic filtering (img2)
    - With anisotropic filtering - another example (img4)

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    664
    I assume, this is some kind of virtual texturing?
    It very much looks like you're using the wrong derivatives for fetching the texels. Mind you, the anisotropic filter is using the length of the derivatives to determine its footprint.
    I guess the edges we're seeing are discontinuities in the texture coordinates (jumping from one tile to another?), which cause a sudden increase in the gradient length and therefor a different filtering than surrounding texels. Also, you should provide a large-enough border around your tiles to prevent sampling outside the tile when the filter gets close to the tile border.
    More on VT stuff: https://mollyrocket.com/forums/viewf...59fc0160cb180b

Posting Permissions

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