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. [SOLVED] Repeating texture in QT3D - multiple usage of the same texture
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 2 Posters 3.0k 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.
  • S Offline
    S Offline
    sibislaw2
    wrote on 5 Feb 2014, 12:25 last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sibislaw2
      wrote on 6 Feb 2014, 06:33 last edited by
      #2

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

      1 Reply Last reply
      0
      • O Offline
        O Offline
        onek24
        wrote on 6 Feb 2014, 08:44 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sibislaw2
          wrote on 6 Feb 2014, 10:24 last edited by
          #4

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

          1 Reply Last reply
          0
          • O Offline
            O Offline
            onek24
            wrote on 6 Feb 2014, 10:32 last edited by
            #5

            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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sibislaw2
              wrote on 6 Feb 2014, 10:35 last edited by
              #6

              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 ?

              1 Reply Last reply
              0
              • O Offline
                O Offline
                onek24
                wrote on 6 Feb 2014, 10:56 last edited by
                #7

                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.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  sibislaw2
                  wrote on 6 Feb 2014, 13:49 last edited by
                  #8

                  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.

                  1 Reply Last reply
                  0

                  1/8

                  5 Feb 2014, 12:25

                  • Login

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