Blendshape properties should be registered per renderer instead of per shader 43/292143/1
authorRichard <r.huang@samsung.com>
Thu, 27 Apr 2023 15:47:58 +0000 (16:47 +0100)
committerRichard <r.huang@samsung.com>
Thu, 27 Apr 2023 15:47:58 +0000 (16:47 +0100)
Change-Id: I38c6a191e37212720fa603f82cb2ef04c6b18a17

dali-scene3d/internal/model-components/model-primitive-impl.cpp
dali-scene3d/public-api/loader/blend-shape-details.cpp
dali-scene3d/public-api/loader/blend-shape-details.h

index 4dbb047..b4f2b17 100644 (file)
@@ -19,9 +19,9 @@
 #include <dali-scene3d/internal/model-components/model-primitive-impl.h>
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/image-loading.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/adaptor-framework/image-loading.h>
 
 // INTERNAL INCLUDES
 #include <dali-scene3d/internal/model-components/material-impl.h>
@@ -178,7 +178,7 @@ void ModelPrimitive::SetImageBasedLightScaleFactor(float iblScaleFactor)
 void ModelPrimitive::SetBlendShapeData(Scene3D::Loader::BlendShapes::BlendShapeData& data)
 {
   mBlendShapeData = std::move(data);
-  Scene3D::Loader::BlendShapes::ConfigureProperties(mBlendShapeData, mShader);
+  Scene3D::Loader::BlendShapes::ConfigureProperties(mBlendShapeData, mRenderer);
 }
 
 void ModelPrimitive::SetBlendShapeGeometry(Dali::Texture blendShapeGeometry)
@@ -248,7 +248,7 @@ void ModelPrimitive::ApplyMaterialToRenderer(MaterialModifyObserver::ModifyFlag
     mShader = Shader::New(vertexShader, fragmentShader);
     if(mBlendShapeData.version != Scene3D::Loader::BlendShapes::Version::INVALID && mBlendShapeData.mActor.GetHandle())
     {
-      Scene3D::Loader::BlendShapes::ConfigureProperties(mBlendShapeData, mShader);
+      Scene3D::Loader::BlendShapes::ConfigureProperties(mBlendShapeData, mRenderer);
     }
 
     if(!mRenderer)
@@ -383,7 +383,7 @@ void ModelPrimitive::UpdateImageBasedLightTexture()
 
       mRenderer.SetTextures(newTextures);
     }
-    mRenderer.RegisterProperty(GetImplementation(mMaterial).GetImageBasedLightScaleFactorName() .data(), mIblScaleFactor);
+    mRenderer.RegisterProperty(GetImplementation(mMaterial).GetImageBasedLightScaleFactorName().data(), mIblScaleFactor);
     mRenderer.RegisterProperty(GetImplementation(mMaterial).GetImageBasedLightMaxLodUniformName().data(), static_cast<float>(mSpecularMipmapLevels));
   }
 }
index 4cf288c..f854fa7 100644 (file)
@@ -36,7 +36,7 @@ const char* BlendShapes::COMPONENTS("blendShapeComponents");
 
 const char* BlendShapes::WEIGHTS_UNIFORM("uBlendShapeWeight");
 
-void BlendShapes::ConfigureProperties(const BlendShapeData& data, Shader shader)
+void BlendShapes::ConfigureProperties(const BlendShapeData& data, Renderer renderer)
 {
   unsigned int index = 0u;
 
@@ -54,28 +54,28 @@ void BlendShapes::ConfigureProperties(const BlendShapeData& data, Shader shader)
       actor.RegisterProperty(weightName, weight);
     }
 
-    if(shader && data.version == Version::VERSION_1_0)
+    if(renderer && data.version == Version::VERSION_1_0)
     {
       snprintf(pFactorName, sizeof(unnormalizeFactorNameBuffer) - (pFactorName - unnormalizeFactorNameBuffer), "[%d]", index);
       std::string factorName{unnormalizeFactorNameBuffer};
-      shader.RegisterProperty(factorName, data.unnormalizeFactors[index]);
+      renderer.RegisterProperty(factorName, data.unnormalizeFactors[index]);
     }
 
     ++index;
   }
 
-  if(shader)
+  if(renderer)
   {
     if(Version::VERSION_2_0 == data.version)
     {
-      shader.RegisterProperty(UNNORMALIZE_FACTOR, data.unnormalizeFactors[0u]);
+      renderer.RegisterProperty(UNNORMALIZE_FACTOR, data.unnormalizeFactors[0u]);
     }
 
-    shader.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast<float>(index)));
-    shader.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast<float>(data.bufferOffset)));
+    renderer.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast<float>(index)));
+    renderer.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast<float>(data.bufferOffset)));
 
     // Create a read only property to preserve the components of the blend shape.
-    shader.RegisterProperty(COMPONENTS, data.components, Property::AccessMode::READ_ONLY);
+    renderer.RegisterProperty(COMPONENTS, data.components, Property::AccessMode::READ_ONLY);
   }
 }
 
index 2b304d6..e7d2eb4 100644 (file)
@@ -74,9 +74,9 @@ struct DALI_SCENE3D_API BlendShapes
 
   /**
    * @brief Registers properties based on the mesh definition (and geometry) and identified by the above string constants,
-   *  on the given @a shader and @a actor.
+   *  on the given @a renderer and @a actor.
    */
-  static void ConfigureProperties(const BlendShapeData& data, Shader shader);
+  static void ConfigureProperties(const BlendShapeData& data, Renderer renderer);
 
   BlendShapes() = delete;
 };