Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. 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)
Qt 6.11 is out! See what's new in the release blog

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)

Scheduled Pinned Locked Moved Solved Game Development
2 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • uaniU Offline
    uaniU Offline
    uani
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • uaniU Offline
      uaniU Offline
      uani
      wrote on last edited by uani
      #2

      my bad:

      ((Qt3DExtras::QTextureMaterial)material).setTexture(t);
      

      should have been

      ((Qt3DExtras::QTextureMaterial*)material)->setTexture(t);
      

      :facepalm:

      i'm sorry for bothering you.

      However the "status changed" signal i'm still not receiving.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved