[Tizen] Fix normal vector error when we use skin 28/292628/1
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 07:41:49 +0000 (16:41 +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 bfcc18bfe4132f2b3853d565999cf99728e8a5bc..e701162c6b11e6862bb3121e90d96f968a3d7fba 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 5b48af089bacd1a2bb4be3437aa07a41216cae1d..8ca91eafcfedff50f10271094a0b3531af6baaaa 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;