[SOLVED] Repeating texture in QT3D - multiple usage of the same texture



  • HI ! I am a new user of Qt3D and i want to use single texture on single quad multiple times. Here is the code :

    Quad {
        scale: 100.0
        position: Qt.vector3d(0,0,0)
    
         effect: Effect {
             color: "#FFFFFF"
             texture: "rockwall.png"
    
         }
     }
    

    Now there is single texture on Quad. What can i do to have this texture repeated on this quad several times ?



  • Can anyone can help me ? I even appreciate telling me that this isnt possible.



  • Hello and welcome to qt-project.org,
    i'm sorry that no one could help you out yet. I'll check it out and after that i'll tell you what i found.

    --Attach--

    Maybe horizontalWrap and verticalWrap is what you are searching for?
    "HorizontalWrap":http://doc.qt.digia.com/qt-quick3d-snapshot/qgltexture2d.html#horizontalWrap
    "TextureWrap":http://doc.qt.digia.com/qt-quick3d-snapshot/qgl.html#TextureWrap-enum

    I havn't worked with Qt3d so i might be wrong. Please tell me if the information could help you.



  • Yes, it is good, but how to use it in QML ? i mean i dont see possibility in QML to set coordinates for texture.



  • There is not that much information about QML Quad in the documentation:
    "QML Quad":http://doc.qt.digia.com/qt-quick3d-snapshot/qml-quad.html#details

    It looks like Quad is preferably used for testings : "...usually for testing material effects...". Isn't there some other Item that you could use for that, because i don't think that you can repeat the texture in a Quad.

    Maybe you'll find some usefull information here:
    "Item3D":http://doc-snapshot.qt-project.org/qt3d-1.0/qml-item3d.html



  • So, is there any possibility of making Quad (not using Quad element), maybe from triangles using Item3D ? And texturing them ?

    Maybe there is simple method of repeating quad element ?



  • I'm sure that there must be a way to repeat textures. I have not worked with Qt3D yet so i can' tell you, but i would give Item3D a try. Otherwise you'll have to wait for someone's else answer or repeat your quad elements, this should work if you use Repeater Items.



  • I found the way using shader program, here is the code

     @Quad {
        scale: 100.0
        position: Qt.vector3d(0,0,0)
        effect: program1
     }
    
     ShaderProgram {
         id: program1
         texture: "rockwall.png"
    
         vertexShader: "
         attribute highp vec4 qt_Vertex;
         uniform highp mat4 qt_ModelViewProjectionMatrix;
    
         attribute highp vec4 qt_MultiTexCoord0;
         varying highp vec4 texCoord;
    
         void main(void)
         {
            texCoord = qt_MultiTexCoord0*4;
            gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
         }
         "
         fragmentShader: "
         varying highp vec4 texCoord;
         uniform sampler2D qt_Texture0;
    
         void main(void)
         {
             mediump vec4 textureColor = texture2D(qt_Texture0, texCoord.st);
             gl_FragColor = textureColor;
         }
         "
     }@
    

    The topic is closed, and thanks for help everyone. Line 20 repeats texture for 4-times on axis x and y, from one texture there will be 16 all over quad.


Log in to reply
 

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