Forums > Jitter

stuck at a very simple fragment shader

July 11, 2006 | 3:07 pm

In my first attempt to modify a shader I’m already stuck:-/

I try to add alpha blending to cf.blur.jxs like this:

vec4 blur;
vec4 color;

blur = texture2DRect(image, texcoord11);
blur += texture2DRect(image, texcoord00);
blur += texture2DRect(image, texcoord02);
blur += texture2DRect(image, texcoord20);
blur += texture2DRect(image, texcoord22);

blur *= 0.2;

color.rgb = blur.rgb;
color.a = gl_Color.a;

gl_FragColor = color;

This always results in alpha 1 regardless of the objects alpha color. While
"color.a = 0.5;" gives me just what I’d expect.

So gl_Color.a is not returning the objects alpha like I want it to. What am
I missing here??

-Thijs


July 11, 2006 | 3:28 pm

ok got it. you need to get the gl_Color in the vertex program and pass it on
to the fragment program. Clearly my first shader attempt :-)

-Thijs

On 7/11/06, Thijs Koerselman

wrote:
>
> In my first attempt to modify a shader I’m already stuck:-/
>
> I try to add alpha blending to cf.blur.jxs like this:
>
> vec4 blur;
> vec4 color;
>
> blur = texture2DRect(image, texcoord11);
> blur += texture2DRect(image, texcoord00);
> blur += texture2DRect(image, texcoord02);
> blur += texture2DRect(image, texcoord20);
> blur += texture2DRect(image, texcoord22);
>
> blur *= 0.2;
>
> color.rgb = blur.rgb;
> color.a = gl_Color.a;
>
> gl_FragColor = color;
>
>
> This always results in alpha 1 regardless of the objects alpha color.
> While "color.a = 0.5;" gives me just what I’d expect.
>
> So gl_Color.a is not returning the objects alpha like I want it to. What
> am I missing here??
>
> -Thijs
>
>


Viewing 2 posts - 1 through 2 (of 2 total)