QML 3D / Shaders : issue with second texture



  • Hello all,
    I'm trying one example provided here with some modifications:
    http://doc.qt.nokia.com/qt3d-snapshot/tutorials-shaders-shader-tutorial-1-textures-qml.html
    @ShaderProgram {
    id: program
    texture: "../../resources/map512x512.png"
    property string texture2: "../../resources/ButtonHMI.png"
    property real interpolationFactor : 0.5

        vertexShader: "
            attribute highp vec4 qt_Vertex;
            uniform highp mat4 qt_ModelViewProjectionMatrix;
    
            attribute highp vec4 qt_MultiTexCoord0;
            varying highp vec4 texCoord;
    
            void main(void)
            {
                texCoord.st = qt_MultiTexCoord0.xy;
                gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
            }
            "
        fragmentShader: "
            varying highp vec4 texCoord;
            uniform sampler2D qt_Texture0;
            uniform sampler2D texture2;
            uniform mediump float interpolationFactor;
    
            void main(void)
            {
                mediump vec4 texture1Color = texture2D(qt_Texture0, texCoord.st);
                mediump vec4 texture2Color = texture2D(texture2, texCoord.st);
                mediump vec4 textureColor = mix(texture1Color, texture2Color,
                                            interpolationFactor);
                gl_FragColor = texture2Color;
            }
            "
    }@
    

    I understand the property "texture" mapped to qt_Texture0, but texture2 is not working at all.
    The result is a dark version of texture1Color. just like it was a mix between qt_Texture0 and a black texture corresponding to color (0,0,0,0).

    So I tried to simply do the following: gl_FragColor = texture1Color;

    @ fragmentShader: "
    varying highp vec4 texCoord;
    uniform sampler2D qt_Texture0;
    uniform sampler2D texture2;
    uniform mediump float interpolationFactor;

         void main(void)
         {
             mediump vec4 texture1Color = texture2D(qt_Texture0, texCoord.st);
             mediump vec4 texture2Color = texture2D(texture2, texCoord.pq);
             mediump vec4 textureColor = mix(texture1Color, texture2Color, interpolationFactor);
             gl_FragColor = texture1Color;
         }
         "
     }@
    

    and the texture1 is displayed correctly.

    Then, I itried to simply display texture2Colod by doing the following: gl_FragColor = texture2Color;
    @ fragmentShader: "
    varying highp vec4 texCoord;
    uniform sampler2D qt_Texture0;
    uniform sampler2D texture2;
    uniform mediump float interpolationFactor;

         void main(void)
         {
             mediump vec4 texture1Color = texture2D(qt_Texture0, texCoord.st);
             mediump vec4 texture2Color = texture2D(texture2, texCoord.pq);
             mediump vec4 textureColor = mix(texture1Color, texture2Color, interpolationFactor);
             gl_FragColor = *texture2Color *;
         }
         "
     }@
    

    And the result is a black image, instead of getting the corresponding texture2 texture :(
    Anyone can help me on this?

    Thank you,
    Bill



  • Problem is occuring only if I mix 2D element and 3D element. The point is being followed on the qt-3D mailing list. If I get an answer / bug fix, I will advise this here.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.