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>
{"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},
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),
#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
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
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;
#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()
// 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;
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;
#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()
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;
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;
#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()