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

Unshaded Custom Materials with VARYING don't work when not using uniforms

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 6.0.1, 6.1.0 Alpha
    • 6.0.0
    • Quick: 3D
    • None
    • All
    • 8361bdd25c0bb04e68ded8e803cc27daa55f782e (qt/qtquick3d/dev) 9cbb01db78f5ec49e362d0ed88111f22c5402811 (qt/qtquick3d/6.0)
    • Qt Quick 3D - 49/50

    Description

      When creating a CustomMaterial with Unshaded shadingMode, it is possible for the shader generation/compilation to fail when there are varyings but no uniforms (custom properties).

      It seems to be because QQ3D_SHADER_META is created in two blocks:

      Working:

       36  #ifdef QQ3D_SHADER_META
       37  /*{
       38    "uniforms": [
       39      { "type": "vec4", "name": "flatColor" }
       40    ]
       41  }*/
       42  #endif
       43  #ifdef QQ3D_SHADER_META
       44  /*{
       45    "inputs": [
       46      { "type": "vec3", "name": "var_normal", "stage": "fragment" }
       47    ]
       48  }*/
       49  #endif
      

      Non Working:

       40  #ifdef QQ3D_SHADER_META
       41  /*{
       42    "uniforms": [
       43    ]
       44  }*/
       45  #endif
       46  #ifdef QQ3D_SHADER_META
       47  /*{
       48    "outputs": [
       49      { "type": "vec3", "name": "var_normal", "stage": "vertex" }
       50    ]
       51  }*/
       52  #endif
      

      The lack of any uniforms in the first block is expected for a material that doesn't expose any custom uniforms properties. But what happens is that when the shader meta data is parsed it hits this block in qssgrendershadermetadata.cpp:

              // /*{"uniforms":{"name":"x","type":"y"}}*/ => 40
              if (size < 40) {
                  qWarning("Shader metadata section found, but content to small to be valid!");
                  break;
              }
      

      But this blocks the parsing of varyings by breaking, meaning that valid shader code will not be generated.

      Attachments

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

        Activity

          People

            lagocs Laszlo Agocs
            janichol Andy Nichols
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes