Fix the 3D model rendering issue after the KHR_texture_transform extension support 54/304054/2
authorRichard Huang <r.huang@samsung.com>
Tue, 9 Jan 2024 16:26:24 +0000 (16:26 +0000)
committerRichard Huang <r.huang@samsung.com>
Tue, 9 Jan 2024 16:31:06 +0000 (16:31 +0000)
Change-Id: I659fa20f8f18e6f6765c70c9c9ef031dd7e18ccb

dali-scene3d/internal/graphics/shaders/default-physically-based-shader.vert
dali-scene3d/internal/model-components/material-impl.cpp
dali-scene3d/public-api/loader/material-definition.cpp
dali-scene3d/public-api/loader/node-definition.cpp

index fc0bff7ad772067dc61290383c522990fc04fefd..f88caf507650a4cae806ea72cc90ea77eabf6a48 100644 (file)
@@ -63,7 +63,7 @@ uniform mediump vec3 uYDirection;
 #endif
 
 #ifdef MORPH
-#define MAX_BLEND_SHAPE_NUMBER 128
+#define MAX_BLEND_SHAPE_NUMBER 256
 uniform int uNumberOfBlendShapes;                                         ///< Total number of blend shapes loaded.
 uniform highp float uBlendShapeWeight[MAX_BLEND_SHAPE_NUMBER];            ///< The weight of each blend shape.
 #ifdef MORPH_VERSION_2_0
index 0eb6213b7b2147bbca230f323df8ee696896d295..3b35ffdcee98d275919a125946218e06d0c159f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -702,6 +702,13 @@ void Material::SetRendererUniform(Dali::Renderer renderer)
   renderer.RegisterProperty("uOcclusionTextureTransformAvailable", 0.0f);
   renderer.RegisterProperty("uEmissiveTextureTransformAvailable", 0.0f);
 
+  renderer.RegisterProperty("uBaseColorTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uNormalRoughnessTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uNormalTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uMetalRoughnessTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uOcclusionTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uEmissiveTextureTransform", Matrix3::IDENTITY);
+
   float opaque = mIsOpaque ? 1.0f : 0.0f;
   float mask   = mIsMask ? 1.0f : 0.0f;
   renderer.RegisterProperty("uOpaque", opaque);
index eb83f23aadd873509760c66873981e6f7d146243..52028bf026a2a2df149b98a88d79fdb0eb123bf5 100644 (file)
@@ -35,7 +35,7 @@ namespace Scene3D
 {
 namespace Loader
 {
-const Matrix3 TextureDefinition::DEFAULT_TRANSFORM = Matrix3(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
+const Matrix3 TextureDefinition::DEFAULT_TRANSFORM = Matrix3::IDENTITY;
 
 namespace
 {
index 218969bf6a268ad17bca92436e02cbf56890bc3a..013b4f3621f58fdd63a9247f88be3424d8de6eb4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -357,6 +357,13 @@ void ModelRenderable::OnCreate(const NodeDefinition& nodeDefinition, NodeDefinit
   renderer.RegisterProperty("uOcclusionTextureTransformAvailable", 0.0f);
   renderer.RegisterProperty("uEmissiveTextureTransformAvailable", 0.0f);
 
+  renderer.RegisterProperty("uBaseColorTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uNormalRoughnessTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uNormalTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uMetalRoughnessTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uOcclusionTextureTransform", Matrix3::IDENTITY);
+  renderer.RegisterProperty("uEmissiveTextureTransform", Matrix3::IDENTITY);
+
   auto iTexture   = matDef.mTextureStages.begin();
   auto checkStage = [&](uint32_t flags) {
     return iTexture != matDef.mTextureStages.end() && MaskMatch(iTexture->mSemantic, flags);
@@ -364,48 +371,48 @@ void ModelRenderable::OnCreate(const NodeDefinition& nodeDefinition, NodeDefinit
 
   if(checkStage(MaterialDefinition::ALBEDO | MaterialDefinition::METALLIC))
   {
-    renderer.RegisterProperty("uBaseColorTextureTransformAvailable", 1.0f);
+    renderer.RegisterProperty("uBaseColorTextureTransformAvailable", iTexture->mTexture.mTransform != Matrix3::IDENTITY);
     renderer.RegisterProperty("uBaseColorTextureTransform", iTexture->mTexture.mTransform);
     ++iTexture;
 
     if(checkStage(MaterialDefinition::NORMAL | MaterialDefinition::ROUGHNESS))
     {
-      renderer.RegisterProperty("uNormalRoughnessTextureTransformAvailable", 1.0f);
+      renderer.RegisterProperty("uNormalRoughnessTextureTransformAvailable", iTexture->mTexture.mTransform != Matrix3::IDENTITY);
       renderer.RegisterProperty("uNormalRoughnessTextureTransform", iTexture->mTexture.mTransform);
       ++iTexture;
     }
   }
   else if(checkStage(MaterialDefinition::ALBEDO))
   {
-    renderer.RegisterProperty("uBaseColorTextureTransformAvailable", 1.0f);
+    renderer.RegisterProperty("uBaseColorTextureTransformAvailable", iTexture->mTexture.mTransform != Matrix3::IDENTITY);
     renderer.RegisterProperty("uBaseColorTextureTransform", iTexture->mTexture.mTransform);
     ++iTexture;
   }
 
   if(checkStage(MaterialDefinition::METALLIC | MaterialDefinition::ROUGHNESS))
   {
-    renderer.RegisterProperty("uMetalRoughnessTextureTransformAvailable", 1.0f);
+    renderer.RegisterProperty("uMetalRoughnessTextureTransformAvailable", iTexture->mTexture.mTransform != Matrix3::IDENTITY);
     renderer.RegisterProperty("uMetalRoughnessTextureTransform", iTexture->mTexture.mTransform);
     ++iTexture;
   }
 
   if(checkStage(MaterialDefinition::NORMAL))
   {
-    renderer.RegisterProperty("uNormalTextureTransformAvailable", 1.0f);
+    renderer.RegisterProperty("uNormalTextureTransformAvailable", iTexture->mTexture.mTransform != Matrix3::IDENTITY);
     renderer.RegisterProperty("uNormalTextureTransform", iTexture->mTexture.mTransform);
     ++iTexture;
   }
 
   if(checkStage(MaterialDefinition::OCCLUSION))
   {
-    renderer.RegisterProperty("uOcclusionTextureTransformAvailable", 1.0f);
+    renderer.RegisterProperty("uOcclusionTextureTransformAvailable", iTexture->mTexture.mTransform != Matrix3::IDENTITY);
     renderer.RegisterProperty("uOcclusionTextureTransform", iTexture->mTexture.mTransform);
     ++iTexture;
   }
 
   if(checkStage(MaterialDefinition::EMISSIVE))
   {
-    renderer.RegisterProperty("uEmissiveTextureTransformAvailable", 1.0f);
+    renderer.RegisterProperty("uEmissiveTextureTransformAvailable", iTexture->mTexture.mTransform != Matrix3::IDENTITY);
     renderer.RegisterProperty("uEmissiveTextureTransform", iTexture->mTexture.mTransform);
     ++iTexture;
   }