Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-24696

Problem with Effect item when applying material and texture

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: P2: Important P2: Important
    • 5.7.1
    • Qt3D TP2
    • Qt3D
    • None

      I noticed, that there is a Problem with the QML Effect item, when applying a texture and a material at the same time.

      Following example code is displaying a Cube that has a texture an material applied.
      The texture color and the materal color are mixed correctly.

      Cube {
          effect: Effect {
              decal: true
              texture: "qtlogo.png"
              material: Material {
                  diffuseColor: "blue"
              }
          }
      } 
      

      However, if you change the order of the properties in the Effect item to:

      Cube {
          effect: Effect {
              material: Material {
                  diffuseColor: "blue"
              }
              decal: true
              texture: "qtlogo.png"
          }
      } 
      

      This doesnt work correctly any more. Only a blue cube will be displayed. This is because (in the second example) internally first
      the texture property is processed. Because the effect doesn't contain any material yet, a new material is created that holds the texture.
      Afterwards the material property is processed which applies the material to the effect, effectivly obscuring the other material.
      In the first example, the material is applied first to the effect. When the texture property is set afterwards, the texture
      is applied to the existing material.

      The same applies for the color property in the Effect item btw.

      As solution I propose to just remove the texture and color property from the Effect item, because it is there anyway in the
      Material item (but not documented).
      Following code would work just fine:

      Cube {
          effect: Effect {
              material: Material {
                  diffuseColor: "blue"
                  textureUrl: "qtlogo.png"
              }
              decal: true
          }
      }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            dpope Daniel Pope (closed Nokia identity) (Inactive)
            bomb3rman Fabian Bumberger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes