PDA

View Full Version : Simple shader - loses green channel



Foxbat
11-09-2006, 10:06 AM
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 );

}

k_szczech
11-09-2006, 12:44 PM
Try this:

col_1 = foo * col_0;

Foxbat
11-09-2006, 02:30 PM
Originally posted by k_szczech:
Try this:

col_1 = foo * col_0;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.

CaseMillennium
11-10-2006, 12:10 AM
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).