Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Qt Quick3D skybox fails on android
Forum Updated to NodeBB v4.3 + New Features

Qt Quick3D skybox fails on android

Scheduled Pinned Locked Moved Unsolved Game Development
1 Posts 1 Posters 529 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johngod
    wrote on 21 Jun 2020, 07:27 last edited by
    #1

    I have made a small example that shows a skybox. It works fine on desktop but fails on android. The code is simple:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick3D 1.15
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        View3D {
            id: view3D
            visible: true
            width: parent.width
            height: parent.height
    
            environment: SceneEnvironment {
                //backgroundMode: SceneEnvironment.Color
                backgroundMode:  SceneEnvironment.SkyBox
                lightProbe: Texture {
                    source: "qrc:/skybox.hdr"
                    mappingMode: Texture.LightProbe
                }
                clearColor: "skyblue"
            }
    
            //! [camera]
            PerspectiveCamera {
                id: cam
                position: Qt.vector3d(0, 0, 500)
            }
            //! [camera]
    
    
            DirectionalLight {
                eulerRotation.x: -45
            }
    
            Model {
                id: ball
                //source: "#Cylinder"
                source: "#Cylinder"
                scale: Qt.vector3d(1, 1, 1)
                materials: [ DefaultMaterial {
                        diffuseColor: "red"
                    }
                ]
                position: Qt.vector3d(-100, -150, 0)
                onPositionChanged: console.log(position)
            }
        }
    }
    

    Relevant part of the logs:

    I Adreno  : QUALCOMM build                   : e6de3b7, I22091d40c2
    I Adreno  : Build Date                       : 08/07/19
    I Adreno  : OpenGL ES Shader Compiler Version: EV031.25.03.03
    ............
    I OpenGLRenderer: Initialized EGL, version 1.4
    D OpenGLRenderer: Swap behavior 2
    D OpenGLRenderer: eglCreateWindowSurface = 0xa52a1120, 0x920c6808
    ..............................
    I libSkyBoxTest_armeabi-v7a.so: QSSG.trace_info: GLSL version: OpenGL ES GLSL ES 3.10
    I libSkyBoxTest_armeabi-v7a.so: QSSG.trace_info: GL version: OpenGL ES 3.0 V@331.0 (GIT@e6de3b7, I22091d40c2) (Date:08/07/19)
    I libSkyBoxTest_armeabi-v7a.so: QSSG.trace_info: HW vendor: Qualcomm
    I libSkyBoxTest_armeabi-v7a.so: QSSG.trace_info: Vendor renderer: Adreno (TM) 308
    I libSkyBoxTest_armeabi-v7a.so: QSSG.trace_info: OpenGL extensions: GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_vertex_half_float GL_OES_framebuffer_object GL_OES_rgb8_rgba8 GL_OES_compressed_ETC1_RGB8_texture GL_AMD_compressed_ATC_texture GL_OES_texture_npot GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_OES_texture_3D GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_QCOM_alpha_test GL_OES_depth24 GL_OES_packed_depth_stencil GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_EXT_sRGB GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_EXT_texture_type_2_10_10_10_REV GL_EXT_texture_sRGB_decode GL_OES_element_index_uint GL_QCOM_user_clip_planes GL_EXT_EGL_image_external_wrap_modes GL_EXT_multisampled_render_to_texture GL_EXT_robustness GL_OES_get_program_binary GL_EXT_debug_label GL_QCOM_tiled_rendering GL_OES_standard_derivatives GL_OES_vertex_array_object GL_EXT_YUV_target GL_EXT_sRGB_write_control GL_EXT_discard_framebuffer GL_OES_surfaceless_context GL_KHR_no_error GL_EX
    I libSkyBoxTest_armeabi-v7a.so: QSSG.trace_info: GL version: OpenGL ES 3.0 V@331.0 (GIT@e6de3b7, I22091d40c2) (Date:08/07/19)
    I libSkyBoxTest_armeabi-v7a.so: QSSG.trace_info: Compiling into shader cache: ' "fullscreen skybox shader" >'
    I Adreno  : ERROR: 0:19: 'inverse' : no matching overloaded function found
    I Adreno  : ERROR: 0:19: '=' :  cannot convert from 'const float' to '4X4 matrix of float'
    I Adreno  : ERROR: 2 compilation errors.  No code generated.
    06-21 07:33:48.481 31533 31709 I Adreno  :
    E libSkyBoxTest_armeabi-v7a.so: QSSG.internal_error: Failed to generate vertex shader!!
    E libSkyBoxTest_armeabi-v7a.so: QSSG.internal_error: Vertex source:
    E libSkyBoxTest_armeabi-v7a.so: #version 100
    E libSkyBoxTest_armeabi-v7a.so: #extension GL_OES_standard_derivatives : enable
    E libSkyBoxTest_armeabi-v7a.so: precision mediump float;
    E libSkyBoxTest_armeabi-v7a.so: precision mediump int;
    E libSkyBoxTest_armeabi-v7a.so: #define texture texture2D
    E libSkyBoxTest_armeabi-v7a.so: #define textureLod(s, co, lod) texture2D(s, co)
    E libSkyBoxTest_armeabi-v7a.so: //Shader name -fullscreen skybox shader
    06-21 07:33:48.481 31533 31709 E libSkyBoxTest_armeabi-v7a.so:
    E libSkyBoxTest_armeabi-v7a.so: attribute vec3 attr_pos;
    06-21 07:33:48.481 31533 31709 E libSkyBoxTest_armeabi-v7a.so:
    E libSkyBoxTest_armeabi-v7a.so: uniform mat4 viewMatrix;
    E libSkyBoxTest_armeabi-v7a.so: uniform mat4 projection;
    06-21 07:33:48.481 31533 31709 E libSkyBoxTest_armeabi-v7a.so:
    06-21 07:33:48.481 31533 31709 E libSkyBoxTest_armeabi-v7a.so:
    E libSkyBoxTest_armeabi-v7a.so: varying vec3 eye_direction;
    06-21 07:33:48.481 31533 31709 E libSkyBoxTest_armeabi-v7a.so:
    E libSkyBoxTest_armeabi-v7a.so: void main() {
    E libSkyBoxTest_armeabi-v7a.so:     gl_Position = vec4(attr_pos, 1.0);
    E libSkyBoxTest_armeabi-v7a.so:     mat4 inverseProjection = inverse(projection);
    E libSkyBoxTest_armeabi-v7a.so:     vec3 unprojected = (inverseProjection * gl_Position).xyz;
    E libSkyBoxTest_armeabi-v7a.so:     eye_direction = normalize(mat3(viewMatrix) * unprojected);
    E libSkyBoxTest_armeabi-v7a.so: }
    06-21 07:33:48.481 31533 31709 E libSkyBoxTest_armeabi-v7a.so:
    E libSkyBoxTest_armeabi-v7a.so: QSSG.invalid_operation: Vertex compilation output:: ERROR: 0:19: 'inverse' : no matching overloaded function found
    E libSkyBoxTest_armeabi-v7a.so: QSSG.invalid_operation: Vertex compilation output:: ERROR: 0:19: '=' :  cannot convert from 'const float' to '4X4 matrix of float'
    E libSkyBoxTest_armeabi-v7a.so: QSSG.invalid_operation: Vertex compilation output:: ERROR: 2 compilation errors.  No code generated.
    E libSkyBoxTest_armeabi-v7a.so: QSSG.invalid_operation: Vertex compilation output::
    E libSkyBoxTest_armeabi-v7a.so: QSSG.invalid_operation: Vertex compilation output::
    W project.exampl: 0xebadde09 skipped times: 0
    F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4 in tid 31709 (QtThread), pid 31533 (project.example)
    

    From above the problem seems to be the inverse() function in the auto generated shader:

    #version 100
    #extension GL_OES_standard_derivatives : enable
    precision mediump float;
    precision mediump int;
    #define texture texture2D
    #define textureLod(s, co, lod) texture2D(s, co)
    //Shader name -fullscreen skybox shader
    
    attribute vec3 attr_pos;
    
    uniform mat4 viewMatrix;
    uniform mat4 projection;
    varying vec3 eye_direction;
    
    
    void main() {
        gl_Position = vec4(attr_pos, 1.0);
        mat4 inverseProjection = inverse(projection);
        vec3 unprojected = (inverseProjection * gl_Position).xyz;
        eye_direction = normalize(mat3(viewMatrix) * unprojected);
    }
    

    According to the Khronus group the inverse() its only available in OpenGL ES shader language version 3.00. This seems to be a Qt bug, the auto generated preprocessor shader should be "#version 300 es", not "#version 100". Also I check my android phone it has opengl es 3.0 so it's good to go. As a workaround I could try to write my own shader but I thing thats only possible for custom Model's, not for SceneEnvironment.
    Somebody as any better ideia how to fix ???

    1 Reply Last reply
    0

    1/1

    21 Jun 2020, 07:27

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved