Search code examples
c++uwpwin2dwindows-8.1-universal

How to use vertex shader via Win2d


I've read and looked a lot of information about Win2D and found that I can use custom pixel and vertex shaders.

I found how to create custom pixel shader resource

        var bitmapTiger = await CanvasBitmap.LoadAsync(sender, "imageTiger.jpg");
        tigerSize = bitmapTiger.Size.ToVector2();

        effect = new PixelShaderEffect(await Utils.ReadAllBytes("my_pixel_shader.fxo"))
        {
            Source1 = bitmapTiger,
            Source1BorderMode = EffectBorderMode.Hard,
            Source1Mapping = SamplerCoordinateMapping.Offset,
            MaxSamplerOffset = 1
        };

But I can not find how to create a vertex shader resource via Win2D.

Thanks in advance


Solution

  • As the site you linked stated:

    Unfortunately, it is not possible to add custom image effects to Win2D today.

    This is wrong by now!
    But unfortunally at the moment Win2D just offers a way to use pixel shaders. If you want to use vertex shaders you have to use Direct3D. There is an Example Gallery with an example how to mix Direct3D with Win2D (the one with the teapot) and you can find the code on GitHub. I don't know if this will help you, but thats all I could find.