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];
  return ColorBl.FromScRGB(Color.ScA, Color.ScRGB * Amplitude.Lerp(1d, Lighting));

The effect is self contained, and leads to the following result:


As with textures, pixel effects can be composed via basic arithmetic operators such as addition or multiplication, or through interpolation (lerp), clamping, and so on. Pixel effects can also be composed using a circle operator of sorts via array indexing notation where e0[e1] is equivalent to input => e0[e1[input]].


  • Transitions yield pixel effects when their progress, random seed, and next texture arguments are provided.
  • Lighting results yield pixel effects when normal maps or height fields (normals are approximated) are provided. This forms the basis for bump mapping in pixel shaders.

Last edited Jul 21, 2009 at 3:38 AM by mcdirmid, version 4


No comments yet.