Merge changes I776588c1,I7292a2fb into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-scene3d-internal / utc-Dali-Gltf2LoaderImpl.cpp
index 03d2f97..723c3ae 100644 (file)
@@ -22,7 +22,7 @@
 #include <dali-scene3d/public-api/loader/load-result.h>
 #include <dali-scene3d/public-api/loader/resource-bundle.h>
 #include <dali-scene3d/public-api/loader/scene-definition.h>
-#include <dali-scene3d/public-api/loader/shader-definition-factory.h>
+#include <dali-scene3d/public-api/loader/shader-manager.h>
 #include <dali-test-suite-utils.h>
 #include <string_view>
 
@@ -125,9 +125,6 @@ int UtcDaliGltfLoaderFailedToParse(void)
 {
   Context ctx;
 
-  ShaderDefinitionFactory sdf;
-  sdf.SetResources(ctx.resources);
-
   DALI_TEST_EQUAL(ctx.loader.LoadModel(TEST_RESOURCE_DIR "/invalid.gltf", ctx.loadResult), false);
 
   DALI_TEST_EQUAL(0, ctx.scene.GetRoots().size());
@@ -136,7 +133,6 @@ int UtcDaliGltfLoaderFailedToParse(void)
   DALI_TEST_EQUAL(0, ctx.resources.mEnvironmentMaps.size());
   DALI_TEST_EQUAL(0, ctx.resources.mMaterials.size());
   DALI_TEST_EQUAL(0, ctx.resources.mMeshes.size());
-  DALI_TEST_EQUAL(0, ctx.resources.mShaders.size());
   DALI_TEST_EQUAL(0, ctx.resources.mSkeletons.size());
 
   DALI_TEST_EQUAL(0, ctx.cameras.size());
@@ -193,7 +189,7 @@ int UtcDaliGltfLoaderSuccess1(void)
       nullptr,
       MaterialDefinition::ALBEDO | MaterialDefinition::EMISSIVE | MaterialDefinition::OCCLUSION |
         MaterialDefinition::NORMAL | MaterialDefinition::SPECULAR | MaterialDefinition::SPECULAR_COLOR |
-        (0x80 << MaterialDefinition::ALPHA_CUTOFF_SHIFT),
+        MaterialDefinition::GLTF_CHANNELS | (0x80 << MaterialDefinition::ALPHA_CUTOFF_SHIFT),
       0,
       Color::WHITE,
       1.f,
@@ -202,6 +198,7 @@ int UtcDaliGltfLoaderSuccess1(void)
       1.f,
       1.f,
       Vector3(0.2, 0.1, 0.0),
+      1.0f,
       0.0f,
       0.5f,
       Vector3(0, 0, 1),
@@ -209,6 +206,8 @@ int UtcDaliGltfLoaderSuccess1(void)
       false,
       true,
       false,
+      Scene3D::Material::AlphaModeType::MASK,
+      true,
       true,
       true,
       {
@@ -267,6 +266,7 @@ int UtcDaliGltfLoaderSuccess1(void)
           },
         },
       },
+      nullptr
     },
     {
       nullptr,
@@ -281,6 +281,7 @@ int UtcDaliGltfLoaderSuccess1(void)
       1.f,
       1.f,
       Vector3(0.2, 0.1, 0.0),
+      -1.0f,
       0.04f,
       1.0f,
       Vector3::ONE,
@@ -288,8 +289,10 @@ int UtcDaliGltfLoaderSuccess1(void)
       true,
       true,
       false,
+      Scene3D::Material::AlphaModeType::OPAQUE,
       true,
       false,
+      true,
       {
         {
           MaterialDefinition::ALBEDO,
@@ -301,7 +304,7 @@ int UtcDaliGltfLoaderSuccess1(void)
           },
         },
         {
-          MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS | MaterialDefinition::GLTF_CHANNELS,
+          MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS,
           {
             "AnimatedCube_MetallicRoughness.png",
             SamplerFlags::Encode(FilterMode::NEAREST_MIPMAP_LINEAR, FilterMode::NEAREST, WrapMode::CLAMP_TO_EDGE, WrapMode::MIRRORED_REPEAT),
@@ -337,6 +340,7 @@ int UtcDaliGltfLoaderSuccess1(void)
           },
         },
       },
+      nullptr,
     },
   };
 
