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

I can't load Texture with QVariant in QMetalRoughMaterial ? Qt 5.15.0 #7

Open
maouache opened this issue Aug 23, 2020 · 3 comments
Open

Comments

@maouache
Copy link

hello,

I tried to use QMetalRoughMaterial for my cube to see how it's work. i saw the example in QML and i tried to translate it in C++ code That's it :

Qt3DExtras::QMorphPhongMaterial *mat {new Qt3DExtras::QMorphPhongMaterial(this)}; mat->baseColor().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_col.jpg"))); mat->metalness().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_met.jpg"))); mat->roughness().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_rgh.jpg"))); mat->normal().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_nrm.jpg"))); mat->ambientOcclusion().setValue(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_disp.jpg")));

Not Working, so I say to go the documentation to see how the methods work, the properties are Qvariant type. I looked how to do, QVariant :: FromValue() it does not work either.

My question is how to get textures through qvariant or QAbsractTexture ?

Please i need help ???

@lemirep
Copy link
Contributor

lemirep commented Aug 24, 2020

You have to first load the texture and then pass it on the material.
Something like:
QMetalRoughMaterial *mat = new QMetalRoughMaterial(); Qt3DRender::QTextureLoader *textureLoader = new Qt3DRender::QTextureLoader(); textureLoader->setSource(QUrl(QStringLiteral("qrc:/texture/metal/Metal03_col.jpg")); mat->baseColor().setValue(QVariant::fromValue(textureLoader));

@maouache
Copy link
Author

sorry but is not work. i used just the example of Qt basicshapes-cpp and i added your code by replace it into sphere material, and the result is this:

image

the code is here:

Qt3DExtras::QMetalRoughMaterial *mat = new Qt3DExtras::QMetalRoughMaterial(); Qt3DRender::QTextureLoader *textureLoader = new Qt3DRender::QTextureLoader(); textureLoader->setSource(QUrl(QStringLiteral("qrc:/texture/Rock035_2K_Color.jpg"))); mat->baseColor().setValue(QVariant::fromValue(textureLoader));

I noticed this message in execution:
QObject::connect(QOpenGLContext, Unknown): invalid nullptr parameter QString::arg: Argument missing: " Max Work Group Size: 1024, 1024, 64\n Max Work Group Count: 65535, 65535, 65535\n Max Invocations: 65535\n Max Shared Memory Size: 1024\n" , 32768

i was thinking if I reduced the size of the images, maybe is gonna work , but nothing

PS: the material that i used is this : https://cc0textures.com/view?id=Rock035

@maouache
Copy link
Author

@lemirep your code is not working

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

2 participants