cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

lizardq
Journeyman III

GLSL mat3 contructor fails (produces wrong result)

The mat3 contructor fails (produces a wrong matrix) inside the fragment shader if passed a variable argument at particular positions. See following code...


mat3 pitchMat( const float angle )
{
    float s = sin( angle ), c = cos( angle );

// does not work:
// return mat3(1, 0, 0, 0, c, -s, 0, s, c );

// workaround:
    mat3 m = mat3( 1, 0, 0, 0, 1, 0, 0, 0, 1 );
    m[1][1] = c; m[2][2] = c; m[1][2] = -s; m[2][1] = s;
    return m;

// interstingly, this works:
// return mat3( c, 0, -s, 0, 1, 0, s, 0, c );
}


Catalyst 10.5 on a Mobility Radeon HD 4350 inside an HP notebook.

(I've been pointed to this forum by AMD tech support with the following "explanation": AMD Customer Care does not currently offer support or troubleshooting in OpenGL development software. ?!?)

0 Likes
3 Replies
frali
Staff

Could you please tell me which value is wrong? I did a test on your function by making the value of "angle" to 0, the returned matrix is
1   0   0
0   1   0
0   0   1

That's as expected. 

0 Likes

Unfortunately I don't have the actual numbers that ended up in the matrix. This function is part of a larger shader that does some texture lookup tasks in a panoramic imaging context. The broken image result had some kind of "spiral"-effect (instead of beeing simply rotated).

The weired thing was, that my very simmilar yawMat and rollMat functions work flowlessly.

It looks like you simply can't reproduce the problem, since I witnessed the "spiral" also using the following code:

    float c = 1.0;
    return mat3(1, 0, 0, 0, c, 0, 0, 0, c );

So the only thing that mattered was whether there is a variable argument at a particular position of the constructor.

Unfortunately, this happened on a client's machine, where I can only get remote access to involving the client...

0 Likes

That's strange that only this matrix doesn't work. But how could you make sure the matrix is wrong when you don't get a chance to check it? Maybe it's called by function call, function argument or something else. We are pleased to resolve your problem but it's better to get a program that is narrowed down to reproduce the bug.

You could contact me by my email: frank.li@amd.com, thanks. 

0 Likes