Let Anti-Alias consider scale factor 63/301563/6
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 20 Nov 2023 04:41:03 +0000 (13:41 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 21 Nov 2023 23:28:42 +0000 (08:28 +0900)
Some days ago, we assume that the view which is smaller than 100x100 doesn't use
the range of anti-alias as 1.0.

(See https://review.tizen.org/gerrit/c/platform/core/uifw/dali-toolkit/+/279801)

But it make some visual defect when we use 56x56 size of view and scale it up.

Basically, the problem of these issues comes due to visuald don't know the
scale value.
So let we get actor's scale value as default shader property,
and then use it as anti-alias calculation parameter.

Change-Id: I64b32049919cd79c9dda7fcf7c9c256e5b5a6078
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-reflection.cpp
dali-toolkit/internal/graphics/shaders/color-visual-shader.frag
dali-toolkit/internal/graphics/shaders/gradient-visual-shader.frag
dali-toolkit/internal/graphics/shaders/image-visual-shader.frag

index 38169a2..b861c66 100644 (file)
@@ -166,6 +166,7 @@ void TestGlAbstraction::Initialize()
     {"uMvpMatrix", GL_FLOAT_MAT4, 1},
     {"uNormalMatrix", GL_FLOAT_MAT4, 1},
     {"uProjection", GL_FLOAT_MAT4, 1},
+    {"uScale", GL_FLOAT_VEC3, 1},
     {"uSize", GL_FLOAT_VEC3, 1},
     {"uViewMatrix", GL_FLOAT_MAT4, 1},
     {"uLightCameraProjectionMatrix", GL_FLOAT_MAT4, 1},
index 7b3e6c8..3998fde 100644 (file)
@@ -54,6 +54,7 @@ static const std::vector<UniformData> UNIFORMS =
     UniformData("uMvpMatrix", Property::Type::MATRIX),
     UniformData("uNormalMatrix", Property::Type::MATRIX3),
     UniformData("uProjection", Property::Type::MATRIX),
+    UniformData("uScale", Property::Type::VECTOR3),
     UniformData("uSize", Property::Type::VECTOR3),
     UniformData("uViewMatrix", Property::Type::MATRIX),
     UniformData("uLightCameraProjectionMatrix", Property::Type::MATRIX),
index 662121e..f1b51bb 100644 (file)
@@ -7,6 +7,11 @@ INPUT mediump vec4 vCornerRadius;
 #endif
 #endif
 
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
+// Be used when we calculate anti-alias range near 1 pixel.
+uniform highp vec3 uScale;
+#endif
+
 uniform lowp vec4 uColor;
 uniform lowp vec3 mixColor;
 #ifdef IS_REQUIRED_BLUR
@@ -18,7 +23,6 @@ uniform lowp vec4 borderlineColor;
 uniform lowp vec4 uActorColor;
 #endif
 
-
 #if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
 // Global values both rounded corner and borderline use
 
@@ -71,8 +75,10 @@ void calculatePotential()
 
 void setupMinMaxPotential()
 {
-  // Set soft anti-alias range at most 2% of visual size
-  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.02);
+  // Set soft anti-alias range at most 10% of visual size.
+  // The range should be inverse proportion with scale of view.
+  // To avoid divid-by-zero, let we allow minimum scale value is 0.001 (0.1%)
+  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.2) / max(0.001, max(uScale.x, uScale.y));
 
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
@@ -89,8 +95,8 @@ void setupMinMaxPotential()
 #endif
 
   // reduce defect near edge of rounded corner.
-  gMaxOutlinePotential += clamp(-min(gDiff.x, gDiff.y)/ max(1.0, gRadius) , 0.0, 1.0);
-  gMinOutlinePotential += clamp(-min(gDiff.x, gDiff.y)/ max(1.0, gRadius) , 0.0, 1.0);
+  gMaxOutlinePotential += clamp(-min(gDiff.x, gDiff.y) / max(1.0, gRadius), 0.0, 1.0);
+  gMinOutlinePotential += clamp(-min(gDiff.x, gDiff.y) / max(1.0, gRadius), 0.0, 1.0);
 }
 
 void PreprocessPotential()
index 5104f6b..c2b9c5d 100644 (file)
@@ -11,6 +11,11 @@ INPUT mediump vec4 vCornerRadius;
 // scale factor to fit start and end position of gradient.
 uniform mediump float uTextureCoordinateScaleFactor;
 
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
+// Be used when we calculate anti-alias range near 1 pixel.
+uniform highp vec3 uScale;
+#endif
+
 uniform sampler2D sTexture; // sampler1D?
 uniform lowp vec4 uColor;
 uniform lowp vec3 mixColor;
@@ -72,8 +77,10 @@ void calculatePotential()
 
 void setupMinMaxPotential()
 {
-  // Set soft anti-alias range at most 2% of visual size
-  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.02);
+  // Set soft anti-alias range at most 10% of visual size.
+  // The range should be inverse proportion with scale of view.
+  // To avoid divid-by-zero, let we allow minimum scale value is 0.001 (0.1%)
+  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.2) / max(0.001, max(uScale.x, uScale.y));
 
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
@@ -87,8 +94,8 @@ void setupMinMaxPotential()
 #endif
 
   // reduce defect near edge of rounded corner.
-  gMaxOutlinePotential += clamp(-min(gDiff.x, gDiff.y)/ max(1.0, gRadius) , 0.0, 1.0);
-  gMinOutlinePotential += clamp(-min(gDiff.x, gDiff.y)/ max(1.0, gRadius) , 0.0, 1.0);
+  gMaxOutlinePotential += clamp(-min(gDiff.x, gDiff.y) / max(1.0, gRadius), 0.0, 1.0);
+  gMinOutlinePotential += clamp(-min(gDiff.x, gDiff.y) / max(1.0, gRadius), 0.0, 1.0);
 }
 
 void PreprocessPotential()
index c2c17e5..bad5500 100644 (file)
@@ -26,6 +26,11 @@ uniform mediump vec4 uAtlasRect;
 uniform lowp vec2 wrapMode;
 #endif
 
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
+// Be used when we calculate anti-alias range near 1 pixel.
+uniform highp vec3 uScale;
+#endif
+
 uniform lowp vec4 uColor;
 uniform lowp vec3 mixColor;
 uniform lowp float preMultipliedAlpha;
@@ -99,8 +104,10 @@ void calculatePotential()
 
 void setupMinMaxPotential()
 {
-  // Set soft anti-alias range at most 2% of visual size
-  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.02);
+  // Set soft anti-alias range at most 10% of visual size.
+  // The range should be inverse proportion with scale of view.
+  // To avoid divid-by-zero, let we allow minimum scale value is 0.001 (0.1%)
+  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.2) / max(0.001, max(uScale.x, uScale.y));
 
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
@@ -114,8 +121,8 @@ void setupMinMaxPotential()
 #endif
 
   // reduce defect near edge of rounded corner.
-  gMaxOutlinePotential += clamp(-min(gDiff.x, gDiff.y)/ max(1.0, gRadius) , 0.0, 1.0);
-  gMinOutlinePotential += clamp(-min(gDiff.x, gDiff.y)/ max(1.0, gRadius) , 0.0, 1.0);
+  gMaxOutlinePotential += clamp(-min(gDiff.x, gDiff.y) / max(1.0, gRadius), 0.0, 1.0);
+  gMinOutlinePotential += clamp(-min(gDiff.x, gDiff.y) / max(1.0, gRadius), 0.0, 1.0);
 }
 
 void PreprocessPotential()