【问题标题】:How to get SamplerProperties of a ShaderEffect in wpf?如何在 wpf 中获取 ShaderEffect 的 SamplerProperties?
【发布时间】:2012-08-13 17:03:53
【问题描述】:

在WPF中,在定义ShaderEffects时,我们使用

ShaderEffect.RegisterPixelShaderSamplerProperty()

引入像素着色器采样器属性(馈送到实际像素着色器的属性,并且属于画笔类型);但是如何从 ShaderEffect 类中检索这些属性?

【问题讨论】:

    标签: wpf effect pixel-shader


    【解决方案1】:

    RegisterPixelShaderSamplerProperty 创建一个新的 DependencyProperty,它在您从 ShaderEffect 派生的类上可用。

    您可以创建一个 CLR 包装器来访问它。

    public static readonly DependencyProperty InputProperty =
        ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(MyShaderEffect), 0);
    
    public Brush Input
    {
        get
        {
            return (Brush)GetValue(InputProperty);
        }
        set
        {
            SetValue(InputProperty, value);
        }
    }
    

    这里是一本书的链接,在为 XAML/WPF 编写着色器时很有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多