Fix normal vector error when we use skin 49/292549/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 10 May 2023 01:35:07 +0000 (10:35 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Wed, 10 May 2023 05:34:11 +0000 (14:34 +0900)
Since dali's world matrix use left-hand-coordinate,
the constrainted world matrix value in uBone need to be multiply negative Y.

To apply this information, let we use uYDirection value if we use skin.

Also, we need to use same precision if we use same uniform both vertex and
fragment shaders. To specify the precision, make uYDirection as mediump.

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

index bfcc18b..e701162 100644 (file)
@@ -77,7 +77,7 @@ uniform sampler2D sbrdfLUT;
 uniform samplerCube sDiffuseEnvSampler;
 uniform samplerCube sSpecularEnvSampler;
 uniform float uIblIntensity;
-uniform vec3 uYDirection;
+uniform mediump vec3 uYDirection;
 uniform float uMaxLOD;
 
 // For Alpha Mode.
index 5b48af0..8ca91ea 100644 (file)
@@ -41,6 +41,7 @@ uniform mat4 uProjection;
   in vec4 aWeights;
   #define MAX_BONES 64
   uniform mat4 uBone[MAX_BONES];
+  uniform mediump vec3 uYDirection;
 #endif
 
 #ifdef MORPH
@@ -141,10 +142,8 @@ void main()
     uBone[int(aJoints.z)] * aWeights.z +
     uBone[int(aJoints.w)] * aWeights.w;
   position = bone * position;
-  normal = (bone * vec4(normal, 0.0)).xyz;
-  tangent = (bone * vec4(tangent, 0.0)).xyz;
-  normal = normalize(normal);
-  tangent = normalize(tangent);
+  normal = uYDirection * (bone * vec4(normal, 0.0)).xyz;
+  tangent = uYDirection * (bone * vec4(tangent, 0.0)).xyz;
 
   highp vec4 positionW = position;
 #else
@@ -154,6 +153,8 @@ void main()
 
   vPositionToCamera = transpose(mat3(uViewMatrix)) * -vec3(positionV.xyz / positionV.w);
 
+  normal = normalize(normal);
+  tangent = normalize(tangent);
   vec3 bitangent = cross(normal, tangent);
 #ifdef VEC4_TANGENT
   bitangent *= aTangent.w;