Simple shader - loses green channel

In the following shader the result for the green channel is always 0 (zero). The red and blue channels are as expected.

Graphics HW is nvidia 7800 w/ the latest drivers.

const mat3 foo = mat3(
0.25,
0.25,
0.25,
0.25,
0.25,
0.25,
0.25,
0.25,
0.25 );

void main( )
{
vec3 col_0, col_1;

col_0 = vec3( gl_Color );
col_1 = col_0 * foo;

gl_FragColor = vec4( col_1, 1.0 );

}

Try this:

col_1 = foo * col_0;

Originally posted by k_szczech:
[b] Try this:

col_1 = foo * col_0;

[/b]
Yes. That does work. Now my question is, is the original code supposed to work? In the Orange book under “Color Space Conversions” it also has the color vector pre-mulitplying the matrix.

Premultiplying a mat4 also works as expected.

Sounds familar to me. I have the same problem, but it is even a littlebit more weird:

I have a simple color-conversion-function to XYZ and back in my shader to do some tonemapping. This function works exactly as it should except in one shader!! On this shader, and only on this shader, the matrix is transposed and I have no idea why, especially since it started to happen with drivers above 81.xx only (before this release, everything was fine).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.