topical media & game development

talk show tell print

graphic-player-10-pixel-bender-shaders-RippleBlocks.pbk / pbk



  <languageVersion : 1.0;>
  
  kernel RippleBlocks
  <   namespace : "Allen Chou";
      vendor : "";
      version : 1;
      description : "box-shaped ripple effect";
  >
  {
      parameter float2 amplitude
      <
      minValue:     float2(  0,   0);
      maxValue:     float2(100, 100);
      defaultValue: float2( 20,  20);
      >;
      
      parameter float2 wavelength
      <
      minValue:     float2(   1.0,    1.0);
      maxValue:     float2( 100.0,  100.0);
      defaultValue: float2(  10.0,   10.0);
      >;
     
      parameter float2 phase
      <
      minValue:     float2(  0.0,   0.0);
      maxValue:     float2(6.283, 6.283);
      defaultValue: float2(  0.0,   0.0);
      >;
  
      input image4 src;
      output pixel4 dst;
  
      void
      evaluatePixel()
      {
          float2 coord = outCoord();
          coord.x += amplitude.x * sin((coord.x / wavelength.x) + phase.x);
          coord.y += amplitude.y * cos((coord.y / wavelength.y) + phase.y);
          
          dst = sample(src, float2(coord.x, coord.y));
      }
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.