Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image Texture is not shown #7

Open
Tadinu opened this issue Nov 3, 2020 · 0 comments
Open

Image Texture is not shown #7

Tadinu opened this issue Nov 3, 2020 · 0 comments

Comments

@Tadinu
Copy link

Tadinu commented Nov 3, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant