Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

iphone - OpenGL ES 2.0 texture distortion on large geometry GL_REPEAT

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...