OpenGL ES 2.0 has serious precision issues with texture sampling - I've seen topics with a similar problem, but I haven't seen a real solution to this "distorted OpenGL ES 2.0 texture" problem yet.
This is not related to the texture's image format or OpenGL color buffers, it seems like it's a precision error. I don't know what specifically causes the precision to fail - it doesn't seem like it's just the size of geometry that causes this distortion, because simply scaling vertex position passed to the the vertex shader does not solve the issue.
Here are some examples of the texture distortion:
Distorted Texture (on OpenGL ES 2.0): http://i47.tinypic.com/3322h6d.png
What the texture normally looks like (also on OpenGL ES 2.0): http://i49.tinypic.com/b4jc6c.png
The texture issue is limited to small scale geometry on OpenGL ES 2.0, otherwise the texture sampling appears normal, but the grainy effect gradually worsens the further the vertex data is from the origin of XYZ(0,0,0)
These texture issues do not occur on desktop OpenGL (works fine under Windows XP, Windows 7, and Mac OS X)
I've only seen the problem occur on Android, iPhone, or WebGL(which is similar to OpenGL ES 2.0)
All textures are power of 2 but the problem still occurs
Scaling the vertex data - The values of a vertex's X Y Z location are in the range of: -65536 to +65536 floating point
- I realized this was large, so I tried dividing the vertex positions by 1024 to shrink the geometry and hopefully get more accurate floating point precision, but this didn't fix or lessen the texture distortion issue
Scaling the modelview or scaling the projection matrix does not help
Changing texture filtering options does not help
- Disabling mipmapping, or using GL_NEAREST/GL_LINEAR does nothing
- Enabling/disabling anisotropic does nothing
- The banding effect still occurs even when using GL_CLAMP
Dividing the texture coords passed to the vertex shader and then multiplying them back to the correct values in the fragment shader, also does not work
precision highp sampler2D, highp float, highp int - in the fragment or the vertex shader didn't change anything (lowp/mediump did not work either)
I'm thinking this problem has to have been solved at one point - Seeing that OpenGL ES 2.0 -based games have been able to render large-scale, highly detailed geometry
This is the usual texture atlas problem. There is no setting to limit the linear interpolation in mid-texture. That's how the hardware works.
You can work around the issue by using nearest filter texture lookup in a fragment program which calculates the texture lookup modulo your texture tile size and position and does its linear filtering manually.
来源:https://stackoverflow.com/questions/11370074/opengl-es-2-0-texture-distortion-on-large-geometry-gl-repeat