Off the top of my head (i.e. untested, but it should work ;) :
vec4 newpix = sample(image, samplerCoord(image));
return (newpix.r + newpix.g + newpix.b)/3.0 > threshold?
    (newpix - threshold) / (1.0 - threshold) :
    vec4(0.0,0.0,0.0,1.0);

(It first tests if r+g+b/3 is greater than the threshold. If it is, it
reduces the value by the threshold value and then scales to 1.0, if not it
returns black.)

Chris


2008/10/16 Jesse Lucas <[EMAIL PROTECTED]>

> Hi List,
>
> I'm trying to create a kind of threshold effect, but I'm very new to CI
> coding. Here's what I'm trying to achieve:
>
> -I need to change all pixels under a certain brightness value to black.
> - And remap the brightness of the remain pixels to a 0 to 1 range (so I get
> contrast even on high threshold values).
>
> - It doesn't matter if the resulting output is grayscale, I don't need the
> color information.
>
> It is definitely not working right now so I need your help :)
>
> Here's the code I've got for now (and I've attached the simple patch)
> :
>
> kernel vec4 threshhold(sampler image, float threshold)
> {
>        vec4 newpix = sample(image, samplerCoord(image));
>        vec4 newpix = (newpix - threshold) / (1.0-threshold*1.1);
>        newpix.a = 1.0;
>        return vec4 (newpix);
> }
>
>
>
>
>
>  _______________________________________________
> 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/psonice%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
 _______________________________________________
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