question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unclear support for some Win2D effects with Composition APIs

See original GitHub issue

Hello, I’m working with the Composition APIs and some Win2D effects and I’ve read the list of the available Win2D effects that are currently supported with the Composition APIs here.

From the list in that page (as well as this page) I can see that the GaussianBlurEffect is marked with the [NoComposition] attribute, so it shouldn’t be supported. Yet I can use this method without any problems (and I’m not sure why):

public static SpriteVisual GetAttachedBlur<T>(
    [NotNull] this T element, float blur, int ms) where T : FrameworkElement
{
    // Get the visual and the compositor
    Visual visual = element.GetVisual();
    Compositor compositor = visual.Compositor;

    // Create the blur effect and the effect factory
    GaussianBlurEffect blurEffect = new GaussianBlurEffect
    {
        Name = "Blur",
        BlurAmount = blur,
        BorderMode = EffectBorderMode.Hard,
        Optimization = EffectOptimization.Balanced,
        Source = new CompositionEffectSourceParameter("source")
    };
    CompositionEffectFactory effectFactory = compositor.CreateEffectFactory(blurEffect);

    // Setup the rest of the effect
    CompositionEffectBrush effectBrush = effectFactory.CreateBrush();
    effectBrush.SetSourceParameter("source", compositor.CreateBackdropBrush());

    // Assign the effect to a brush and display it
    SpriteVisual sprite = compositor.CreateSpriteVisual();
    sprite.Brush = effectBrush;
    sprite.Size = new Vector2((float)element.ActualWidth, (float)element.ActualHeight);
    ElementCompositionPreview.SetElementChildVisual(element, sprite);
    return sprite;
}

I mean, looking at the documentation, I would expect the code to fail, since the GaussianBlurEffect doesn’t seem to be supported. Then, I tried another effect (the DirectionalBlurEffect, which is also marked as not supported by the Composition APIs) and that failed (the CreateEffectFactory threw an exception. So my questions are:

  • If both those effects are marked as [NoComposition], why does the GaussianBlurEffect actually work with the Composition APIs, and the DirectionalBlurEffect doesn’t? Is there another way to use those other effects, or is there a plan to support them as well in future Windows 10 releases?

Thanks for your help!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
sohchattcommented, May 23, 2017

Here’s a list of effects that are currently tagged as NoComposition but are supported as of today:

  • All BlendEffectModes except Dissolve (Fall Creator’s Update Insider)
  • BorderEffect (Creator’s Update)
  • ColorMatrixEffect (Creator’s Update)
  • DistantDiffuseEffect (Anniversary Update)
  • DistatntSpecularEffect (Anniversary Update)
  • GaussianBlurEffect (Anniversary Update)
  • LuminaceToAlphaEffect (Anniversary Update)
  • PointDiffuseEffect (Anniversary Update)
  • PointSpecularEffect(Anniversary Update)
  • SpotDiffuseEffect (Anniversary Update)
  • SpotSpecularEffect (Anniversary Update)

You should see updates to the Win2D documentation over the next few days.

You (and others) have a direct say in which effects we support next: please feel free to submit feedback (and upvote) about the specific Win2D effects you’d like to see in the Composition APIs.

1reaction
sohchattcommented, May 23, 2017

This is a documentation bug on the Win2D page: GaussianBlurEffect is supported in Composition.

Thanks for your feedback; we will update the Win2D effect descriptions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unclear support for some Win2D effects with Composition ...
Hello, I'm working with the Composition APIs and some Win2D effects and I've read the list of the available Win2D effects that are...
Read more >
Some Win2D effects not working with Composition APIs ...
I'm working with some Win2D effects and the Composition APIs in a UWP application and I'm having some issues with some of the...
Read more >
CompositionEffectBrush Class (Windows.UI.Composition)
The effect APIs enable developers to customize how their UI is rendered. ... Effects that are not supported are marked as [NoComposition] in...
Read more >
Composition
Windows 10 1607, UWP, Composition APIs–Walked Through Demo Code ... blog and I have a question with blur effect and really need your...
Read more >
Windows 10 1607, Composition, XAML and a Blurred ...
The main page has a background image and the bottom of the main page is a grid, I want it with blur effect....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found