Quartz icon indicating copy to clipboard operation
Quartz copied to clipboard

Image Texture is not shown

Open Tadinu opened this issue 5 years ago • 0 comments

Hi @Nadrin,

So I've managed to run your raytrace-cpp example and also tried using QMaterial::setAlbedoTexture/setRoughnessTexture/setMetalnessTexture(QAbstractTexture *texture) as follows:

QAbstractTexture* QMaterial::createTexture(const QString& textureFilePath)
{
    auto* texture = new Qt3DRaytrace::QAbstractTexture(this);
    auto* textureImage = new Qt3DRaytrace::QTextureImage(texture);

    QImage image;
    image.load(textureFilePath);
    QByteArray arr;
    QDataStream ds(&arr, QIODevice::ReadWrite);
    ds.writeRawData((const char*)image.bits(), image.sizeInBytes());

    Qt3DRaytrace::QImageData imageData;
    imageData.format = Qt3DRaytrace::QImageData::Format::RGBA;
    imageData.width = 854;
    imageData.height = 854;
    imageData.channels = 4;
    imageData.type = Qt3DRaytrace::QImageData::ValueType::Float16;
    imageData.data = arr;
    textureImage->setData(imageData);

    return texture;
}

void QMaterial::setAlbedoTexture(const QString& textureFilePath)
{
    setAlbedoTexture(createTexture(textureFilePath));
}

However, I could not see them be reflected on the mesh. Do you happen to have an example using those APIs?

By the way, I also printed out member values of imageData fetched in UploadTextureJob::run() and they are correct, which means the image has been loaded and ready to be uploaded to GPU.

Thank you.

Tadinu avatar Nov 03 '20 08:11 Tadinu