@@ -355,12 +359,14 @@ int UtcDaliGltfLoaderSuccess1(void)
     DALI_TEST_EQUAL(md.mNormalScale, m.mNormalScale);
     DALI_TEST_EQUAL(md.mOcclusionStrength, m.mOcclusionStrength);
     DALI_TEST_EQUAL(md.mEmissiveFactor, m.mEmissiveFactor);
+    DALI_TEST_EQUAL(md.mIor, m.mIor);
     DALI_TEST_EQUAL(md.mDielectricSpecular, m.mDielectricSpecular);
     DALI_TEST_EQUAL(md.mSpecularFactor, m.mSpecularFactor);
     DALI_TEST_EQUAL(md.mSpecularColorFactor, m.mSpecularColorFactor);
     DALI_TEST_EQUAL(md.mNeedAlbedoTexture, m.mNeedAlbedoTexture);
     DALI_TEST_EQUAL(md.mNeedMetallicRoughnessTexture, m.mNeedMetallicRoughnessTexture);
     DALI_TEST_EQUAL(md.mNeedNormalTexture, m.mNeedNormalTexture);
+    DALI_TEST_EQUAL(md.mAlphaModeType, m.mAlphaModeType);
     DALI_TEST_EQUAL(md.mIsOpaque, m.mIsOpaque);
     DALI_TEST_EQUAL(md.mIsMask, m.mIsMask);
 
@@ -440,7 +446,6 @@ int UtcDaliGltfLoaderSuccess1(void)
     ++iMesh;
   }
 
-  DALI_TEST_EQUAL(2u, ctx.resources.mShaders.size());
   DALI_TEST_EQUAL(0u, ctx.resources.mSkeletons.size());
 
   DALI_TEST_EQUAL(6u, ctx.cameras.size());
@@ -454,8 +459,6 @@ int UtcDaliGltfLoaderSuccess1(void)
 int UtcDaliGltfLoaderSuccess2(void)
 {
   Context                 ctx;
-  ShaderDefinitionFactory sdf;
-  sdf.SetResources(ctx.resources);
 
   ctx.loader.LoadModel(TEST_RESOURCE_DIR "/AnimatedCubeStride.gltf", ctx.loadResult);
 
@@ -569,9 +572,6 @@ int UtcDaliGltfLoaderSuccessShort(void)
 int UtcDaliGltfLoaderMRendererTest(void)
 {
   Context ctx;
-
-  ShaderDefinitionFactory sdf;
-  sdf.SetResources(ctx.resources);
   auto& resources = ctx.resources;
 
   ctx.loader.LoadModel(TEST_RESOURCE_DIR "/MRendererTest.gltf", ctx.loadResult);
@@ -584,6 +584,7 @@ int UtcDaliGltfLoaderMRendererTest(void)
 
   DALI_TEST_EQUAL(scene.GetNodeCount(), 1u);
 
+  Scene3D::Loader::ShaderManagerPtr shaderManager = new Scene3D::Loader::ShaderManager();
   ViewProjection viewProjection;
   Transforms     xforms{
     MatrixStack{},
@@ -591,6 +592,7 @@ int UtcDaliGltfLoaderMRendererTest(void)
   NodeDefinition::CreateParams nodeParams{
     resources,
     xforms,
+    shaderManager,
   };
 
   Customization::Choices choices;
@@ -608,7 +610,6 @@ int UtcDaliGltfLoaderMRendererTest(void)
     ctx.resources.LoadResources(ctx.pathProvider);
     if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))
     {
-      scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor);
       scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));
       scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));
       root.Add(actor);
@@ -621,7 +622,7 @@ int UtcDaliGltfLoaderMRendererTest(void)
   DALI_TEST_EQUAL(child.GetProperty(Actor::Property::NAME).Get<std::string>(), "RootNode");
   DALI_TEST_EQUAL(child.GetProperty(Actor::Property::SCALE).Get<Vector3>(), Vector3(1.0f, 1.0f, 1.0f));
   DALI_TEST_EQUAL(child.GetRendererCount(), 1u);
-  DALI_TEST_EQUAL(child.GetRendererAt(0).GetTextures().GetTextureCount(), 4u);
+  DALI_TEST_EQUAL(child.GetRendererAt(0).GetTextures().GetTextureCount(), 5u);
 
   DALI_TEST_EQUAL(child.GetRendererCount(), 1u);
   DALI_TEST_EQUAL(child.GetRendererAt(0u).GetProperty<decltype(BlendMode::ON)>(Renderer::Property::BLEND_MODE), BlendMode::ON);
