GLSL Shader Actor - mat2 input



  • Dear All,

    A user sent me a GLSL Shader actor that wasn't working.... the code that caused it to fail is below.

    // ISADORA_FLOAT_PARAM(complexity, complex, 9.0, 900.0, 10.0, "veraendere dichtheit");

    uniform mat2 complexity;

    Note that while they have specified a floating point input, the actual uniform variable declared by complexity is a **mat2** – that's not a single float, but actually four floats! (You can learn more about GLSL types [on this page](https://www.opengl.org/wiki/Data_Type_(GLSL)).)
    To provide like input to a **mat2**, you'd need to define four separate inputs

    // ISADORA_FLOAT_PARAM(complexity00, cp00, 9.0, 900.0, 10.0, "veraendere dichtheit");

    // ISADORA_FLOAT_PARAM(complexity01, cp01, 9.0, 900.0, 10.0, "veraendere dichtheit");

    // ISADORA_FLOAT_PARAM(complexity10, cp10, 9.0, 900.0, 10.0, "veraendere dichtheit");

    // ISADORA_FLOAT_PARAM(complexity11, cp11, 9.0, 900.0, 10.0, "veraendere dichtheit");

    uniform float complexity00;

    uniform float complexity01;

    uniform float complexity10;

    uniform float complexity11;

    and then somewhere within your code, you'd need this to initialize a **mat2**called complexity as follows:

    mat2 complexity;

    complexity[0][0] = complexity00;

    complexity[0][1] = complexity01;

    complexity[1][0] = complexity10;

    complexity[1][1] = complexity11;

     

    I tested this and it works. Hopefully that will help one of you down the road.

     

    Best Wishes,

    Mark



  • nice


  • Tech Staff

    This should be added to a Knowledge base article on GLSL usage.



  • Dear @DusX,

    Added the mat2 stuff to the tutorial as an addendum.
    Best,
    Mark

Log in to reply
 

Looks like your connection to TroikaTronix Community Forum was lost, please wait while we try to reconnect.