   OpenGL 3D texture artifact using nearest interpolation - SOLVED
  Hi everyone,I am experiencing a strange artifact while rendering a textured quad using a 3D texture. The artifact is highly visible when I use nearest interpolation for both min and mag filter (see the images).  On the other hand, if I use linear interpolation the artifacts disappears, but the rendering looks quite blurry. Unfortunately, my application requirements request that I use nearest interpolation, thus, I can't use linear filtering to circumvent the problem.Does anyone have a clue what this artifact is? Is it maybe texture bleeding or aliasing? I would really appreciate any suggestions.P.S Here is the code for the 3D texture setup.glEnable(GL_TEXTURE_3D);glBindTexture(GL_TEXTURE_3D,volTexId);if(texture_nearest){   glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);   glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);}else{   glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);   glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);}glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE32F_ARB, 512, 512,180, 0,GL_LUMINANCE, GL_FLOAT, image->getData());glBindTexture(GL_TEXTURE_3D,0);glDisable(GL_TEXTURE_3D);[Edited by - Quantix on May 16, 2010 8:15:01 AM]
  Does that happen at the edges of the texture (depends on your texcoord). Because if that is the case, then try GL_CLAMP_TO_EDGE.   ;  It happens everywhere on the displayed texture (including edges). The artifact is highly visible when there is a high intensity different between adjacent voxels in the texture.   ;  I would suggest running your program on another PC with another graphics card.   ;  The behavior you are getting is what your requested GL_NEAREST doesn't do any filtering and thats that you are seeing in your image. If the current texel is 0 and all its 4 neighbors that are usually used in bilinear filtering are for example 1, your actual texel will be 0 instead of a blend.   ;  @V-ManQuote:I would suggest running your program on another PC with another graphics card.I tried it on another PC (different OS, graphics cards , drivers) and got the same result.@cgrantQuote:The behavior you are getting is what your requested GL_NEAREST doesn't do any filtering and thats that you are seeing in your image. If the current texel is 0 and all its 4 neighbors that are usually used in bilinear filtering are for example 1, your actual texel will be 0 instead of a blend.I definitely agree with you on the principle of nearest neighbor interpolation. However, the images are zoomed on the texture at almost texel level. Therefore, in the following example  one would expect that the texel marked with the red box would either be black or white but not a blend between those two values (the texture contains only 8 different values all-together). What gives me headache it the jitter-like artifact in these texels.Another source of headache is the following example. When my viewing direction is orthogonal to the plane displaying the texture the artifacts are not visible. On the other hand, when I slightly rotate the textured quad artifacts start to appear.  This is really strange.Thanks for the replies so far.;  i think that somehow a texel of a underlying layer of the 3D texture got picked by the gl_nearest. That's properly because when you view the texture not orthoggonaly u get a anisotropic effect?   ;Quote:i think that somehow a texel of a underlying layer of the 3D texture got picked by the gl_nearest. That's properly because when you view the texture not orthoggonaly u get a anisotropic effect?Sure, nearest interpolation is along all axis in the 3D texture. However, I don't see why changing the orientation of the textured quad would affect the interpolation outcome. The texture coordinates for both orthogonal and non-orthogonal case are still the same, since they are not affected by the modelview matrix. Am I missing something?   ;Quote:Original post by Danny02i think that somehow a texel of a underlying layer of the 3D texture got picked by the gl_nearest. That's properly because when you view the texture not orthoggonaly u get a anisotropic effect?I don't think it is anisotropy since this would sample a few pixels and do an average so you would get some grey.Perhaps he can make a shader that outputs the texcoords, render to a RGBA32F buffer, then readback and inspect the texcoords carefully.   ;  @V-ManI tried your suggestion in an altered way by writing a fragment shader that produces arbitrary (rotation and translation independent) cut slices from the 3D texture volume. The resulting cut slice does not have any artifacts. Does this info point out the possible problem?Considering your initial suggestion, what should I look out for when I got the texture coordinates read back?   