qt5pngentityqt3dskybox

How to properly use QSkyBoxEntity?


I looked everywhere, but there are not any guides or explanations of how to use QSkyBoxEntity.

I created Entity and filled it with transform (set translation and 3d scale). Also changed name and extension.

When I'm trying to run program it says

"Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit for "skyboxTexture""

I checked several times and tried different png files but no luck.
My image
(I know it's fake transparency, but it shouldn't change anything, right?)

And here's part of a code:

Qt3DCore::QEntity *resultEntity = new Qt3DCore::QEntity;

    Qt3DExtras::QSkyboxEntity *skyboxEntity = new Qt3DExtras::QSkyboxEntity(resultEntity);
    skyboxEntity->setBaseName("skybox"); //I tried using path as well
    skyboxEntity->setExtension("png");

    Qt3DCore::QTransform *skyTransform = new Qt3DCore::QTransform(skyboxEntity);
    skyTransform->setTranslation(QVector3D(0.0f,0.0f,0.0f));
    skyTransform->setScale3D(QVector3D(0.1f,0.1f,0.1f));

    skyboxEntity->addComponent(skyTransform);

Solution

  • It's important to properly name files in order for skybox to work and use resource file for storing.

    I recommend .tga, but other formats should work as well.

    You can read about it here: https://doc.qt.io/qt-6/qml-qt3d-extras-skyboxentity.html

    And here's example how it should look