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
- depends on
-
QTBUG-82472 QRhi D3D11 backend can hit sampler slot limit even though there are fewer samplers in the shader
- Closed
-
QTBUG-82438 RHI: Generate valid shader code for Quick3D custom materials
- Closed
-
QTBUG-82624 rhi: Support for arrays of textures
- Closed
-
QTBUG-82654 Dynamic looping based on light count uniforms in custom materials is not portable
- Closed
-
QTBUG-82719 rhi: There is a limit of 16 combined image samplers per shader which can be problematic for custom materials
- Closed
- is required for
-
QTBUG-78679 Port Qt Quick 3D onto the RHI
- Closed
- resulted in
-
QTBUG-82790 Custom materials in Qt 6
- Closed
- tests
-
QTBUG-82587 Custom material CG lighting is broken
- Closed