Nadrin / Quartz

Vulkan RTX path tracer with a declarative ES7-like scene description language.
GNU Lesser General Public License v3.0
435 stars 23 forks source link

Image Texture is not shown #7

Open Tadinu opened 3 years ago

Tadinu commented 3 years ago

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.