Ensure blendshape weight between [0..1] 22/300422/1
authorEunki Hong <eunkiki.hong@samsung.com>
Tue, 24 Oct 2023 14:05:43 +0000 (23:05 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Tue, 24 Oct 2023 14:05:43 +0000 (23:05 +0900)
Let we ensure the blendshape weight is between 0 and 1.
So ignore cases when weight value is bigger than 1, less than 0.

Change-Id: I3bdd0a3f59498654e6e7ac65a4a2e665a58a9fcc
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
dali-scene3d/internal/graphics/shaders/default-physically-based-shader.vert

index 6f637ed..a63addb 100644 (file)
@@ -80,6 +80,7 @@ void main()
     highp int vertexId = 0;
     highp int x = 0;
     highp int y = 0;
+    highp float weight = clamp(uBlendShapeWeight[index], 0.0, 1.0);
 
 #ifdef MORPH_POSITION
     // Calculate the index to retrieve the geometry from the texture.
@@ -88,7 +89,7 @@ void main()
     y = vertexId / width;
 
     // Retrieves the blend shape geometry from the texture, unnormalizes it and multiply by the weight.
-    if( 0.0 != uBlendShapeWeight[index] )
+    if(0.0 != weight)
     {
 #ifdef MORPH_VERSION_2_0
        highp float unnormalizeFactor = uBlendShapeUnnormalizeFactor;
@@ -96,7 +97,7 @@ void main()
        highp float unnormalizeFactor = uBlendShapeUnnormalizeFactor[index];
 #endif
 
-      diff = uBlendShapeWeight[index] * unnormalizeFactor * ( texelFetch( sBlendShapeGeometry, ivec2(x, y), 0 ).xyz - 0.5 );
+      diff = weight * unnormalizeFactor * ( texelFetch( sBlendShapeGeometry, ivec2(x, y), 0 ).xyz - 0.5 );
     }
 
     position.xyz += diff;
@@ -111,9 +112,9 @@ void main()
     y = vertexId / width;
 
     // Retrieves the blend shape normal from the texture, unnormalizes it and multiply by the weight.
-    if( 0.0 != uBlendShapeWeight[index] )
+    if(0.0 != weight)
     {
-      diff = uBlendShapeWeight[index] * 2.0 * ( texelFetch( sBlendShapeGeometry, ivec2(x, y), 0 ).xyz - 0.5 );
+      diff = weight * 2.0 * ( texelFetch( sBlendShapeGeometry, ivec2(x, y), 0 ).xyz - 0.5 );
     }
 
     normal += diff.xyz;
@@ -128,9 +129,9 @@ void main()
     y = vertexId / width;
 
     // Retrieves the blend shape tangent from the texture, unnormalizes it and multiply by the weight.
-    if( 0.0 != uBlendShapeWeight[index] )
+    if(0.0 != weight)
     {
-      diff = uBlendShapeWeight[index] * 2.0 * ( texelFetch( sBlendShapeGeometry, ivec2(x, y), 0 ).xyz - 0.5 );
+      diff = weight * 2.0 * ( texelFetch( sBlendShapeGeometry, ivec2(x, y), 0 ).xyz - 0.5 );
     }
 
     tangent += diff.xyz;