kernel Luminosity < namespace: "com.27Bobs"; vendor: "Todd Yard"; version: 1; description: "Applies the luminosity of the source image to the background image."; > { 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(background, coord); float backgroundLuminance = px.r * 0.3 + px.g * 0.59 + px.b * 0.11; px = sampleNearest(source, coord); float sourceLuminance = px.r * 0.3 + px.g * 0.59 + px.b * 0.11; float luminance = backgroundLuminance - sourceLuminance; pixel4 fullBlend = px; fullBlend.r += luminance; fullBlend.g += luminance; fullBlend.b += luminance; result = mix(px, fullBlend, percent); } }