Loading 3D model from DAE COLLADA using Qt 6. OpenGL lighting works incorrectly on Android and WebAssembly

Hello,

I wrote an example that loads 3D model from DAE COLLADA using Qt 6. Source code: load-3d-model-from-dae-opengl-window-qt6-cpp.zip

OpenGL lighting works correctly on Desktop but incorrectly on Android and WebAssembly:

d138eecf-d8bd-4de3-86aa-c7669484c12b-image.png

Android:

WebAssembly:

ef0b3e64-6deb-46ad-984b-9a9610509561-image.png

Vertex shader:

attribute vec4 aPosition;
attribute vec4 aNormal;
attribute vec2 aTexCoord;

uniform mat4 uMvpMatrix;
uniform mat4 uModelMatrix;
uniform mat4 uNormalMatrix;

varying vec3 vPosition;
varying vec3 vNormal;
varying vec2 vTexCoord;

void main()
{
    gl_Position = uMvpMatrix * aPosition;
    vPosition = vec3(uModelMatrix * aPosition);
    vNormal = normalize(vec3(uNormalMatrix * aNormal));
    vTexCoord = aTexCoord;
}

Fragment shader:

#ifdef GL_ES
precision mediump float;
#endif

const vec3 lightColor = vec3(0.8, 0.8, 0.8);
const vec3 ambientLight = vec3(0.3, 0.3, 0.3);

uniform sampler2D uSampler;
uniform vec3 uLightPosition;

varying vec3 vPosition;
varying vec3 vNormal;
varying vec2 vTexCoord;

void main()
{
    vec4 color = texture2D(uSampler, vTexCoord);
    vec3 normal = normalize(vNormal);
    vec3 lightDirection = normalize(uLightPosition - vPosition);
    float nDotL = max(dot(lightDirection, normal), 0.0);
    vec3 diffuse = lightColor * color.rgb * nDotL;
    vec3 ambient = ambientLight * color.rgb;
    gl_FragColor = vec4(diffuse + ambient, color.a);
}

Cross-refs:

I created the bug report: Loading...

I added this line of code glEnable(GL_CULL_FACE); to OpenGLWindow::initializeGL(). The problem was solved for a cube on Android:

image

and WebAssembly:

image

When I change a model with Mario it works on Desktop:

image

But it doesn’t work for Android:

image

and WebAssembly:

image

Source code: load-3d-model-from-dae-opengl-window-qt6-cpp.zip

I tried to set a depth buffer size to 24:

OpenGLWindow::OpenGLWindow()
{
    setTitle("OpenGL ES 2.0, Qt6, C++");
    resize(350, 350);

    QSurfaceFormat surfaceFormat;
    surfaceFormat.setDepthBufferSize(24);
    setFormat(surfaceFormat);
}

It works on WebAssembly at least from Windows 10, 64-bit:

image

And on Redmi 4X, Android 7: