I came across strange pixel shader behavior in WPF.
This problem is 100% reproducible, so I wrote a small demo program. You can download the source code here .
The root of all evil is a tiny class called MyFrameworkElement:
internal sealed class MyFrameworkElement : FrameworkElement
{
public double EndX
{
get
{
return (double)this.GetValue(MyFrameworkElement.EndXProperty);
}
set
{
this.SetValue(MyFrameworkElement.EndXProperty, value);
}
}
public static readonly DependencyProperty EndXProperty =
DependencyProperty.Register("EndX",
typeof(double),
typeof(MyFrameworkElement),
new FrameworkPropertyMetadata(0d, FrameworkPropertyMetadataOptions.AffectsRender));
protected override void OnRender(DrawingContext dc)
{
dc.DrawLine(new Pen(Brushes.Red, 2), new Point(0, 0), new Point(this.EndX, 100));
dc.DrawLine(new Pen(Brushes.Green, 3), new Point(10, 300), new Point(200, 10));
}
}
As you can see, this framework element displays 2 lines: the bottom line has constant coordinates, but the top line depends on the EndX dependency property.
So this framework element is an object for the pixel shader effect. For simplicity, I use the grayscale effect found here . So I applied GrayscaleEffect to MyFrameworkElement. You can see the result, it looks beautiful.

EndX.

, !
, , .

- , ?
, ?