Hi,

this is annoying: I'm trying to create a variable blur CIFilter effect where 
the mix between blurred and unblurred image is determined by the values stored 
in the Blue channel of the input image. It works OK on a completely opaque 
image, but not on one with a transparent background. In this case, I end up 
with a dark line around the border between opaque areas.

Here's the CIFilter kernel routine:

kernel vec4 TexCntrlBlur(sampler Image, float Blur, float Bal)
{
        vec2 xy = samplerCoord(Image);

        vec4 unblurred = (sample(Image, samplerCoord(Image)));
        vec4 blurred = unblurred;
        float ctrl = unblurred.b;

        const vec2 offsets_0    =       vec2(0.0);
        const vec2 offsets_1    =       vec2(-0.75) * samplerSize(Image);
        const vec2 offsets_2    =       vec2(-1.0, 0.0) * samplerSize(Image);
        const vec2 offsets_3    =       vec2(-0.75, 0.75) * samplerSize(Image);
        const vec2 offsets_4    =       vec2(0.0, -1.0) * samplerSize(Image);
        const vec2 offsets_5    =       vec2(0.0, 1.0) * samplerSize(Image);
        const vec2 offsets_6    =       vec2(0.75, -0.75) * samplerSize(Image);
        const vec2 offsets_7    =       vec2(1.0, 0.0) * samplerSize(Image);
        const vec2 offsets_8    =       vec2(0.75, 0.75) * samplerSize(Image);
        const vec2 offsets_9    =       vec2(-1.6, 0.0) * samplerSize(Image);
        const vec2 offsets_10   =       vec2(1.6, 0.0) * samplerSize(Image);
        const vec2 offsets_11   =       vec2(0.0, -1.6) * samplerSize(Image);
        const vec2 offsets_12   =       vec2(0.0, 1.6) * samplerSize(Image);    
        const float weight_0    =       4.0;
        const float weight_1    =       2.0;
        const float weight_2    =       2.0;
        const float weight_3    =       2.0;
        const float weight_4    =       2.0;
        const float weight_5    =       2.0;
        const float weight_6    =       2.0;
        const float weight_7    =       2.0;
        const float weight_8    =       2.0;
        const float weight_9    =       1.0;
        const float weight_10   =       1.0;
        const float weight_11   =       1.0;
        const float weight_12   =       1.0;
        
        blurred = vec4(0.0);
        blurred += (sample(Image, xy + offsets_0 * Blur)) * weight_0 / 21.0;
        blurred += (sample(Image, xy + offsets_1 * Blur)) * weight_1 / 21.0;
        blurred += (sample(Image, xy + offsets_2 * Blur)) * weight_2 / 21.0;
        blurred += (sample(Image, xy + offsets_3 * Blur)) * weight_3 / 21.0;
        blurred += (sample(Image, xy + offsets_4 * Blur)) * weight_4 / 21.0;
        blurred += (sample(Image, xy + offsets_5 * Blur)) * weight_5 / 21.0;
        blurred += (sample(Image, xy + offsets_6 * Blur)) * weight_6 / 21.0;
        blurred += (sample(Image, xy + offsets_7 * Blur)) * weight_7 / 21.0;
        blurred += (sample(Image, xy + offsets_8 * Blur)) * weight_8 / 21.0;
        blurred += (sample(Image, xy + offsets_9 * Blur)) * weight_9 / 21.0;
        blurred += (sample(Image, xy + offsets_10 * Blur)) * weight_10 / 21.0;
        blurred += (sample(Image, xy + offsets_11 * Blur)) * weight_11 / 21.0;
        blurred += (sample(Image, xy + offsets_12 * Blur)) * weight_12 / 21.0;
        
        vec4 finalPix = mix(unblurred,blurred,1.0 - ctrl);
        
        return vec4(finalPix.rgga);
}

Can anyone spot where I'm going wrong? It's probably got something to do with 
pre or un-multiplying, but I can't seem to work out how to fix the problem.

Cheers,

a|x
http://machinesdontcare.wordpress.com



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to