X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fgraphics%2Fshaders%2Fgradient-visual-shader.frag;h=c2b9c5d2b01aca69373657ad2825c9fc8f1a74ea;hb=0ab2af8053436971758161fbf1c4ad73058ac5ce;hp=febc7768d99205d52a7f7fbe2e4e3fd7f9158a0b;hpb=45ad62cd772319bc585a48c868b31892881374bb;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/graphics/shaders/gradient-visual-shader.frag b/dali-toolkit/internal/graphics/shaders/gradient-visual-shader.frag index febc776..c2b9c5d 100644 --- a/dali-toolkit/internal/graphics/shaders/gradient-visual-shader.frag +++ b/dali-toolkit/internal/graphics/shaders/gradient-visual-shader.frag @@ -8,6 +8,14 @@ INPUT mediump vec4 vCornerRadius; #endif #endif +// 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; @@ -69,7 +77,10 @@ void calculatePotential() void setupMinMaxPotential() { - gPotentialRange = 1.0; + // 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; @@ -83,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() @@ -113,7 +124,7 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor) borderlineOpacity = smoothstep(gMinInlinePotential, gMaxInlinePotential, potential); // Muliply borderlineWidth to resolve very thin borderline - borderlineOpacity *= min(1.0, borderlineWidth); + borderlineOpacity *= min(1.0, borderlineWidth / gPotentialRange); } lowp vec3 borderlineColorRGB = borderlineColor.rgb * uActorColor.rgb; @@ -126,7 +137,7 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor) // But if borderlineOpacity > 0.0 and borderlineColor.a == 0.0, we need to apply tCornerRadius. if(borderlineOpacity > 0.0 && borderlineColor.a * borderlineOpacity < 1.0) { - mediump float tCornerRadius = -gCenterPosition; + mediump float tCornerRadius = -gCenterPosition + gPotentialRange; mediump float MaxTexturelinePotential = tCornerRadius + gPotentialRange; mediump float MinTexturelinePotential = tCornerRadius - gPotentialRange; if(potential > MaxTexturelinePotential) @@ -187,7 +198,8 @@ mediump float calculateCornerOpacity() void main() { #ifdef RADIAL - lowp vec4 textureColor = TEXTURE(sTexture, vec2(length(vTexCoord), 0.5)) * vec4(mixColor, 1.0) * uColor; + mediump float radialTexCoord = ((length(vTexCoord) - 0.5) * uTextureCoordinateScaleFactor) + 0.5; + lowp vec4 textureColor = TEXTURE(sTexture, vec2(radialTexCoord, 0.5)) * vec4(mixColor, 1.0) * uColor; #else lowp vec4 textureColor = TEXTURE(sTexture, vec2(vTexCoord.y, 0.5)) * vec4(mixColor, 1.0) * uColor; #endif