[Interest] Qt3D, custom mesh and materials

Sean Harmer sean.harmer at kdab.com
Fri Apr 7 13:21:19 CEST 2017


For completeness, this was due to missing tangent vectors in the custom 
geometry. Tangents are required for normal mapping materials.

Cheers,

Sean

On 05/04/2017 17:34, Helmut Mülner wrote:
> Another question for the Qt3D experts:
>
> I created a custom mesh by defining the following attributes: position,
> normal, index, texCoord.
> If I use a PhongMaterial, the mesh displays nicely:
>
>         auto material = new Qt3DExtras::QPhongMaterial();
>         material->setAmbient(QColor(85, 85, 128));
>         material->setDiffuse(QColor(128, 128, 192));
>         material->setSpecular(QColor(170, 170, 255));
>         entity->addComponent(mesh);
>         entity->addComponent(material);
>
> If I use a QDiffuseMapMaterial, the mesh is black and I get a lot of the
> same messages in the debug output:
>
> [Qt3DRender::GLTexture] No QTextureImageData generated from functor
>
> Code:
>         auto material = new Qt3DExtras::QDiffuseMapMaterial();
>         material->setShininess(70.0f);
>         material->setAmbient(QColor(85, 85, 128));
>         material->setSpecular(QColor(170, 170, 255));
>
>         Qt3DRender::QTextureImage *diffuseImage = new
> Qt3DRender::QTextureImage();
>         diffuseImage->setSource(QUrl(QStringLiteral(":/diffuse.webp")));
>         material->diffuse()->addTextureImage(diffuseImage);
>         entity->addComponent(mesh);
>         entity->addComponent(material);
>
>
> And if I use this:
>         auto material = new Qt3DExtras::QNormalDiffuseMapMaterial();
>         material->setShininess(70.0f);
>         material->setAmbient(QColor(85, 85, 128));
>         material->setSpecular(QColor(170, 170, 255));
>
>         Qt3DRender::QTextureImage *diffuseImage = new
> Qt3DRender::QTextureImage();
>         diffuseImage->setSource(QUrl(QStringLiteral(":/diffuse.webp")));
>         material->diffuse()->addTextureImage(diffuseImage);
>         Qt3DRender::QTextureImage *normalImage = new
> Qt3DRender::QTextureImage();
>         normalImage->setSource(QUrl((QStringLiteral(":/normal.webp"))));
>         material->normal()->addTextureImage(normalImage);
>         entity->addComponent(mesh);
>         entity->addComponent(material);
>
> ... my mesh displays in simple dark blue and I get the same debug messages.
>
> (I burrowed the texture images from the materials-cpp sample.)
>
> What did I miss?
>
> Best regards
>
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>

-- 
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
KDAB (UK) Ltd, a KDAB Group company
Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
Mobile: +44 (0)7545 140604
KDAB - Qt Experts



More information about the Interest mailing list