Skip to content

Image Texture is not shown #7

@Tadinu

Description

@Tadinu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions