Arash
Arash

Reputation: 213

How to get SamplerProperties of a ShaderEffect in wpf?

In WPF, when defining ShaderEffects, we use

ShaderEffect.RegisterPixelShaderSamplerProperty()

to introduce pixel shader sampler properties (the ones that are fed to the actual pixel shader, and are of type Brush); but how can these properties be retrieved from a ShaderEffect class?

Upvotes: 0

Views: 315

Answers (1)

Colin Smith
Colin Smith

Reputation: 12540

RegisterPixelShaderSamplerProperty creates a new DependencyProperty which becomes available on the class which you derived from ShaderEffect.

You can create a CLR wrapper in order to access it.

public static readonly DependencyProperty InputProperty =
    ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(MyShaderEffect), 0);

public Brush Input
{
    get
    {
        return (Brush)GetValue(InputProperty);
    }
    set
    {
        SetValue(InputProperty, value);
    }
}

Here is a link to a book useful when writing shaders for XAML/WPF.

Upvotes: 1

Related Questions