Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML 3D / Shaders : issue with second texture
Forum Updated to NodeBB v4.3 + New Features

QML 3D / Shaders : issue with second texture

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 2.4k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    billouparis
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • B Offline
      B Offline
      billouparis
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

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