From 7faba4a1d65aec3f2074c1e4a3adc8161b427555 Mon Sep 17 00:00:00 2001 From: Seungho Baek Date: Tue, 11 Jul 2023 18:20:35 +0900 Subject: [PATCH] Change some precision of shader variables to highp - 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 --- .../graphics/shaders/default-physically-based-shader.frag | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.frag b/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.frag index 9a436f5..de7b28d 100644 --- a/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.frag +++ b/dali-scene3d/internal/graphics/shaders/default-physically-based-shader.frag @@ -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 -- 2.7.4