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

Quick3D custom materials with RHI (excl. blits/multipass)

    XMLWordPrintable

Details

    • Task
    • Resolution: Done
    • P2: Important
    • 6.0
    • None
    • Qt RHI, Quick: 3D
    • None

    Description

      1. Generate shader code. Handled in QTBUG-82438. done

      2. Single pass, texture-less, completely custom materials (such as the customshaders example, no interaction with lighting and other features etc. is needed there) done

      3. Enable textures, blend and cull mode states, with lights uniform buffer set as well. Plus light probes. done

      4. Backend specific issues to solve: The custommaterials example blows up with D3D. QTBUG-82472 QTBUG-82719 done

      5. Enable demoing and testing various custom material cases: custom materials with lights and shadows. hacked something into the lights example done

      This is important because the existing custommaterials example only uses light probes, same goes for all Lancelot cases; this means that a significant portion of the custom materials functionality is not tested in any form. See next point.

      6. It turns out custom materials are pretty broken when it comes to lights, this is unrelated to RHI. QTBUG-82587 out of scope for this task Turns out that this is not fully unexpected since what we inherited from Qt 3D Studio is simply not correctly prepared to handle all cases. For example, custom materials use their environment map texture even when environment mapping is explicitly disabled. Also they are not meant to handle diffuse or shadow(?!) contributions.

      6.1 off-topic: direct OpenGL (no RHI) on macOS cannot display the custom material based objects with https://codereview.qt-project.org/c/qt/qtquick3d/+/293018 ("QSSG.gl_error: GL Error: GL_INVALID_OPERATION")

      7. Lights. (directional, point, area, spot) done but see 6

      7.1 The results with RHI (using the enhanced 'lights' example) do not match the non-RHI ones. (not even in the broken non-RHI form, that still looks better than what we get with RHI) done

      8. Shadow mapping. done

      8.1 Needs array support for combined image samplers (think for instance: layout(binding = 9) uniform samplerCube shadowCubes[8]). This is totally unsupported by everything in the stack. Bummer. Needs a whole lot of new feature development in QRhi: QTBUG-82624 done

      8.2 and then it all fails with HLSL due to dynamic looping (which calls functions etc. in the body) QTBUG-82654 done

      8.3 we also hit a sampler slot limit (16) on D3D due to the why we translate SPIRV-V combined image samplers to HLSL. worked around see also QTBUG-82719

      9. Need new Lancelot cases for 7 and 8. done

      10. Ambient occlusion, depth prepass, depth texture. done (but note that SSAO is disfunctional with the built-in custom materials, meaning it will have no visible effect; this is similar to 6)

      The following are moved to a separate task:

      11. Non-property images. (?? there is code on the direct OpenGL code path but not sure what it is for)

      12. Support multiple passes with BufferBlit commands in them.

      13. Enable sourceless BufferBlits.

      This raises an interesting issue, namely that it is possible to get a copy of the main framebuffer (see first BufferBlit in the example below), meaning all the content that was rendered before the object with the custom material in question.

      With the QRhi-based pipeline the texture-to-texture copy would normally happen in the prepare phase, but we haven't even started the main renderpass at that point, so source-less BufferBlits cannot be supported this way.

      It is very unfortunate that the old OpenGL implementation tends to rely on the 'do some draw calls, issue a blitFramebuffer to get the content rendered by the previous draw calls, do some more draw calls, ...' pattern, which, while being a performance hazard, is also non-portable to modern APIs (and by extension to QRhi).

      So such materials will likely involve running a full main render pass up to the object in question, targeting the destination texture of such a BufferBlit, in the prepare phase. (so then such a BufferBlit is not a copy then but rather the result of partially performing the main renderpass, ugggh...)

         passes: [ Pass {
                  shaders: frostedGlassSpFragShader
                  commands: [ BufferBlit {   // <--------------- no source
                          destination: tempBuffer
                      }, BufferInput {
                          buffer: tempBuffer
                          param: "refractiveTexture"
                      }, Blending {
                          srcBlending: Blending.SrcAlpha
                          destBlending: Blending.OneMinusSrcAlpha
                      }
                  ]
              }
          ]
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-82245
          # Subject Branch Project Status CR V

          Activity

            People

              lagocs Laszlo Agocs
              lagocs Laszlo Agocs
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: