QML ShaderEffect and property type



  • Hi all,

    I would like to pass a matrix3x3 to my openGL script but I can't find the right type to use in QML.
    It works with a matrix4x4 in the following example :

    @
    ShaderEffect {
    ...

    property matrix4x4 uMatrix: Qt.matrix4x4(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1)
    
    ...
    

    }
    @

    Unfortunately the QML type "matrix3x3" does not exist. I tried many other types without success.
    Does anyone have a solution please ?



  • Could you just use the matrix4x4, and then just fill the 4th column with '1'?
    The shaders are always using 4x4 and 4x1, and I guess that you are using the matrix in your shader. Post your full code, maybe I can help some more.



  • amund_l Thanks for reply.
    In my shader I use a matrix3x3 so I would like to set it directly from QML.
    Another solution would be to convert a matrix4x4 to matrix3x3 at the beginning of my shader. Is it possible ?
    Something like :
    @
    mat3 matrix3x3 = matrix4x4 * ???;"
    @



  • The property types which are provided by QtQuick are listed at http://doc-snapshot.qt-project.org/qt5-stable/qtquick/qtquick-qmltypereference.html#basic-types however not all of them have conversions to uniforms/varyings in ShaderEffect. Matrix3x3 doesn't exist at all. vector2d, vector3d, vector4d, quaternion and matrix4x4 should all have conversions.

    Cheers,
    Chris.


Log in to reply
 

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