Hello,
OpenGL ES 3.0 here. I’ve got a weird problem. The program I am writing works of some 50 different (mobile) devices I’ve checked, but recently it has been brought to my attention the the program does not work on Samsung Galaxy J4+ (Adreno 308). I’ve got access to this model and indeed, I can reproduce what has been reported.
Using the tactic of the ‘smallest code that reproducees the problem’ I’ve been shaving various pieces of code off and I’ve arrived at a very simple program with essentially displays a textured quad. Here’s what it does:
Vertex shader:
#version 300 es
// …
in vec2 a_TexCoordinate; // Per-vertex texture coordinate.
out vec2 v_TexCoordinate;// …
void main()
{
// …
v_TexCoordinate = a_TexCoordinate;
// …
}
Fragment Shader:
#version 300 es
precision mediump float;
in vec2 v_TexCoordinate;
out vec4 fragColor;
uniform sampler2D u_Texture;void main()
{
fragColor = texture(u_Texture,v_TexCoordinate);
}
Using those shaders, when run on any ‘normal’ device, my textured-quad-program displays the following:
Which is exactly what I expect - this is the input texture.
The very same program, when run on the ‘suspicious’ Galaxy J4+ however, displays the following:
Which is the texture moved by vec2(0.5,0.5) [ I’m using GL_CLAMP_TO_EDGE for texture wrapping ]
So it really looks like the J4+ somehow moves the texture coordinates by (0.5,0.5). I’ve then tried the following for the fragment shader:
#version 300 es
precision mediump float;
in vec2 v_TexCoordinate;
out vec4 fragColor;
uniform sampler2D u_Texture;void main()
{
fragColor = texture(u_Texture, vec2(0.5,0.5) );
}
and that displays (on any device including the J4+)
Which is expected - this is the color of the middle of the texture. Then I’ve tried
Vertex shader:
#version 300 es
// …
in vec2 a_TexCoordinate; // Per-vertex texture coordinate.
out vec2 v_TexCoordinate;// …
void main()
{
// …
v_TexCoordinate = vec2(0.5,0.5);
// …
}
Fragment Shader:
#version 300 es
precision mediump float;
in vec2 v_TexCoordinate;
out vec4 fragColor;
uniform sampler2D u_Texture;void main()
{
fragColor = texture(u_Texture,v_TexCoordinate);
}
i.e. hardcoding all the texture coordinates to (0.5,0.5) in the vertex shader and passing those on to the fragment shader - the effect on any ‘normal’ device is expected (blue rectangle just like above), but on the J4+ it displays
i.e. again the input texture moved by (0.5,0.5).
So it would seem like on the J4+ the out ‘v_TexCoordinate’ variable of the vertex shader is completely disconnected with the in ‘a_TexCoordinate’ variable of the fragment shader.
How is that possible?