kernel ColorBurn < namespace: "com.27Bobs"; vendor: "Todd Yard"; version: 1; description: "Darkens the background color to reflect the 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; // equations taken from Adobe documentation on Photoshop blend modes if (px.r > 0.0) { fullBlend.r = 1.0 - min(1.0, (1.0-px.r)/bg.r); } if (px.g > 0.0) { fullBlend.g = 1.0 - min(1.0, (1.0-px.g)/bg.g); } if (px.b > 0.0) { fullBlend.b = 1.0 - min(1.0, (1.0-px.b)/bg.b); } result = mix(px, fullBlend, percent); } }