QTextureMaterial error : 'Unable to find suitable Texture Unit for "diffuseTexture"' (OGL), 'Sampler "diffuseTexture" wasn't set on material. Rendering might not work as expected' (DX)
-
Hello,
I followed https://doc.qt.io/qt-6/qt3d-simple-cpp-example.html but I replaced the material by a QTextureMaterial.
The texture I set is not shown and I receive the following errors:
OpenGL:
Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit for "diffuseTexture"DirectX:
Qt3D.Renderer.RHI.Backend: Sampler "diffuseTexture" wasn't set on material. Rendering might not work as expected
D3D11 WARNING: ID3D11DeviceContext::DrawIndexed: The Pixel Shader unit expects a Sampler to be set at Slot 0, but none is bound. This is perfectly valid, as a NULL Sampler maps to default Sampler state. However, the developer may not want to rely on the defaults. [ EXECUTION WARNING #352: DEVICE_DRAW_SAMPLER_NOT_SET]Here's the code:
Qt3DRender::QMaterial* material = new Qt3DExtras::QTextureMaterial(rootEntity); Derived<Qt3DRender::QTextureImage>* dti = new Derived<Qt3DRender::QTextureImage>(); Qt3DRender::QTextureImage* ti = dti->get(); connect(ti, &Qt3DRender::QTextureImage::statusChanged, this, &mainCore::debugLog); ti->setSource(QUrl("file:///E:/IDrive-Sync/Dokumente/Qt Projects/Mylonite/cache/0_0_0.jpg")); Derived<Qt3DRender::QTexture2D>* dt = new Derived<Qt3DRender::QTexture2D>(); Qt3DRender::QTexture2D* t = dt->get(); t->addTextureImage(ti); ((Qt3DExtras::QTextureMaterial)material).setTexture(t);
Note: "Derived" is a memory manager (https://github.com/u-an-i/MemoryManagement), which is not the issue (i tried "new"ing the classes directly too), I don't even receive a status change signal, the file is a JPG and present at the location given.
Must I perhaps use a particular texture file format? If yes, which?