mat3 construction

This topic contains 1 reply, has 2 voices, and was last updated by  Joe Davis 6 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30316

    Hi there,

                Is there a nice way of construction a mat3 from a mat4 in a vertex shader?

    I see in most of the PowerVR demos this is mostly avoided by passing in the 3×3 matrix.

    The glsl spec lists a number of ways including:

    uniform highp mat4 c;

    mat3 a(c);

    mat3 b(c[0].xyz,c[1].xyz,c[2].xyz);

    Both of which return the rather unhelpful “syntax error: syntax error” compilation error 🙁

    The only way I seem to be able to make one, is to copy the individual vectors over.

    Thanks,

    Steve.

    #34430

    Joe Davis
    Member

    The problem you are encountering is because the syntax for the assignment differs from that which can be done in a language such as C++. Instead, you should write the following:

    highp mat3 a = mat3(c);

    highp mat3 b = mat3(c[0].xyz,c[1].xyz,c[2].xyz);

    [/CODE]

    Unlike C++ syntax where (depending on the compiler) this could cause the default constructor to be called and then an assignment, the GLSL ES compiler interprets the code I’ve written above as a call to the assignment constructor.

    JoeJoe2010-11-08 12:49:32[CODE]

    highp mat3 a = mat3(c);

    highp mat3 b = mat3(c[0].xyz,c[1].xyz,c[2].xyz);

    [/CODE]

    Unlike C++ syntax where (depending on the compiler) this could cause the default constructor to be called and then an assignment, the GLSL ES compiler interprets the code I’ve written above as a call to the assignment constructor.

    JoeJoe2010-11-08 12:49:32

Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.