A pixel effect is a texture to texture transformation that defines a pixel shader. Example of a pixel effect is a ripple:

public static PixelEffect Ripple(this PointBl Center, DoubleBl Amplitude, 
                                            DoubleBl Frequency, DoubleBl Phase) {
 return new PixelEffect(Input => new Texture(UV => {
  PointBl ToPoint = UV - Center;
  DoubleBl Distance = ToPoint.Length;
  PointBl Direction = ToPoint / Distance;
  PointBl Wave = new Angle2DBl(Frequency * Distance + Phase).ToPoint;
  DoubleBl Falloff = (1d - Distance).Saturate.Square;
  DoubleBl Lighting = (Wave.Y * Falloff).Saturate * 0.2 + 0.8;
  PointBl Distance2 = Distance + Amplitude * Wave.X * Falloff;
  ColorBl Color = Input[Center + Distance2 * Direction];
  var Color2 = ColorBl.FromScRGB(Color.ScA, Color.ScRGB * Amplitude.Lerp(1d, Lighting));
  return Color2;
 }));
}

The above pixel effect is self contained and creates a ripple, as

ripple.PNG

Last edited Jul 20, 2009 at 3:54 PM by mcdirmid, version 2

Comments

No comments yet.