INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
+INPUT mediump float vAliasMargin;
#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform sampler2D sTexture;
+#if defined(IS_REQUIRED_YUV_TO_RGB) || defined(IS_REQUIRED_UNIFIED_YUV_AND_RGB)
+uniform sampler2D sTextureU;
+uniform sampler2D sTextureV;
+#endif
#ifdef IS_REQUIRED_ALPHA_MASKING
uniform sampler2D sMaskTexture;
void setupMinMaxPotential()
{
- gPotentialRange = 1.0;
+ gPotentialRange = vAliasMargin;
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()
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;
// 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)
}
#endif
+#if defined(IS_REQUIRED_YUV_TO_RGB) || defined(IS_REQUIRED_UNIFIED_YUV_AND_RGB)
+lowp vec4 ConvertYuvToRgba(mediump vec2 texCoord)
+{
+#ifdef IS_REQUIRED_UNIFIED_YUV_AND_RGB
+ // Special case when shader use YUV but actual textures are not YUV format.
+ // In this case, just resturn sTexture.
+ if(textureSize(sTextureU, 0) != textureSize(sTextureV, 0))
+ {
+ return texture(sTexture, texCoord);
+ }
+#endif
+
+ lowp float y = texture(sTexture, texCoord).r;
+ lowp float u = texture(sTextureU, texCoord).r - 0.5;
+ lowp float v = texture(sTextureV, texCoord).r - 0.5;
+ lowp vec4 rgba;
+ rgba.r = y + (1.403 * v);
+ rgba.g = y - (0.344 * u) - (0.714 * v);
+ rgba.b = y + (1.770 * u);
+ rgba.a = 1.0;
+ return rgba;
+}
+#endif
+
void main()
{
#ifdef ATLAS_DEFAULT_WARP
mediump vec2 texCoord = vTexCoord;
#endif
+#if defined(IS_REQUIRED_YUV_TO_RGB) || defined(IS_REQUIRED_UNIFIED_YUV_AND_RGB)
+ lowp vec4 textureColor = ConvertYuvToRgba(texCoord) * vec4( mixColor, 1.0 ) * uColor;
+#else
lowp vec4 textureColor = TEXTURE( sTexture, texCoord ) * vec4( mixColor, 1.0 ) * uColor;
+#endif
#ifdef IS_REQUIRED_ALPHA_MASKING
mediump float maskAlpha = TEXTURE(sMaskTexture, vMaskTexCoord).a;