Qt 6.2.0, Qt3D. The COLLADA DAE model is darker than OBJ
Unsolved
Game Development
-
Hello,
I am glad that the bug with loading COLLADA DAE files was fixed in Qt 6. But I have a strange problem: the COLLADA DAE model is darker than OBJ.
I created this cube in Blender 2.93:
With OBJ it works fine:
But when I export to DAE I see that the model is darker:
.pro
QT += 3dcore 3dlogic 3dextras 3dinput
main.cpp
#ifdef _WIN32 #include <windows.h> extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001; #endif #include <QtCore/QDebug> #include <QtGui/QGuiApplication> #include <Qt3DExtras/Qt3DWindow> #include <Qt3DExtras/QCuboidMesh> #include <Qt3DExtras/QPhongMaterial> #include <Qt3DExtras/QOrbitCameraController> #include <Qt3DCore/QEntity> #include <Qt3DCore/QTransform> #include <Qt3DRender/QCamera> #include <Qt3DRender/QPointLight> #include <Qt3DRender/QSceneLoader> class Window : public Qt3DExtras::Qt3DWindow { public: Window() { setTitle("COLLADA DAE 3D model"); resize(400, 400); Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity(); // Lighting Qt3DCore::QEntity *lightEntity = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QPointLight *pointLight = new Qt3DRender::QPointLight(lightEntity); Qt3DCore::QTransform *lightTransform = new Qt3DCore::QTransform(lightEntity); lightTransform->setTranslation(QVector3D(20.f, 25.f, 30.f)); lightEntity->addComponent(pointLight); lightEntity->addComponent(lightTransform); // 3D Model Qt3DCore::QEntity *objectEntity = new Qt3DCore::QEntity(rootEntity); Qt3DRender::QSceneLoader *sceneLoader = new Qt3DRender::QSceneLoader(objectEntity); // sceneLoader->setSource(QUrl("qrc:/Models/Cube.obj")); sceneLoader->setSource(QUrl("qrc:/Models/Cube.dae")); objectEntity->addComponent(sceneLoader); Qt3DCore::QTransform *objectTransform = new Qt3DCore::QTransform(objectEntity); objectTransform->setScale(10.f); objectEntity->addComponent(objectTransform); // Camera Qt3DRender::QCamera *camera = this->camera(); camera->lens()->setPerspectiveProjection( 60.f, (float) this->width() / this->height(), 0.1f, 500.0f); camera->setPosition(QVector3D(30.0f, 30.0f, 30.f)); camera->setViewCenter(QVector3D(0.f, 0.f, 0.f)); Qt3DExtras::QOrbitCameraController *cameraController = new Qt3DExtras::QOrbitCameraController(rootEntity); cameraController->setCamera(camera); cameraController->setLookSpeed(180.f); cameraController->setLinearSpeed(50.f); this->setRootEntity(rootEntity); } }; int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); Window w; w.show(); return app.exec(); }
-
Hi,
You should provide the model files as well so that people can test it.
-
Cube.dae
<?xml version="1.0" encoding="utf-8"?> <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1"> <asset> <contributor> <author>Blender User</author> <authoring_tool>Blender 2.76.0 commit date:2015-10-11, commit time:06:55, hash:48f7dd6</authoring_tool> </contributor> <created>2020-12-10T01:55:11</created> <modified>2020-12-10T01:55:11</modified> <unit name="meter" meter="1"/> <up_axis>Z_UP</up_axis> </asset> <library_images/> <library_effects> <effect id="BackgoundMaterial-effect"> <profile_COMMON> <technique sid="common"> <phong> <emission> <color sid="emission">0 0 0 1</color> </emission> <ambient> <color sid="ambient">0 0 0 1</color> </ambient> <diffuse> <color sid="diffuse">0.07052612 0.64 0.02013014 1</color> </diffuse> <specular> <color sid="specular">0.5 0.5 0.5 1</color> </specular> <shininess> <float sid="shininess">50</float> </shininess> <index_of_refraction> <float sid="index_of_refraction">1</float> </index_of_refraction> </phong> </technique> </profile_COMMON> </effect> <effect id="SideMaterial-effect"> <profile_COMMON> <technique sid="common"> <phong> <emission> <color sid="emission">0 0 0 1</color> </emission> <ambient> <color sid="ambient">0 0 0 1</color> </ambient> <diffuse> <color sid="diffuse">0.64 0.06314375 0.129652 1</color> </diffuse> <specular> <color sid="specular">0.5 0.5 0.5 1</color> </specular> <shininess> <float sid="shininess">50</float> </shininess> <index_of_refraction> <float sid="index_of_refraction">1</float> </index_of_refraction> </phong> </technique> </profile_COMMON> </effect> </library_effects> <library_materials> <material id="BackgoundMaterial-material" name="BackgoundMaterial"> <instance_effect url="#BackgoundMaterial-effect"/> </material> <material id="SideMaterial-material" name="SideMaterial"> <instance_effect url="#SideMaterial-effect"/> </material> </library_materials> <library_geometries> <geometry id="Cube-mesh" name="Cube"> <mesh> <source id="Cube-mesh-positions"> <float_array id="Cube-mesh-positions-array" count="24">1 1 -1 1 -1 -1 -1 -0.9999998 -1 -0.9999997 1 -1 1 0.9999995 1 0.9999994 -1.000001 1 -1 -0.9999997 1 -1 1 1</float_array> <technique_common> <accessor source="#Cube-mesh-positions-array" count="8" stride="3"> <param name="X" type="float"/> <param name="Y" type="float"/> <param name="Z" type="float"/> </accessor> </technique_common> </source> <source id="Cube-mesh-normals"> <float_array id="Cube-mesh-normals-array" count="36">0 0 -1 0 0 1 1 -5.96046e-7 3.27825e-7 -4.76837e-7 -1 0 -1 2.38419e-7 -1.19209e-7 2.08616e-7 1 0 0 0 -1 0 0 1 1 0 -2.38419e-7 0 -1 -4.76837e-7 -1 2.38419e-7 -1.49012e-7 2.68221e-7 1 2.38419e-7</float_array> <technique_common> <accessor source="#Cube-mesh-normals-array" count="12" stride="3"> <param name="X" type="float"/> <param name="Y" type="float"/> <param name="Z" type="float"/> </accessor> </technique_common> </source> <vertices id="Cube-mesh-vertices"> <input semantic="POSITION" source="#Cube-mesh-positions"/> </vertices> <polylist material="BackgoundMaterial-material" count="10"> <input semantic="VERTEX" source="#Cube-mesh-vertices" offset="0"/> <input semantic="NORMAL" source="#Cube-mesh-normals" offset="1"/> <vcount>3 3 3 3 3 3 3 3 3 3 </vcount> <p>0 0 1 0 2 0 7 1 6 1 5 1 5 3 6 3 2 3 2 4 6 4 7 4 0 5 3 5 7 5 3 6 0 6 2 6 4 7 7 7 5 7 1 9 5 9 2 9 3 10 2 10 7 10 4 11 0 11 7 11</p> </polylist> <polylist material="SideMaterial-material" count="2"> <input semantic="VERTEX" source="#Cube-mesh-vertices" offset="0"/> <input semantic="NORMAL" source="#Cube-mesh-normals" offset="1"/> <vcount>3 3 </vcount> <p>4 2 5 2 1 2 0 8 4 8 1 8</p> </polylist> </mesh> </geometry> </library_geometries> <library_controllers/> <library_visual_scenes> <visual_scene id="Scene" name="Scene"> <node id="Cube" name="Cube" type="NODE"> <matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix> <instance_geometry url="#Cube-mesh" name="Cube"> <bind_material> <technique_common> <instance_material symbol="BackgoundMaterial-material" target="#BackgoundMaterial-material"/> <instance_material symbol="SideMaterial-material" target="#SideMaterial-material"/> </technique_common> </bind_material> </instance_geometry> </node> </visual_scene> </library_visual_scenes> <scene> <instance_visual_scene url="#Scene"/> </scene> </COLLADA>
Cube.obj
# Blender v2.93.5 OBJ File: '' # www.blender.org mtllib Cube.mtl o Cube_Cube.001 v 1.000000 -1.000000 -1.000000 v 1.000000 -1.000000 1.000000 v -1.000000 -1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -1.000000 v 0.999999 1.000000 1.000001 v -1.000000 1.000000 1.000000 v -1.000000 1.000000 -1.000000 vn 0.0000 -1.0000 0.0000 vn 0.0000 1.0000 0.0000 vn -0.0000 0.0000 1.0000 vn -1.0000 -0.0000 0.0000 vn 0.0000 0.0000 -1.0000 vn 1.0000 0.0000 0.0000 usemtl BackgoundMaterial s off f 1//1 2//1 3//1 f 8//2 7//2 6//2 f 6//3 7//3 3//3 f 3//4 7//4 8//4 f 1//5 4//5 8//5 f 4//1 1//1 3//1 f 5//2 8//2 6//2 f 2//3 6//3 3//3 f 4//4 3//4 8//4 f 5//5 1//5 8//5 usemtl SideMaterial f 5//6 6//6 2//6 f 1//6 5//6 2//6
Cube.mtl
# Blender MTL File: 'None' # Material Count: 2 newmtl BackgoundMaterial Ns 225.000000 Ka 1.000000 1.000000 1.000000 Kd 0.070526 0.640000 0.020130 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 Ni 1.000000 d 1.000000 illum 2 newmtl SideMaterial Ns 225.000000 Ka 1.000000 1.000000 1.000000 Kd 0.640000 0.063144 0.129652 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 Ni 1.000000 d 1.000000 illum 2