mHorizontalBlurActor = Actor::New();
mHorizontalBlurActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
Renderer horizontalBlurRenderer = CreateRenderer(BASIC_VERTEX_SOURCE, fragmentSource.c_str());
+ horizontalBlurRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); // Always use pre-multiply alpha
mHorizontalBlurActor.AddRenderer(horizontalBlurRenderer);
mInternalRoot.Add(mHorizontalBlurActor);
mVerticalBlurActor = Actor::New();
mVerticalBlurActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
Renderer verticalBlurRenderer = CreateRenderer(BASIC_VERTEX_SOURCE, fragmentSource.c_str());
+ verticalBlurRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); // Always use pre-multiply alpha
mVerticalBlurActor.AddRenderer(verticalBlurRenderer);
mInternalRoot.Add(mVerticalBlurActor);
}
if(!mRenderer)
{
mRenderer = CreateRenderer(SHADER_RENDER_EFFECT_VERT, SHADER_RENDER_EFFECT_FRAG);
+ mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); // Always use pre-multiply alpha
}
ownerControl.InheritedVisibilityChangedSignal().Connect(this, &RenderEffectImpl::OnControlInheritedVisibilityChanged);
varying highp vec2 vOptRectSize;
varying highp vec4 vCornerRadius;
+uniform lowp vec4 uColor;
uniform highp vec3 uSize;
uniform sampler2D sTexture;
void main()
{
- gl_FragColor = texture2D(sTexture, vTexCoord);
+ gl_FragColor = texture2D(sTexture, vTexCoord) * uColor;
gl_FragColor.rgb = applyDithering(gl_FragColor.rgb);
highp vec2 location = (vTexCoord.xy - vec2(0.5)) * uSize.xy;
float distance = roundedBoxSDF(location, uSize.xy * 0.5, radius);
float smoothedAlpha = 1.0 - smoothstep(-edgeSoftness, edgeSoftness, distance);
- gl_FragColor.a *= smoothedAlpha;
+
+ // Premultiply alpha feature used.
+ gl_FragColor *= smoothedAlpha;
}
}