Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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:

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

share|improve this question
    
Have you tried the solution presented in the answer to the question you linked to (i.e. splitting your object up)? I'm guessing the texture problems only happen on ES because the mobile devices have less precision on whatever they use to do the texture lookup. –  CiscoIPPhone Jul 7 '12 at 3:14
    
What texture coords are you using? Just wondering. –  CiscoIPPhone Jul 7 '12 at 3:20
add comment

1 Answer 1

What you're seeing is floating point accuracy, or lack thereof.

Even highp is specified as 16 bit in OpenGL ES according to the spec (pdf link). To make things worse, denormals/subnormals are not required (these are used to improve accuracy near zero, but require special handling and, to save silicon space, are often not implemented).

Note that's the minimum spec, and implementations may be more accurate. You can get more information about the accuracy of your specific implementation by calling glGetShaderPrecisionFormat().

To solve the problem, try not to use huge numbers with tiny changes.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.