topical media & game development

talk show tell print

graphic-flex-image-effects-05-source-multiply.pbk / pbk



  <languageVersion : 1.0;>
  
  kernel Multiply
  <   namespace:      "com.27Bobs";
      vendor:         "Todd Yard";
      version:        1;
      description:    "Multiplies the background color and source color.";
  >
  {
  
      parameter float percent
      <
          minValue:       0.0;
          maxValue:       1.0;
          defaultValue:   1.0;
          description:    "The amount of blend to apply.";
      >;
  
      input image4 source;
      input image4 background;
      output pixel4 result;
  
      void
      evaluatePixel()
      {
          float2 coord = outCoord();
          pixel4 px = sampleNearest(source, coord);
          pixel4 bg = sampleNearest(background, coord);
          pixel4 fullBlend = px*bg;
          result = mix(px, fullBlend, percent);
      }
  
  }


(C) Æliens 18/6/2009

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.