I am trying to tile area with texture atlas and specific shaders but I get weird behavior on different devices.
Most of them (Samsung Galaxy Ace, Samsung Galaxy Gio etc) are ok, just bleeding occurs (hope I can fix it with half-pixel correction).
But Samsung Galaxy S3 gets next with distance:
(jumping from weaker to even worse distortion zone is also seemed, it happens exactly on regular atlas width or height passing)
- OpenGL ES 2.0, Android SDK are used.
- Atlas and texture part for tiling are both POT (1024 for atlas and 64 for texture part).
- Texture filtering doesn't matter: tried both NEAREST and LINEAR
- drawable-nodpi resources folder is used
- mat4, vec2, vec4, sampler2D precisions change does nothing
What am I doing wrong? Is it possible to fix it?
Shaders:
Vertex:
uniform mat4 u_viewmatrix;
uniform mat4 u_modelmatrix;
attribute vec4 a_position;
varying vec2 v_texCoord;
void main()
{
mat4 matrix = u_viewmatrix * u_modelmatrix;
gl_Position = matrix * a_position;
v_texCoord = a_position.xy;
}
Fragment:
precision highp float;
uniform sampler2D u_texture;
uniform float u_texpartx;
uniform float u_texparty;
uniform float u_texpartwidth;
uniform float u_texpartheight;
uniform float u_texwidth;
uniform float u_texheight;
varying vec2 v_texCoord;
void main()
{
vec2 coord;
coord.x = (u_texpartx + mod(v_texCoord.x, u_texpartwidth))/u_texwidth;
coord.y = (u_texparty + mod(v_texCoord.y, u_texpartheight))/u_texheight;
gl_FragColor = texture2D(u_texture, coord);
}