[Tizen] Let we use integer uniform for shader 92/296892/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 30 May 2023 03:54:26 +0000 (12:54 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Wed, 23 Aug 2023 04:50:18 +0000 (13:50 +0900)
Since we cannot believe float to integer convertor,
Let we use integer uniform value register without float conversion

Change-Id: Idf740687b51b73a00db77eb4a784f0acef73f5df
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali-scene3d/internal/graphics/shaders/default-physically-based-shader.vert
dali-scene3d/public-api/loader/blend-shape-details.cpp

index 8ca91ea..d57d974 100644 (file)
@@ -46,14 +46,14 @@ uniform mat4 uProjection;
 
 #ifdef MORPH
 #define MAX_BLEND_SHAPE_NUMBER 128
-uniform float uNumberOfBlendShapes;                                       ///< Total number of blend shapes loaded.
+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
 uniform highp float uBlendShapeUnnormalizeFactor;                         ///< Factor used to unnormalize the geometry of the blend shape.
 #else
 uniform highp float uBlendShapeUnnormalizeFactor[MAX_BLEND_SHAPE_NUMBER]; ///< Factor used to unnormalize the geometry of the blend shape.
 #endif
-uniform highp float uBlendShapeComponentSize;                             ///< The size in the texture of either the vertices, normals or tangents. Used to calculate the offset to address them.
+uniform highp int uBlendShapeComponentSize;                               ///< The size in the texture of either the vertices, normals or tangents. Used to calculate the offset to address them.
 #endif
 
 void main()
@@ -66,10 +66,8 @@ void main()
   int width = textureSize( sBlendShapeGeometry, 0 ).x;
 
   highp int blendShapeBufferOffset = 0;
-  highp int blendShapeComponentSize = int(uBlendShapeComponentSize);
-  int numberOfBlendShapes = int(uNumberOfBlendShapes);
 
-  for( int index = 0; index < numberOfBlendShapes; ++index )
+  for( int index = 0; index < uNumberOfBlendShapes; ++index )
   {
     highp vec3 diff = vec3(0.0);
     highp int vertexId = 0;
@@ -96,12 +94,12 @@ void main()
 
     position.xyz += diff;
 
-    blendShapeBufferOffset += blendShapeComponentSize;
+    blendShapeBufferOffset += uBlendShapeComponentSize;
 #endif
 
 #ifdef MORPH_NORMAL
     // Calculate the index to retrieve the normal from the texture.
-    vertexId = gl_VertexID + int(blendShapeBufferOffset);
+    vertexId = gl_VertexID + blendShapeBufferOffset;
     x = vertexId % width;
     y = vertexId / width;
 
@@ -113,7 +111,7 @@ void main()
 
     normal += diff.xyz;
 
-    blendShapeBufferOffset += blendShapeComponentSize;
+    blendShapeBufferOffset += uBlendShapeComponentSize;
 #endif
 
 #ifdef MORPH_TANGENT
@@ -130,7 +128,7 @@ void main()
 
     tangent += diff.xyz;
 
-    blendShapeBufferOffset += blendShapeComponentSize;
+    blendShapeBufferOffset += uBlendShapeComponentSize;
 #endif
   }
 
index f854fa7..7c947f8 100644 (file)
@@ -38,7 +38,7 @@ const char* BlendShapes::WEIGHTS_UNIFORM("uBlendShapeWeight");
 
 void BlendShapes::ConfigureProperties(const BlendShapeData& data, Renderer renderer)
 {
-  unsigned int index = 0u;
+  uint32_t index = 0u;
 
   char        weightNameBuffer[32];
   char        unnormalizeFactorNameBuffer[64];
@@ -71,8 +71,8 @@ void BlendShapes::ConfigureProperties(const BlendShapeData& data, Renderer rende
       renderer.RegisterProperty(UNNORMALIZE_FACTOR, data.unnormalizeFactors[0u]);
     }
 
-    renderer.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast<float>(index)));
-    renderer.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast<float>(data.bufferOffset)));
+    renderer.RegisterProperty(NUMBER_OF_BLEND_SHAPES, Property::Value(static_cast<int32_t>(index)));
+    renderer.RegisterProperty(COMPONENT_SIZE, Property::Value(static_cast<int32_t>(data.bufferOffset)));
 
     // Create a read only property to preserve the components of the blend shape.
     renderer.RegisterProperty(COMPONENTS, data.components, Property::AccessMode::READ_ONLY);