View Full Version : Questions: GL_LINEAR is not working in android GLES 3.0

06-25-2014, 11:04 PM
Hi, I tried using Texture parameters for MIN and MAG FILTER as GL_LINEAR, but it gives a black screen for me.
Is there a way to implement this interpolation in 3D texturing? i am getting distorded images by using GL_NEAREST.


carsten neumann
06-26-2014, 01:49 AM
Hmm, something rather basic like linear texture filtering should normally work.
My suspicion would be that there is something else wrong especially when you say that GL_NEAREST produces 'distorted' images - I would expect them to be pixelated, not distorted. Is it possible that your glPixelStore (http://www.opengl.org/sdk/docs/man/html/glPixelStore.xhtml) settings (in particular GL_UNPACK_ALIGNMENT) are incorrect when uploading the texture data?

06-26-2014, 01:55 AM
Actually, Image doesnt even appear on GL_LINEAR. GL_NEAREST produces blurred images where there is slight distortion. Is there any mathematical algorithm which i can implement in th shader to counter the interpolation issue?
\My pixel store parameters seem to be fine.

carsten neumann
06-26-2014, 02:16 PM
It's possible to manually implement linear sampling in the shader (but a bit tedious to handle the different wrap modes and not as efficient as letting the hardware do it). For a texture of size W by H pixels the pixel centers are located at texture coords u = i/W + 1/2W and v = i/H + 1/2H for i in [0,W-1], j in [0,H-1]. You need to find the 4 texels closest to the sample location (s,t) and bilinearly interpolate their values.
For sampling at (s,t) where the fractional part of (s*W) > 1/2W you want texels s*W, (s+1)*W, otherwise s*W, (s-1)*W and similar for the vertical direction.