[Tizen] Change some precision of shader variables to highp 04/296904/4
authorSeungho Baek <sbsh.baek@samsung.com>
Tue, 11 Jul 2023 09:20:35 +0000 (18:20 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Wed, 23 Aug 2023 04:51:55 +0000 (13:51 +0900)
 - There are some visual artifact to render 3D object in case of adding Directional Light.
 - Some variable's precision is too low.
 - This patch changes minimum number of variable's precision to highp

Change-Id: I0ff1c30bb3f0eb837434f0dc61d2a461383dfbd2
Signed-off-by: Seungho Baek <sbsh.baek@samsung.com>
dali-scene3d/internal/graphics/shaders/default-physically-based-shader.frag

index 9a436f5..de7b28d 100644 (file)
@@ -117,7 +117,7 @@ void main()
   lowp float metallic = uMetallicFactor;
   lowp float perceptualRoughness = uRoughnessFactor;
   // If there isn't normal texture, use surface normal
-  mediump vec3 n = normalize(vTBN[2].xyz);
+  highp vec3 n = normalize(vTBN[2].xyz);
 
 #ifdef THREE_TEX
   // The albedo may be defined from a base texture or a flat color
@@ -222,8 +222,8 @@ void main()
 
     for(int i = 0; i < uLightCount; ++i)
     {
-      mediump vec3 l = normalize(-uLightDirection[i]);               // Vector from surface point to light
-      mediump vec3 h = normalize(l+v);                              // Half vector between both l and v
+      highp vec3 l = normalize(-uLightDirection[i]); // Vector from surface point to light
+      mediump vec3 h = normalize(l+v);               // Half vector between both l and v
       mediump float VdotH = dot(v, h);
       lowp vec3 specularReflection = f0 + (reflectance90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0);
 
@@ -231,8 +231,8 @@ void main()
       lowp float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
       lowp float geometricOcclusion = attenuationL * attenuationV;
 
-      mediump float NdotH = dot(n, h);
-      lowp float f = (NdotH * roughnessSq - NdotH) * NdotH + 1.0;
+      highp float NdotH = dot(n, h);
+      highp float f = (NdotH * roughnessSq - NdotH) * NdotH + 1.0;
       lowp float microfacetDistribution = roughnessSq / (M_PI * f * f);;
 
       // Calculation of analytical lighting contribution