@@ -642,6 +643,7 @@ int UtcDaliGltfLoaderAnimationLoadingTest(void)
   auto& roots = scene.GetRoots();
   DALI_TEST_EQUAL(roots.size(), 1u);
 
+  Scene3D::Loader::ShaderManagerPtr shaderManager = new Scene3D::Loader::ShaderManager();
   ViewProjection viewProjection;
   Transforms     xforms{
     MatrixStack{},
@@ -649,6 +651,7 @@ int UtcDaliGltfLoaderAnimationLoadingTest(void)
   NodeDefinition::CreateParams nodeParams{
     resources,
     xforms,
+    shaderManager,
   };
 
   Customization::Choices choices;
@@ -664,7 +667,6 @@ int UtcDaliGltfLoaderAnimationLoadingTest(void)
     resources.LoadResources(ctx.pathProvider);
     if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))
     {
-      scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor);
       scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));
       scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));
       root.Add(actor);
@@ -672,9 +674,9 @@ int UtcDaliGltfLoaderAnimationLoadingTest(void)
   }
 
   DALI_TEST_EQUAL(ctx.loadResult.mAnimationDefinitions.size(), 1u);
-  DALI_TEST_EQUAL(ctx.loadResult.mAnimationDefinitions[0].mProperties.size(), 57u);
+  DALI_TEST_EQUAL(ctx.loadResult.mAnimationDefinitions[0].GetPropertyCount(), 57u);
 
-  uint32_t id = ctx.loadResult.mScene.GetNode(ctx.loadResult.mAnimationDefinitions[0].mProperties[0].mNodeIndex)->mNodeId;
+  uint32_t id = ctx.loadResult.mScene.GetNode(ctx.loadResult.mAnimationDefinitions[0].GetPropertyAt(0).mNodeIndex)->mNodeId;
   DALI_TEST_EQUAL(id, root.FindChildByName("Skeleton_torso_joint_1").GetProperty<int32_t>(Dali::Actor::Property::ID));
 
   END_TEST;
@@ -684,8 +686,6 @@ int UtcDaliGltfLoaderImageFromBufferView(void)
 {
   Context ctx;
 
-  ShaderDefinitionFactory sdf;
-  sdf.SetResources(ctx.resources);
   auto& resources = ctx.resources;
 
   ctx.loader.LoadModel(TEST_RESOURCE_DIR "/EnvironmentTest_b.gltf", ctx.loadResult);
@@ -694,6 +694,7 @@ int UtcDaliGltfLoaderImageFromBufferView(void)
   auto& roots = scene.GetRoots();
   DALI_TEST_EQUAL(roots.size(), 1u);
 
+  Scene3D::Loader::ShaderManagerPtr shaderManager = new Scene3D::Loader::ShaderManager();
   ViewProjection viewProjection;
   Transforms     xforms{
     MatrixStack{},
@@ -701,6 +702,7 @@ int UtcDaliGltfLoaderImageFromBufferView(void)
   NodeDefinition::CreateParams nodeParams{
     resources,
     xforms,
+    shaderManager,
   };
 
   Customization::Choices choices;
@@ -718,7 +720,6 @@ int UtcDaliGltfLoaderImageFromBufferView(void)
     resources.LoadResources(ctx.pathProvider);
     if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))
     {
-      scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor);
       scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));
       scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));
       root.Add(actor);
@@ -744,6 +745,7 @@ int UtcDaliGltfLoaderUint8Indices(void)
   auto& roots = scene.GetRoots();
   DALI_TEST_EQUAL(roots.size(), 1u);
 
+  Scene3D::Loader::ShaderManagerPtr shaderManager = new Scene3D::Loader::ShaderManager();
   ViewProjection viewProjection;
   Transforms     xforms{
     MatrixStack{},
@@ -751,6 +753,7 @@ int UtcDaliGltfLoaderUint8Indices(void)
   NodeDefinition::CreateParams nodeParams{
     resources,
     xforms,
+    shaderManager,
   };
 
   Customization::Choices choices;
@@ -768,7 +771,6 @@ int UtcDaliGltfLoaderUint8Indices(void)
     resources.LoadResources(ctx.pathProvider);
     if(auto actor = scene.CreateNodes(iRoot, choices, nodeParams))
     {
-      scene.ConfigureSkeletonJoints(iRoot, resources.mSkeletons, actor);
       scene.ConfigureSkinningShaders(resources, actor, std::move(nodeParams.mSkinnables));
       scene.ApplyConstraints(actor, std::move(nodeParams.mConstrainables));
       root.Add(actor);